diff options
3 files changed, 48 insertions, 6 deletions
diff --git a/archaeological_context_records/migrations/0121_add_hierarchy_documentations_excavation_technics.py b/archaeological_context_records/migrations/0121_add_hierarchy_documentations_excavation_technics.py new file mode 100644 index 000000000..0aeb2b46d --- /dev/null +++ b/archaeological_context_records/migrations/0121_add_hierarchy_documentations_excavation_technics.py @@ -0,0 +1,42 @@ +# Generated by Django 2.2.24 on 2024-09-23 14:48 + +from django.db import migrations, models +import django.db.models.deletion + + +class Migration(migrations.Migration): + + dependencies = [ + ('archaeological_context_records', '0120_excavator'), + ] + + operations = [ + migrations.AlterModelOptions( + name='documentationtype', + options={'ordering': ('order', 'label'), 'verbose_name': 'Documentation type', 'verbose_name_plural': 'Documentation types'}, + ), + migrations.AlterModelOptions( + name='excavationtechnictype', + options={'ordering': ('order', 'label'), 'verbose_name': 'Excavation technique type', 'verbose_name_plural': 'Excavation technique types'}, + ), + migrations.AddField( + model_name='documentationtype', + name='order', + field=models.IntegerField(default=10, verbose_name='Order'), + ), + migrations.AddField( + model_name='documentationtype', + name='parent', + field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, to='archaeological_context_records.DocumentationType', verbose_name='Parent'), + ), + migrations.AddField( + model_name='excavationtechnictype', + name='order', + field=models.IntegerField(default=10, verbose_name='Order'), + ), + migrations.AddField( + model_name='excavationtechnictype', + name='parent', + field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, to='archaeological_context_records.ExcavationTechnicType', verbose_name='Parent'), + ), + ] diff --git a/archaeological_context_records/models.py b/archaeological_context_records/models.py index efef8cce0..90f961c0a 100644 --- a/archaeological_context_records/models.py +++ b/archaeological_context_records/models.py @@ -404,22 +404,22 @@ post_save.connect(post_save_cache, sender=InclusionType) post_delete.connect(post_save_cache, sender=InclusionType) -class ExcavationTechnicType(GeneralType): +class ExcavationTechnicType(OrderedHierarchicalType): class Meta: verbose_name = _("Excavation technique type") verbose_name_plural = _("Excavation technique types") - ordering = ("label",) + ordering = ("order", "label") post_save.connect(post_save_cache, sender=ExcavationTechnicType) post_delete.connect(post_save_cache, sender=ExcavationTechnicType) -class DocumentationType(GeneralType): +class DocumentationType(OrderedHierarchicalType): class Meta: verbose_name = _("Documentation type") verbose_name_plural = _("Documentation types") - ordering = ("label",) + ordering = ("order", "label") post_save.connect(post_save_cache, sender=DocumentationType) diff --git a/ishtar_common/views_item.py b/ishtar_common/views_item.py index 1e4cc0b9c..48d8e229b 100644 --- a/ishtar_common/views_item.py +++ b/ishtar_common/views_item.py @@ -121,6 +121,8 @@ LIST_FIELDS = { # key: hierarchic depth "development_type": HIERARCHIC_LEVELS, "monitoring_justification": HIERARCHIC_LEVELS, "types": HIERARCHIC_LEVELS, + "documentations": HIERARCHIC_LEVELS, + "excavation_technics": HIERARCHIC_LEVELS, "discovery_method": 0, "discovery_status": 0, "current_status": 0, @@ -150,9 +152,7 @@ LIST_FIELDS = { # key: hierarchic depth "data_type": 0, "origin": 0, "provider": 0, - "excavation_technics": 0, "activity": 0, - "documentations": 0, } HIERARCHIC_FIELDS = list(LIST_FIELDS.keys()) |