diff options
author | Étienne Loks <etienne.loks@iggdrasil.net> | 2018-08-10 17:59:44 +0200 |
---|---|---|
committer | Étienne Loks <etienne.loks@iggdrasil.net> | 2018-08-13 18:26:04 +0200 |
commit | 1ee3cc6e7f0b0d6207d065b155ed77bfbb5ad5c4 (patch) | |
tree | 04f21ad44a463b7e9677f56f9243b7e5de228811 /archaeological_context_records/models.py | |
parent | 1d94279572cd21e9d126ac73f6f13dad91c59c23 (diff) | |
download | Ishtar-1ee3cc6e7f0b0d6207d065b155ed77bfbb5ad5c4.tar.bz2 Ishtar-1ee3cc6e7f0b0d6207d065b155ed77bfbb5ad5c4.zip |
Context record search configuration
Diffstat (limited to 'archaeological_context_records/models.py')
-rw-r--r-- | archaeological_context_records/models.py | 57 |
1 files changed, 55 insertions, 2 deletions
diff --git a/archaeological_context_records/models.py b/archaeological_context_records/models.py index 211be9ade..97bf2a117 100644 --- a/archaeological_context_records/models.py +++ b/archaeological_context_records/models.py @@ -25,10 +25,10 @@ from django.core.urlresolvers import reverse from django.db import connection, transaction from django.db.models import Q from django.db.models.signals import post_delete, post_save -from django.utils.translation import ugettext_lazy as _, ugettext, pgettext +from django.utils.translation import ugettext_lazy as _, pgettext, pgettext_lazy from django.utils.text import slugify -from ishtar_common.utils import cached_label_changed +from ishtar_common.utils import cached_label_changed, TXT_SEARCH_COMMENT from ishtar_common.models import Document, GeneralType, \ BaseHistorizedItem, HistoricalRecords, OwnPerms, ShortMenuItem, \ @@ -256,6 +256,55 @@ class ContextRecord(BulkUpdatedItem, BaseHistorizedItem, RELATIVE_SESSION_NAMES = [ ('operation', 'operation__pk'), ('file', 'operation__associated_file__pk')] + # alternative names of fields for searches + ALT_NAMES = { + 'label': ( + pgettext_lazy(TXT_SEARCH_COMMENT, u"id"), + 'label' + ), + 'town': ( + pgettext_lazy(TXT_SEARCH_COMMENT, u"town"), + 'town__cached_label__iexact' + ), + 'operation__year': ( + pgettext_lazy(TXT_SEARCH_COMMENT, u"operation-year"), + 'operation__year' + ), + 'operation__code_patriarche': ( + pgettext_lazy(TXT_SEARCH_COMMENT, u"patriarche"), + 'operation__code_patriarche' + ), + 'operation__operation_code': ( + pgettext_lazy(TXT_SEARCH_COMMENT, u"operation-code"), + 'operation__operation_code' + ), + 'archaeological_site': ( + pgettext_lazy(TXT_SEARCH_COMMENT, u"site"), + 'archaeological_site__cached_label__icontains' + ), + 'ope_relation_types': ( + pgettext_lazy(TXT_SEARCH_COMMENT, u"operation-relation-type"), + 'ope_relation_types' + ), + 'datings__period': ( + pgettext_lazy(TXT_SEARCH_COMMENT, u"period"), + 'datings__period__label__iexact' + ), + 'unit': ( + pgettext_lazy(TXT_SEARCH_COMMENT, u"unit-type"), + 'unit__label__iexact' + ), + 'parcel': ( + pgettext_lazy(TXT_SEARCH_COMMENT, u"parcel"), + 'parcel__cached_label__iexact' + ), + 'cr_relation_types': ( + pgettext_lazy(TXT_SEARCH_COMMENT, u"record-relation-type"), + 'cr_relation_types' + ), + } + for v in ALT_NAMES.values(): + EXTRA_REQUEST_KEYS[v[0]] = v[1] # fields external_id = models.TextField(_(u"External ID"), blank=True, null=True) @@ -670,5 +719,9 @@ class RecordRelationView(models.Model): ("view_recordrelation", u"Can view all record relations - view"), ] + @classmethod + def general_types(cls): + return [] + def __unicode__(self): return u"{} \"{}\"".format(self.relation_type, self.right_record) |