From f2133b1363d3d275ce063c0cddebb3fb862e2637 Mon Sep 17 00:00:00 2001 From: Étienne Loks Date: Mon, 8 Jul 2024 14:09:48 +0200 Subject: ✨ Context records - identification: switch to multivalued MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- archaeological_context_records/models.py | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) (limited to 'archaeological_context_records/models.py') diff --git a/archaeological_context_records/models.py b/archaeological_context_records/models.py index 0c245abd4..c41b691cf 100644 --- a/archaeological_context_records/models.py +++ b/archaeological_context_records/models.py @@ -520,7 +520,7 @@ class ContextRecord( ("unit__label", _("Context record type")), ("operation__cached_label", _("Operation")), ("datings__period__label", _("Chronological period")), - ("identification__label", _("Identification")), + ("identifications__label", _("Identification")), ("activity__label", _("Activity")), ("excavation_technics__label", _("Excavation techniques")), ("documents__source_type__label", _("Associated document type")), @@ -532,6 +532,7 @@ class ContextRecord( "documentations", "cultural_attributions", "excavation_technics", + "identifications" ] # search parameters @@ -614,10 +615,6 @@ class ContextRecord( "activity": SearchAltName( pgettext_lazy("key for text search", "activity"), "activity__label__iexact" ), - "identification": SearchAltName( - pgettext_lazy("key for text search", "identification"), - "identification__label__iexact" - ), "parcel": SearchAltName( pgettext_lazy("key for text search", "parcel"), "parcel__cached_label__iexact", @@ -637,6 +634,10 @@ class ContextRecord( pgettext_lazy("key for text search", "cultural-attribution"), "cultural_attributions__label__iexact", ), + "identifications": SearchAltName( + pgettext_lazy("key for text search", "identification"), + "identifications__label__iexact" + ), } ALT_NAMES.update(BaseHistorizedItem.ALT_NAMES) ALT_NAMES.update(DocumentItem.ALT_NAMES) @@ -653,13 +654,13 @@ class ContextRecord( SearchVectorConfig("interpretation", "local"), SearchVectorConfig("filling", "local"), SearchVectorConfig("datings_comment", "local"), - SearchVectorConfig("identification__label"), SearchVectorConfig("unit__label"), SearchVectorConfig("activity__label"), ] M2M_SEARCH_VECTORS = [ SearchVectorConfig("datings__period__label", "local"), SearchVectorConfig("excavation_technics__label", "local"), + SearchVectorConfig("identifications__label", "local"), ] UP_MODEL_QUERY = { "operation": ( @@ -674,7 +675,7 @@ class ContextRecord( ("site", "archaeological_site__pk"), ("file", "operation__associated_file__pk"), ] - HISTORICAL_M2M = ["datings", "documentations", "excavation_technics"] + HISTORICAL_M2M = ["datings", "documentations", "excavation_technics", "identifications"] CACHED_LABELS = ["cached_label", "cached_periods", "cached_related_context_records"] DOWN_MODEL_UPDATE = ["base_finds"] @@ -815,12 +816,11 @@ class ContextRecord( null=True, help_text=_('Estimation of a "Terminus Post Quem"'), ) - identification = models.ForeignKey( + identifications = models.ManyToManyField( IdentificationType, blank=True, - null=True, - on_delete=models.SET_NULL, verbose_name=_("Identification"), + related_name="context_records", ) activity = models.ForeignKey( ActivityType, -- cgit v1.2.3