datasources: add support for filtering

This commit is contained in:
Frédéric Péters 2013-02-11 15:03:39 +01:00
parent 5e718d3379
commit 66c1131213
1 changed files with 6 additions and 1 deletions

View File

@ -5,4 +5,9 @@ from models import BaseDataSource
@to_json('api')
def json(request, datasource):
ds = BaseDataSource.objects.get_subclass(slug=datasource)
return ds.get_data()
q = request.GET.get('q')
if q:
q = q.lower()
return [x for x in ds.get_data() if q in x.lower()]
else:
return ds.get_data()