diff options
author | Étienne Loks <etienne.loks@iggdrasil.net> | 2017-08-03 18:35:23 +0200 |
---|---|---|
committer | Étienne Loks <etienne.loks@iggdrasil.net> | 2017-08-03 18:35:23 +0200 |
commit | 7357dd53e48eb975a32c5fecc01ba01e75b417c5 (patch) | |
tree | fb818c98a0786ad6dc1cf3efe2bdbb66f5d93414 /archaeological_operations | |
parent | b002ac5c0d61337d63de299db519d0e1973a944e (diff) | |
download | Ishtar-7357dd53e48eb975a32c5fecc01ba01e75b417c5.tar.bz2 Ishtar-7357dd53e48eb975a32c5fecc01ba01e75b417c5.zip |
Lookups: add operations
Diffstat (limited to 'archaeological_operations')
-rw-r--r-- | archaeological_operations/lookups.py | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/archaeological_operations/lookups.py b/archaeological_operations/lookups.py new file mode 100644 index 000000000..b6fdaad23 --- /dev/null +++ b/archaeological_operations/lookups.py @@ -0,0 +1,21 @@ +from ajax_select import register, LookupChannel + +from django.db.models import Q +from archaeological_operations.models import Operation + + +@register('operation') +class OperationLookup(LookupChannel): + model = Operation + + def get_query(self, q, request): + query = Q() + for term in q.strip().split(' '): + subquery = ( + Q(cached_label__icontains=term) + ) + query &= subquery + return self.model.objects.filter(query).order_by('cached_label')[:20] + + def format_item_display(self, item): + return u"<span class='ajax-label'>%s</span>" % item.cached_label |