summaryrefslogtreecommitdiff
path: root/archaeological_context_records/models.py
diff options
context:
space:
mode:
authorÉtienne Loks <etienne.loks@iggdrasil.net>2024-07-08 14:09:48 +0200
committerÉtienne Loks <etienne.loks@iggdrasil.net>2024-07-08 18:15:40 +0200
commitf2133b1363d3d275ce063c0cddebb3fb862e2637 (patch)
tree0131f651e3a8bb5347eda18622daf75523f92c82 /archaeological_context_records/models.py
parent4869a23a5adeeba3160267537ce6acccdf1a3aae (diff)
downloadIshtar-f2133b1363d3d275ce063c0cddebb3fb862e2637.tar.bz2
Ishtar-f2133b1363d3d275ce063c0cddebb3fb862e2637.zip
✨ Context records - identification: switch to multivalued
Diffstat (limited to 'archaeological_context_records/models.py')
-rw-r--r--archaeological_context_records/models.py20
1 files changed, 10 insertions, 10 deletions
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,