summaryrefslogtreecommitdiff
path: root/archaeological_context_records
diff options
context:
space:
mode:
Diffstat (limited to 'archaeological_context_records')
-rw-r--r--archaeological_context_records/forms.py17
-rw-r--r--archaeological_context_records/migrations/0109_contextrecord_excavation_technics.py26
-rw-r--r--archaeological_context_records/migrations/0110_auto_20221017_1435.py21
-rw-r--r--archaeological_context_records/models.py19
-rw-r--r--archaeological_context_records/templates/ishtar/sheet_contextrecord.html2
5 files changed, 68 insertions, 17 deletions
diff --git a/archaeological_context_records/forms.py b/archaeological_context_records/forms.py
index 0e06ae2e5..8d05e50e1 100644
--- a/archaeological_context_records/forms.py
+++ b/archaeological_context_records/forms.py
@@ -170,13 +170,13 @@ class RecordSelect(DocumentItemSelect, PeriodSelect):
cr_relation_types = forms.ChoiceField(
label=_("Search within relations"), choices=[]
)
- excavation_technic = forms.ChoiceField(label=_("Excavation technique"), choices=[])
+ excavation_technics = forms.ChoiceField(label=_("Excavation technique"), choices=[])
TYPES = PeriodSelect.TYPES + [
FieldType("unit", models.Unit),
FieldType("cr_relation_types", models.RelationType),
FieldType("ope_relation_types", OpeRelationType),
- FieldType("excavation_technic", models.ExcavationTechnicType),
+ FieldType("excavation_technics", models.ExcavationTechnicType),
]
SITE_KEYS = {"archaeological_site": None}
@@ -273,7 +273,7 @@ class RecordFormGeneral(CustomForm, ManageOldType):
form_admin_name = _("Context record - 020 - General")
form_slug = "contextrecord-020-general"
file_upload = True
- base_models = ["documentation"]
+ base_models = ["documentation", "excavation_technic"]
associated_models = {
"archaeological_site": ArchaeologicalSite,
"parcel": Parcel,
@@ -304,8 +304,11 @@ class RecordFormGeneral(CustomForm, ManageOldType):
comment = forms.CharField(
label=_("General comment"), widget=forms.Textarea, required=False
)
- excavation_technic = forms.ChoiceField(
- label=_("Excavation technique"), choices=[], required=False
+ excavation_technic = forms.MultipleChoiceField(
+ label=_("Excavation technique"),
+ choices=[],
+ required=False,
+ widget=widgets.Select2Multiple,
)
surface = forms.FloatField(
required=False,
@@ -362,7 +365,7 @@ class RecordFormGeneral(CustomForm, ManageOldType):
TYPES = [
FieldType("unit", models.Unit),
- FieldType("excavation_technic", models.ExcavationTechnicType),
+ FieldType("excavation_technic", models.ExcavationTechnicType, is_multiple=True),
FieldType("documentation", models.DocumentationType, is_multiple=True),
FieldType("spatial_reference_system", SpatialReferenceSystem),
]
@@ -455,7 +458,7 @@ class RecordFormGeneral(CustomForm, ManageOldType):
if not self.cleaned_data.get("parcel", None) and not self.cleaned_data.get(
"town", None
):
- raise forms.ValidationError(_("You have to choose a town or a " "parcel."))
+ raise forms.ValidationError(_("You have to choose a town or a parcel."))
return cleaned_data
diff --git a/archaeological_context_records/migrations/0109_contextrecord_excavation_technics.py b/archaeological_context_records/migrations/0109_contextrecord_excavation_technics.py
new file mode 100644
index 000000000..2179eb558
--- /dev/null
+++ b/archaeological_context_records/migrations/0109_contextrecord_excavation_technics.py
@@ -0,0 +1,26 @@
+# Generated by Django 2.2.24 on 2022-10-17 12:22
+
+from django.db import migrations, models
+
+
+def migrate(apps, schema_editor):
+ ContextRecord = apps.get_model('archaeological_context_records', 'ContextRecord')
+ for cr in ContextRecord.objects.filter(excavation_technic__isnull=False).all():
+ cr.excavation_technics.add(cr.excavation_technic)
+
+
+
+class Migration(migrations.Migration):
+
+ dependencies = [
+ ('archaeological_context_records', '0108_auto_20220707_1633'),
+ ]
+
+ operations = [
+ migrations.AddField(
+ model_name='contextrecord',
+ name='excavation_technics',
+ field=models.ManyToManyField(blank=True, related_name='context_records', to='archaeological_context_records.ExcavationTechnicType', verbose_name='Excavation technique'),
+ ),
+ migrations.RunPython(migrate),
+ ]
diff --git a/archaeological_context_records/migrations/0110_auto_20221017_1435.py b/archaeological_context_records/migrations/0110_auto_20221017_1435.py
new file mode 100644
index 000000000..c9f7f76a2
--- /dev/null
+++ b/archaeological_context_records/migrations/0110_auto_20221017_1435.py
@@ -0,0 +1,21 @@
+# Generated by Django 2.2.24 on 2022-10-17 14:35
+
+from django.db import migrations
+
+
+class Migration(migrations.Migration):
+
+ dependencies = [
+ ('archaeological_context_records', '0109_contextrecord_excavation_technics'),
+ ]
+
+ operations = [
+ migrations.RemoveField(
+ model_name='contextrecord',
+ name='excavation_technic',
+ ),
+ migrations.RemoveField(
+ model_name='historicalcontextrecord',
+ name='excavation_technic',
+ ),
+ ]
diff --git a/archaeological_context_records/models.py b/archaeological_context_records/models.py
index 08e94af85..97a629d05 100644
--- a/archaeological_context_records/models.py
+++ b/archaeological_context_records/models.py
@@ -529,7 +529,7 @@ class ContextRecord(
("datings__period__label", _("Period")),
("identification__label", _("Identification")),
("activity__label", _("Activity")),
- ("excavation_technic__label", _("Excavation technique")),
+ ("excavation_technics__label", _("Excavation technique")),
("documents__source_type__label", _("Associated document type")),
("last_modified__year", _("Modification (year)")),
]
@@ -620,9 +620,9 @@ class ContextRecord(
pgettext_lazy("key for text search", "record-relation-type"),
"cr_relation_types",
),
- "excavation_technic": SearchAltName(
+ "excavation_technics": SearchAltName(
pgettext_lazy("key for text search", "excavation-technique"),
- "excavation_technic__label__iexact",
+ "excavation_technics__label__iexact",
),
}
ALT_NAMES.update(BaseHistorizedItem.ALT_NAMES)
@@ -640,9 +640,11 @@ class ContextRecord(
SearchVectorConfig("datings_comment", "local"),
SearchVectorConfig("identification__label"),
SearchVectorConfig("activity__label"),
- SearchVectorConfig("excavation_technic__label"),
]
- M2M_SEARCH_VECTORS = [SearchVectorConfig("datings__period__label", "local")]
+ M2M_SEARCH_VECTORS = [
+ SearchVectorConfig("datings__period__label", "local"),
+ SearchVectorConfig("excavation_technics__label", "local"),
+ ]
UP_MODEL_QUERY = {
"operation": (
pgettext_lazy("key for text search", "operation"),
@@ -656,7 +658,7 @@ class ContextRecord(
("site", "archaeological_site__pk"),
("file", "operation__associated_file__pk"),
]
- HISTORICAL_M2M = ["datings", "documentations"]
+ HISTORICAL_M2M = ["datings", "documentations", "excavation_technics"]
CACHED_LABELS = ["cached_label", "cached_periods", "cached_related_context_records"]
DOWN_MODEL_UPDATE = ["base_finds"]
@@ -808,12 +810,11 @@ class ContextRecord(
on_delete=models.SET_NULL,
verbose_name=_("Activity"),
)
- excavation_technic = models.ForeignKey(
+ excavation_technics = models.ManyToManyField(
ExcavationTechnicType,
blank=True,
- null=True,
- on_delete=models.SET_NULL,
verbose_name=_("Excavation technique"),
+ related_name="context_records",
)
related_context_records = models.ManyToManyField(
"ContextRecord", through="RecordRelations", blank=True
diff --git a/archaeological_context_records/templates/ishtar/sheet_contextrecord.html b/archaeological_context_records/templates/ishtar/sheet_contextrecord.html
index acc131e88..a38d2c3bf 100644
--- a/archaeological_context_records/templates/ishtar/sheet_contextrecord.html
+++ b/archaeological_context_records/templates/ishtar/sheet_contextrecord.html
@@ -138,7 +138,7 @@
<hr class="clearfix">
<h3>{% trans "Description"%}</h3>
<div class="row">
- {% field_flex "Excavation technique" item.excavation_technic '' '' has_image %}
+ {% field_flex_multiple_obj "Excavation technique" item 'excavation_technics' has_image %}
{% field_flex_multiple_obj "Periods" item 'datings' has_image %}
{% field_flex "Town" item.town.label_with_areas '' '' has_image %}
{% field_flex_multiple_obj "Documentation" item 'documentations' has_image %}