diff options
Diffstat (limited to 'archaeological_operations/models.py')
-rw-r--r-- | archaeological_operations/models.py | 113 |
1 files changed, 85 insertions, 28 deletions
diff --git a/archaeological_operations/models.py b/archaeological_operations/models.py index 872d2bf4e..d8233ba0f 100644 --- a/archaeological_operations/models.py +++ b/archaeological_operations/models.py @@ -108,6 +108,7 @@ class ArchaeologicalSite(BaseHistorizedItem, OwnPerms, ValueGetter, SHOW_URL = 'show-site' TABLE_COLS = ['reference', 'name', 'towns_label', 'periods', 'remains'] SLUG = 'site' + LONG_SLUG = 'archaeologicalsite' BASE_SEARCH_VECTORS = [ "comment", @@ -119,6 +120,8 @@ class ArchaeologicalSite(BaseHistorizedItem, OwnPerms, ValueGetter, "reference", "shipwreck_code", "shipwreck_name", + "drassm_number", + "affmar_number", ] M2M_SEARCH_VECTORS = ["periods__label", "remains__label", "towns__name"] PARENT_SEARCH_VECTORS = ['operations'] @@ -192,6 +195,14 @@ class ArchaeologicalSite(BaseHistorizedItem, OwnPerms, ValueGetter, pgettext_lazy("key for text search", u"top-operation"), 'top_operation__cached_label__icontains' ), + 'drassm_number': ( + pgettext_lazy("key for text search", u"numero-drassm"), + 'drassm_number__iexact' + ), + 'affmar_number': ( + pgettext_lazy("key for text search", u"numero-affmar"), + 'affmar_number__iexact' + ), } for v in ALT_NAMES.values(): for language_code, language_lbl in settings.LANGUAGES: @@ -243,6 +254,10 @@ class ArchaeologicalSite(BaseHistorizedItem, OwnPerms, ValueGetter, _(u"Sinking date"), null=True, blank=True) discovery_area = models.TextField( _(u"Discovery area"), null=True, blank=True) + affmar_number = models.CharField(_(u"AffMar number"), max_length=100, + null=True, blank=True) + drassm_number = models.CharField(_(u"DRASSM number"), max_length=100, + null=True, blank=True) # gis point = models.PointField(_(u"Point"), blank=True, null=True) @@ -290,6 +305,9 @@ class ArchaeologicalSite(BaseHistorizedItem, OwnPerms, ValueGetter, 'operations__context_record__base_finds__find__container__responsible__', Warehouse._get_query_owns_dicts(ishtaruser) ) | cls._construct_query_own( + 'operations__context_record__base_finds__find__basket__', + [{"shared_with": ishtaruser, "shared_write_with": ishtaruser}] + ) | cls._construct_query_own( 'operations__context_record__base_finds__find__container__location__', Warehouse._get_query_owns_dicts(ishtaruser) ) | cls._construct_query_own( @@ -541,6 +559,7 @@ class Operation(ClosedItem, BaseHistorizedItem, OwnPerms, ValueGetter, "scientist__cached_label", "scientific_documentation_comment", "seizure_name", + "drassm_code", ] PROPERTY_SEARCH_VECTORS = [ "full_reference", "short_code_patriarche" @@ -705,6 +724,10 @@ class Operation(ClosedItem, BaseHistorizedItem, OwnPerms, ValueGetter, pgettext_lazy("key for text search", u"finds-deadline-after"), 'finds_deadline__gte' ), + 'drassm_code': ( + pgettext_lazy("key for text search", u"code-drassm"), + 'drassm_code__iexact' + ), } for v in ALT_NAMES.values(): for language_code, language_lbl in settings.LANGUAGES: @@ -783,34 +806,35 @@ class Operation(ClosedItem, BaseHistorizedItem, OwnPerms, ValueGetter, blank=True, null=True) old_code = models.CharField(_(u"Old code"), max_length=200, null=True, blank=True) - if settings.COUNTRY == 'fr': - code_patriarche = models.TextField(u"Code PATRIARCHE", null=True, - blank=True, unique=True) - TABLE_COLS = ['code_patriarche'] + TABLE_COLS - BASE_SEARCH_VECTORS = ['code_patriarche'] + BASE_SEARCH_VECTORS - # preventive - fnap_financing = models.FloatField(u"Financement FNAP (%)", - blank=True, null=True) - # preventive - fnap_cost = models.IntegerField(u"Financement FNAP (€)", - blank=True, null=True) - # preventive diag - zoning_prescription = models.NullBooleanField( - _(u"Prescription on zoning"), blank=True, null=True) - # preventive diag - large_area_prescription = models.NullBooleanField( - _(u"Prescription on large area"), blank=True, null=True) - geoarchaeological_context_prescription = models.NullBooleanField( - _(u"Prescription on geoarchaeological context"), blank=True, - null=True) # preventive diag - cira_rapporteur = models.ForeignKey( - Person, related_name='cira_rapporteur', null=True, blank=True, - on_delete=models.SET_NULL, verbose_name=u"Rapporteur CIRA") - negative_result = models.NullBooleanField( - u"Résultat considéré comme négatif", blank=True, null=True) - cira_date = models.DateField(u"Date avis CIRA", null=True, blank=True) - eas_number = models.CharField(u"Numéro de l'EA", max_length=20, - null=True, blank=True) + ## fr + code_patriarche = models.TextField(u"Code PATRIARCHE", null=True, + blank=True, unique=True) + TABLE_COLS = ['code_patriarche'] + TABLE_COLS + BASE_SEARCH_VECTORS = ['code_patriarche'] + BASE_SEARCH_VECTORS + # preventive + fnap_financing = models.FloatField(u"Financement FNAP (%)", + blank=True, null=True) + # preventive + fnap_cost = models.IntegerField(u"Financement FNAP (€)", + blank=True, null=True) + # preventive diag + zoning_prescription = models.NullBooleanField( + _(u"Prescription on zoning"), blank=True, null=True) + # preventive diag + large_area_prescription = models.NullBooleanField( + _(u"Prescription on large area"), blank=True, null=True) + geoarchaeological_context_prescription = models.NullBooleanField( + _(u"Prescription on geoarchaeological context"), blank=True, + null=True) # preventive diag + cira_rapporteur = models.ForeignKey( + Person, related_name='cira_rapporteur', null=True, blank=True, + on_delete=models.SET_NULL, verbose_name=u"Rapporteur CIRA") + negative_result = models.NullBooleanField( + u"Résultat considéré comme négatif", blank=True, null=True) + cira_date = models.DateField(u"Date avis CIRA", null=True, blank=True) + eas_number = models.CharField(u"Numéro de l'EA", max_length=20, + null=True, blank=True) + ## end fr operator_reference = models.CharField( _(u"Operator reference"), max_length=20, null=True, blank=True) common_name = models.TextField(_(u"Generic name"), null=True, blank=True) @@ -845,6 +869,9 @@ class Operation(ClosedItem, BaseHistorizedItem, OwnPerms, ValueGetter, finds_received = models.NullBooleanField( _(u"Finds received"), blank=True, null=True) + # underwater + drassm_code = models.CharField(_(u"DRASSM code"), max_length=100, + null=True, blank=True) # judiciary seizure_name = models.TextField(_(u"Seizure name"), blank=True, null=True) official_report_number = models.TextField(_(u"Official report number"), @@ -1040,6 +1067,22 @@ class Operation(ClosedItem, BaseHistorizedItem, OwnPerms, ValueGetter, finds__base_finds__context_record__operation=self ) + def get_extra_actions(self, request): + """ + For sheet template + """ + # url, base_text, icon, extra_text, extra css class, is a quick action + actions = super(Operation, self).get_extra_actions(request) + + can_add_cr = self.can_do(request, 'add_contextrecord') + if can_add_cr: + actions += [ + (reverse('operation-qa-contextrecord', args=[self.pk]), + _(u"Add context record"), "fa fa-plus", + _(u"context record"), "", True), + ] + return actions + associated_file_short_label_lbl = _(u"Archaeological file") full_code_patriarche_lbl = _(u"Code patriarche") @@ -1131,6 +1174,9 @@ class Operation(ClosedItem, BaseHistorizedItem, OwnPerms, ValueGetter, 'context_record__base_finds__find__container__location__', Warehouse._get_query_owns_dicts(ishtaruser) ) | cls._construct_query_own( + 'context_record__base_finds__find__basket__', + [{"shared_with": ishtaruser, "shared_write_with": ishtaruser}] + ) | cls._construct_query_own( '', cls._get_query_owns_dicts(ishtaruser) ) return q @@ -1461,6 +1507,7 @@ class AdministrativeAct(BaseHistorizedItem, OwnPerms, ValueGetter): 'act_object', 'signature_date', 'associated_file__cached_label', 'operation__cached_label', 'towns_label'] + SLUG = "administrativeact" TABLE_COLS_FILE = [ 'full_ref', 'year', 'index', 'act_type', 'act_object', 'associated_file', 'towns_label', @@ -1826,6 +1873,16 @@ class AdministrativeAct(BaseHistorizedItem, OwnPerms, ValueGetter): if self.treatment_file: return self.treatment_file + def get_extra_templates(self, request): + templates = [] + for template in self.act_type.associated_template.all(): + urlname = "generatedoc-administrativeactop" + templates.append( + (template.name, reverse( + urlname, args=[self.pk, template.pk])) + ) + return templates + def get_filename(self): filename = self.related_item.associated_filename filename = u"-".join(filename.split('-')[:-1]) # remove date |