diff options
| author | Étienne Loks <etienne.loks@iggdrasil.net> | 2016-10-22 13:41:02 +0200 | 
|---|---|---|
| committer | Étienne Loks <etienne.loks@iggdrasil.net> | 2016-10-22 13:41:02 +0200 | 
| commit | dafc5d16f3095bad00356b6198afcd5bbeab61d6 (patch) | |
| tree | 7040d1fd325ba67b890122059a8f50a3857e332a /archaeological_context_records/models.py | |
| parent | 64bb69c03ce1688c72b3f7ebd0e1550cd941aa69 (diff) | |
| parent | 0ecd905165193897129a71a1e8203232f0b2b68c (diff) | |
| download | Ishtar-dafc5d16f3095bad00356b6198afcd5bbeab61d6.tar.bz2 Ishtar-dafc5d16f3095bad00356b6198afcd5bbeab61d6.zip | |
Merge branch 'master' into v0.9
Diffstat (limited to 'archaeological_context_records/models.py')
| -rw-r--r-- | archaeological_context_records/models.py | 54 | 
1 files changed, 54 insertions, 0 deletions
| diff --git a/archaeological_context_records/models.py b/archaeological_context_records/models.py index e1cb216a2..bbfb410f8 100644 --- a/archaeological_context_records/models.py +++ b/archaeological_context_records/models.py @@ -135,6 +135,27 @@ class ContextRecord(BaseHistorizedItem, ImageModel, OwnPerms, ShortMenuItem):          }      }      IMAGE_PREFIX = 'context_records/' + +    # search parameters +    EXTRA_REQUEST_KEYS = { +        'parcel__town': 'parcel__town__pk', +        'operation__year': 'operation__year__contains', +        'operation__code_patriarche': 'operation__code_patriarche', +        'operation__operation_code': 'operation__operation_code', +        'datings__period': 'datings__period__pk', +        'parcel_0': 'operation__parcels__section', +        'parcel_1': 'operation__parcels__parcel_number', +        'parcel_2': 'operation__parcels__public_domain', +        'label': 'label__icontains', +        'archaeological_sites': 'operation__archaeological_sites__pk', +        'cached_label': 'cached_label__icontains', +    } +    RELATION_TYPES_PREFIX = {'ope_relation_types': 'operation__'} +    RELATIVE_SESSION_NAMES = [ +        ('operation', 'operation__pk'), +        ('file', 'operation__associated_file__pk')] + +    # fields      external_id = models.TextField(_(u"External ID"), blank=True, null=True)      auto_external_id = models.BooleanField(          _(u"External ID is set automatically"), default=False) @@ -264,6 +285,10 @@ class ContextRecord(BaseHistorizedItem, ImageModel, OwnPerms, ShortMenuItem):      def _generate_cached_label(self):          return self.full_label() +    def _get_associated_cached_labels(self): +        from archaeological_finds.models import Find +        return list(Find.objects.filter(base_finds__context_record=self).all()) +      @property      def reference(self):          if not self.operation: @@ -383,6 +408,11 @@ class RecordRelations(GeneralRecordRelations, models.Model):          "right_record__datings__period": _(u"Periods (right)")      } +    # search parameters +    EXTRA_REQUEST_KEYS = { +        "left_record__operation": "left_record__operation__pk" +    } +      class Meta:          verbose_name = _(u"Record relation")          verbose_name_plural = _(u"Record relations") @@ -396,6 +426,30 @@ class ContextRecordSource(Source):      TABLE_COLS = ['context_record__operation', 'context_record'] + \          Source.TABLE_COLS +    # search parameters +    RELATIVE_SESSION_NAMES = [ +        ('contextrecord', 'context_record__pk'), +        ('operation', 'context_record__operation__pk'), +        ('file', 'context_record__operation__associated_file__pk')] +    BOOL_FIELDS = ['duplicate'] +    EXTRA_REQUEST_KEYS = { +        'title': 'title__icontains', +        'description': 'description__icontains', +        'comment': 'comment__icontains', +        'person': 'authors__person__pk', +        'additional_information': 'additional_information__icontains', +        'context_record__parcel__town': 'context_record__parcel__town__pk', +        'context_record__operation__year': 'context_record__operation__year', +        'context_record__operation__operation_code': +        'context_record__operation__operation_code', +        'context_record__operation__code_patriarche': +        'context_record__operation__code_patriarche', +        'context_record__operation': 'context_record__operation__pk', +        'context_record__datings__period': +            'context_record__datings__period__pk', +        'context_record__unit': 'context_record__unit__pk', +    } +      class Meta:          verbose_name = _(u"Context record documentation")          verbose_name_plural = _(u"Context record documentations") | 
