diff options
Diffstat (limited to 'archaeological_operations/models.py')
-rw-r--r-- | archaeological_operations/models.py | 131 |
1 files changed, 121 insertions, 10 deletions
diff --git a/archaeological_operations/models.py b/archaeological_operations/models.py index d64936c90..ce804765d 100644 --- a/archaeological_operations/models.py +++ b/archaeological_operations/models.py @@ -177,10 +177,56 @@ class Operation(ClosedItem, BaseHistorizedItem, ImageModel, OwnPerms, QUALITY_DICT = dict(QUALITY) SHOW_URL = 'show-operation' TABLE_COLS = ['year_index', 'operation_type', 'remains', 'towns', - 'start_date', 'excavation_end_date'] - TABLE_COLS.insert(4, 'associated_file_short_label') + 'associated_file_short_label', 'start_date', + 'excavation_end_date'] IMAGE_PREFIX = 'operations/' SLUG = 'operation' + + # search parameters + BOOL_FIELDS = ['end_date__isnull', 'virtual_operation', + 'documentation_received', 'finds_received'] + DATED_FIELDS = [ + 'start_date__lte', 'start_date__gte', 'excavation_end_date__lte', + 'excavation_end_date__gte', 'documentation_deadline__lte', + 'documentation_deadline__gte', 'finds_deadline__lte', + 'finds_deadline__gte'] + RELATIVE_SESSION_NAMES = [('file', 'associated_file__pk')] + EXTRA_REQUEST_KEYS = { + 'common_name': 'common_name__icontains', + 'cached_label': 'cached_label__icontains', + 'comment': 'comment__icontains', + 'scientific_documentation_comment': + 'scientific_documentation_comment__icontains', + 'abstract': 'abstract__icontains', + 'end_date': 'end_date__isnull', + 'year_index': ('year', 'operation_code'), + 'start_before': 'start_date__lte', + 'start_after': 'start_date__gte', + 'end_before': 'excavation_end_date__lte', + 'end_after': 'excavation_end_date__gte', + 'towns__numero_insee__startswith': + 'towns__numero_insee__startswith', + 'parcel_0': ('parcels__section', + 'associated_file__parcels__section'), + 'parcel_1': ( + 'parcels__parcel_number', + 'associated_file__parcels__parcel_number'), + 'parcel_2': ( + 'parcels__public_domain', + 'associated_file__parcels__public_domain'), + 'history_creator': + 'history_creator__ishtaruser__person__pk', + 'history_modifier': + 'history_modifier__ishtaruser__person__pk', + 'archaeological_sites': + 'archaeological_sites__pk', + 'documentation_deadline_before': 'documentation_deadline__lte', + 'documentation_deadline_after': 'documentation_deadline__gte', + 'finds_deadline_before': 'finds_deadline__lte', + 'finds_deadline_after': 'finds_deadline__gte', + } + + # fields definition creation_date = models.DateField(_(u"Creation date"), default=datetime.date.today) end_date = models.DateField(_(u"Closing date"), null=True, blank=True) @@ -760,6 +806,31 @@ class OperationByDepartment(models.Model): class OperationSource(Source): + SHOW_URL = 'show-operationsource' + MODIFY_URL = 'operation_source_modify' + TABLE_COLS = ['operation.year', 'operation.operation_code', 'index'] + \ + Source.TABLE_COLS + + # search parameters + BOOL_FIELDS = ['duplicate'] + EXTRA_REQUEST_KEYS = { + 'title': 'title__icontains', + 'description': 'description__icontains', + 'comment': 'comment__icontains', + 'additional_information': 'additional_information__icontains', + 'person': 'authors__person__pk', + 'operation__towns': 'operation__towns__pk', + 'operation__operation_code': 'operation__operation_code', + 'operation__code_patriarche': 'operation__code_patriarche', + 'operation__operation_type': 'operation__operation_type__pk', + 'operation__year': 'operation__year'} + + # fields + operation = models.ForeignKey(Operation, verbose_name=_(u"Operation"), + related_name="source") + index = models.IntegerField(verbose_name=_(u"Index"), blank=True, + null=True) + class Meta: verbose_name = _(u"Operation documentation") verbose_name_plural = _(u"Operation documentations") @@ -775,14 +846,6 @@ class OperationSource(Source): ("delete_own_operationsource", ugettext(u"Can delete own Operation source")), ) - operation = models.ForeignKey(Operation, verbose_name=_(u"Operation"), - related_name="source") - index = models.IntegerField(verbose_name=_(u"Index"), blank=True, - null=True) - TABLE_COLS = ['operation.year', 'operation.operation_code', 'index'] + \ - Source.TABLE_COLS - SHOW_URL = 'show-operationsource' - MODIFY_URL = 'operation_source_modify' @property def owner(self): @@ -823,6 +886,54 @@ class AdministrativeAct(BaseHistorizedItem, OwnPerms, ValueGetter): TABLE_COLS.append('departments_label') TABLE_COLS_FILE.append('departments_label') TABLE_COLS_OPE.append('departments_label') + + # search parameters + DATED_FIELDS = ['signature_date__lte', 'signature_date__gte'] + ASSOCIATED_MODELS = [ + (models.File, 'associated_file'), + (Person, 'associated_file__general_contractor')] + EXTRA_REQUEST_KEYS = { + 'act_object': 'act_object__icontains', + 'act_type__intented_to': 'act_type__intented_to', + 'associated_file__general_contractor__attached_to': + 'associated_file__general_contractor__attached_to__pk', + 'associated_file__name': 'associated_file__name__icontains', + 'associated_file__operations__code_patriarche': + 'associated_file__operations__code_patriarche', + 'associated_file__permit_reference': + 'associated_file__permit_reference__icontains', + 'associated_file__towns': 'associated_file__towns__pk', + 'associated_file__towns__numero_insee__startswith': + 'associated_file__towns__numero_insee__startswith', + 'indexed': 'index__isnull', + 'history_creator': + 'history_creator__ishtaruser__person__pk', + 'history_modifier': + 'history_modifier__ishtaruser__person__pk', + 'operation__code_patriarche': 'operation__code_patriarche', + 'operation__towns': 'operation__towns__pk', + 'operation__towns__numero_insee__startswith': + 'operation__towns__numero_insee__startswith', + 'parcel_0': ('associated_file__parcels__section', + 'operation__parcels__section', + 'operation__associated_file__parcels__section'), + 'parcel_1': ( + 'associated_file__parcels__parcel_number' + 'operation__parcels__parcel_number', + 'operation__associated_file__parcels__parcel_number'), + 'parcel_2': ( + 'associated_file__parcels__public_domain', + 'operation__parcels__public_domain', + 'operation__associated_file__parcels__public_domain'), + 'signature_date_before': 'signature_date__lte', + 'signature_date_after': 'signature_date__gte', + 'year': 'signature_date__year', + } + REVERSED_BOOL_FIELDS = ['index__isnull'], + RELATIVE_SESSION_NAMES = [('operation', 'operation__pk'), + ('file', 'associated_file__pk')] + + # fields act_type = models.ForeignKey(ActType, verbose_name=_(u"Act type")) in_charge = models.ForeignKey( Person, blank=True, null=True, |