diff options
author | Étienne Loks <etienne.loks@iggdrasil.net> | 2018-08-09 19:02:49 +0200 |
---|---|---|
committer | Étienne Loks <etienne.loks@iggdrasil.net> | 2018-08-13 18:26:04 +0200 |
commit | 862d49c1bd6fe5bd5cb6312d3e125a333d50158b (patch) | |
tree | 717f96c1a9bae8c8f81b0a3ab4358cc0b767cbb6 /archaeological_operations/models.py | |
parent | 3ab10cd96173edd3786eb6fd69dbcc4ac0f4772e (diff) | |
download | Ishtar-862d49c1bd6fe5bd5cb6312d3e125a333d50158b.tar.bz2 Ishtar-862d49c1bd6fe5bd5cb6312d3e125a333d50158b.zip |
Adapt search form for sites
Diffstat (limited to 'archaeological_operations/models.py')
-rw-r--r-- | archaeological_operations/models.py | 63 |
1 files changed, 63 insertions, 0 deletions
diff --git a/archaeological_operations/models.py b/archaeological_operations/models.py index f09184a32..8fa00a215 100644 --- a/archaeological_operations/models.py +++ b/archaeological_operations/models.py @@ -116,6 +116,69 @@ class ArchaeologicalSite(BaseHistorizedItem): M2M_SEARCH_VECTORS = ["periods__label", "remains__label", "towns__name"] PARENT_SEARCH_VECTORS = ['operations'] + DATED_FIELDS = ['sinking_date'] + + EXTRA_REQUEST_KEYS = {} + + # alternative names of fields for searches + ALT_NAMES = { + 'reference': ( + pgettext_lazy(TXT_SEARCH_COMMENT, u"reference"), + 'reference' + ), + 'name': ( + pgettext_lazy(TXT_SEARCH_COMMENT, u"name"), + 'name' + ), + 'periods': ( + pgettext_lazy(TXT_SEARCH_COMMENT, u"period"), + 'periods__label__iexact' + ), + 'remains': ( + pgettext_lazy(TXT_SEARCH_COMMENT, u"remain"), + 'remains__label__iexact' + ), + 'towns': ( + pgettext_lazy(TXT_SEARCH_COMMENT, u"town"), + 'towns__cached_label__iexact' + ), + 'comment': ( + pgettext_lazy(TXT_SEARCH_COMMENT, u"comment"), + 'comment__icontains' + ), + 'locality_ngi': ( + pgettext_lazy(TXT_SEARCH_COMMENT, u"locality-ngi"), + 'locality_ngi__icontains' + ), + 'locality_cadastral': ( + pgettext_lazy(TXT_SEARCH_COMMENT, u"locality-cadastral"), + 'locality_cadastral__icontains' + ), + 'shipwreck_name': ( + pgettext_lazy(TXT_SEARCH_COMMENT, u"shipwreck-name"), + 'shipwreck_name__iexact' + ), + 'oceanographic_service_localisation': ( + pgettext_lazy(TXT_SEARCH_COMMENT, + u"oceanographic-service-localisation"), + 'oceanographic_service_localisation__icontains' + ), + 'shipwreck_code': ( + pgettext_lazy(TXT_SEARCH_COMMENT, u"shipwreck-code"), + 'shipwreck_code__iexact' + ), + 'sinking_date': ( + pgettext_lazy(TXT_SEARCH_COMMENT, u"sinking-date"), + 'sinking_date' + ), + 'discovery_area': ( + pgettext_lazy(TXT_SEARCH_COMMENT, u"discovery-area"), + 'discovery_area__icontains' + ), + } + for v in ALT_NAMES.values(): + EXTRA_REQUEST_KEYS[v[0]] = v[1] + reference = models.CharField(_(u"Reference"), max_length=200, unique=True) name = models.CharField(_(u"Name"), max_length=200, null=True, blank=True) |