@@ -1358,20 +1358,24 def get_paginator(model, page, order, filters={}, n=10): | |||
|
1358 | 1358 | [filters.pop(key) for key in filters.keys() if filters[key] in ('', ' ')] |
|
1359 | 1359 | filters.pop('page', None) |
|
1360 | 1360 | |
|
1361 | if 'template' in filters: | |
|
1362 | filters['template'] = True | |
|
1361 | 1363 | if 'start_date' in filters: |
|
1362 | 1364 | filters['start_date__gte'] = filters.pop('start_date') |
|
1363 | 1365 | if 'end_date' in filters: |
|
1364 | 1366 | filters['start_date__lte'] = filters.pop('end_date') |
|
1365 | 1367 | if 'tags' in filters: |
|
1366 | 1368 | tags = filters.pop('tags') |
|
1367 |
|
|
|
1369 | fields = [f.name for f in model._meta.get_fields()] | |
|
1370 | ||
|
1371 | if 'tags' in fields: | |
|
1368 | 1372 | query = query | Q(tags__icontains=tags) |
|
1369 |
if 'name' in |
|
|
1373 | if 'name' in fields: | |
|
1370 | 1374 | query = query | Q(name__icontains=tags) |
|
1371 |
if 'location' in |
|
|
1375 | if 'location' in fields: | |
|
1372 | 1376 | query = query | Q(location__name__icontains=tags) |
|
1373 |
if 'device' in |
|
|
1374 | query = query | Q(device__name__icontains=tags) | |
|
1377 | if 'device' in fields: | |
|
1378 | query = query | Q(device__device_type__name__icontains=tags) | |
|
1375 | 1379 | |
|
1376 | 1380 | object_list = model.objects.filter(query, **filters).order_by(*order) |
|
1377 | 1381 | paginator = Paginator(object_list, n) |
General Comments 0
You need to be logged in to leave comments.
Login now