diff options
author | Étienne Loks <etienne.loks@iggdrasil.net> | 2024-02-29 15:06:43 +0100 |
---|---|---|
committer | Étienne Loks <etienne.loks@iggdrasil.net> | 2024-02-29 15:06:43 +0100 |
commit | 9c8a347be272696003dc19e5128ac29fc78266a2 (patch) | |
tree | e1f675fcb300e9715cdf6835831ca7415774b071 | |
parent | f3fe6f7fdd5e815283f22c9f06afd0c5a6400576 (diff) | |
download | Ishtar-9c8a347be272696003dc19e5128ac29fc78266a2.tar.bz2 Ishtar-9c8a347be272696003dc19e5128ac29fc78266a2.zip |
🔧 fix default settings for treatment states and treatments types (#5782, #5774)
-rw-r--r-- | archaeological_finds/admin.py | 9 | ||||
-rw-r--r-- | archaeological_finds/fixtures/initial_data-fr.json | 54 | ||||
-rw-r--r-- | archaeological_finds/migrations/0121_fix_bad_treatment_types_states.py | 56 | ||||
-rw-r--r-- | changelog/en/changelog_2022-06-15.md | 1 | ||||
-rw-r--r-- | changelog/fr/changelog_2023-01-25.md | 1 |
5 files changed, 97 insertions, 24 deletions
diff --git a/archaeological_finds/admin.py b/archaeological_finds/admin.py index 934089a7a..b089e0713 100644 --- a/archaeological_finds/admin.py +++ b/archaeological_finds/admin.py @@ -204,10 +204,11 @@ class TreatmentTypeAdmin(GeneralTypeAdmin): "change_current_location", "restore_reference_location", ] - - def get_list_display(self, request): - list_display = super(TreatmentTypeAdmin, self).get_list_display(request) - return list_display[:-1] + ['order'] + [list_display[-1]] + LIST_DISPLAY = [ + "label", "txt_idx", "available", "order", "create_new_find", + "upstream_is_many", "downstream_is_many", "change_reference_location", + "change_current_location", "restore_reference_location", "virtual", "destructive" + ] admin_site.register(models.TreatmentType, TreatmentTypeAdmin) diff --git a/archaeological_finds/fixtures/initial_data-fr.json b/archaeological_finds/fixtures/initial_data-fr.json index 338e2849f..91c8c0c91 100644 --- a/archaeological_finds/fixtures/initial_data-fr.json +++ b/archaeological_finds/fixtures/initial_data-fr.json @@ -608,7 +608,9 @@ "parent": null, "virtual": false, "upstream_is_many": false, - "downstream_is_many": false + "downstream_is_many": false, + "change_reference_location": true, + "change_current_location": true } }, { @@ -629,7 +631,7 @@ "model": "archaeological_finds.treatmenttype", "fields": { "label": "Radiographie", - "txt_idx": "radioX", + "txt_idx": "x-ray", "comment": "", "available": true, "order": 10, @@ -652,14 +654,17 @@ "parent": null, "virtual": false, "upstream_is_many": false, - "downstream_is_many": false + "downstream_is_many": false, + "change_reference_location": true, + "change_current_location": true, + "create_new_find": false } }, { "model": "archaeological_finds.treatmenttype", "fields": { "label": "Groupement virtuel", - "txt_idx": "virtual_group", + "txt_idx": "virtual-group", "comment": "Regroupement d'un ensemble de mobilier. Exemple : ensemble des outils provenant d'une fouille, mobilier datant d'un site, tessonier virtuel, etc.", "available": true, "order": 10, @@ -673,14 +678,15 @@ "model": "archaeological_finds.treatmenttype", "fields": { "label": "Groupement", - "txt_idx": "physical_grouping", + "txt_idx": "physical-grouping", "comment": "R\u00e9union de plusieurs objets ou lots mobiliers en un seul. Ce type de traitement peut impliquer ou non un reconditionnement.\r\n\r\nExemple : Remontage d'une c\u00e9ramique \u00e0 partir de tessons d\u00e9j\u00e0 pr\u00e9sents dans un contenant (pas de reconditionnement), regroupement d'une partie de la faune (os) d'une op\u00e9ration et cr\u00e9ation d'une nouvelle caisse dans ce but (reconditionnement \u00e0 faire).", "available": true, "order": 10, "parent": null, "virtual": false, "upstream_is_many": true, - "downstream_is_many": false + "downstream_is_many": false, + "create_new_find": true } }, { @@ -694,7 +700,10 @@ "parent": null, "virtual": false, "upstream_is_many": false, - "downstream_is_many": true + "downstream_is_many": true, + "change_reference_location": false, + "change_current_location": false, + "create_new_find": true } }, { @@ -736,7 +745,8 @@ "parent": null, "virtual": false, "upstream_is_many": true, - "downstream_is_many": false + "downstream_is_many": false, + "create_new_find": true } }, { @@ -757,7 +767,7 @@ "model": "archaeological_finds.treatmenttype", "fields": { "label": "Consultation sur place", - "txt_idx": "local_consultation", + "txt_idx": "local-consultation", "comment": "", "available": true, "order": 10, @@ -799,12 +809,12 @@ "model": "archaeological_finds.treatmenttype", "fields": { "label": "Radiographie argentique", - "txt_idx": "regular_x_ray", + "txt_idx": "regular-x-ray", "comment": "Radiographie (rayon X) qui produit un ou des films radio.", "available": true, "order": 10, "parent": [ - "radioX" + "x-ray" ], "virtual": false, "upstream_is_many": false, @@ -831,12 +841,12 @@ "model": "archaeological_finds.treatmenttype", "fields": { "label": "Radiographie num\u00e9rique", - "txt_idx": "digital_x_ray", + "txt_idx": "digital-x-ray", "comment": "Radiographie (rayon X) qui produit un ou des fichiers num\u00e9riques.", "available": true, "order": 10, "parent": [ - "radioX" + "x-ray" ], "virtual": false, "upstream_is_many": false, @@ -861,7 +871,7 @@ "model": "archaeological_finds.treatmenttype", "fields": { "label": "Photographie argentique", - "txt_idx": "regular_photography", + "txt_idx": "regular-photography", "comment": "Photographie produisant un film (positif ou n\u00e9gatif).", "available": true, "order": 10, @@ -877,7 +887,7 @@ "model": "archaeological_finds.treatmenttype", "fields": { "label": "Photographie num\u00e9rique", - "txt_idx": "digital_photography", + "txt_idx": "digital-photography", "comment": "Prise de vue \u00e0 l'aide d'un appareil photo num\u00e9rique.", "available": true, "order": 10, @@ -902,7 +912,9 @@ "destructive": false, "create_new_find": false, "upstream_is_many": false, - "downstream_is_many": false + "downstream_is_many": false, + "change_reference_location": false, + "change_current_location": true } }, { @@ -918,7 +930,8 @@ "destructive": false, "create_new_find": false, "upstream_is_many": false, - "downstream_is_many": false + "downstream_is_many": false, + "restore_reference_location": true } }, { @@ -934,7 +947,7 @@ "model": "archaeological_finds.treatmentstate", "fields": { "label": "En cours", - "txt_idx": "in_progress", + "txt_idx": "in-progress", "comment": "", "available": true } @@ -945,7 +958,8 @@ "label": "Achev\u00e9", "txt_idx": "completed", "comment": "", - "available": true + "available": true, + "executed": true } }, { @@ -961,7 +975,7 @@ "model": "archaeological_finds.treatmentstate", "fields": { "label": "\u00c0 confirmer", - "txt_idx": "to_be_confirmed", + "txt_idx": "to-be-confirmed", "comment": "", "available": true } diff --git a/archaeological_finds/migrations/0121_fix_bad_treatment_types_states.py b/archaeological_finds/migrations/0121_fix_bad_treatment_types_states.py new file mode 100644 index 000000000..0f5db59f5 --- /dev/null +++ b/archaeological_finds/migrations/0121_fix_bad_treatment_types_states.py @@ -0,0 +1,56 @@ +# Generated by Django 2.2.24 on 2024-02-29 12:08 + +from django.db import migrations + + +def fix_typo(apps, __): + TreatmentState = apps.get_model("archaeological_finds", "treatmentstate") + q = TreatmentState.objects.filter(txt_idx='completed') + if q.count(): + completed = q.all()[0] + completed.executed = True + completed.save() + else: + TreatmentState.objects.create(txt_idx='completed', available=True, label="Achevé") + for t in TreatmentState.objects.all(): + if "_" in t.txt_idx: + t.txt_idx = t.txt_idx.replace("_", "-") + t.save() + TreatmentType = apps.get_model("archaeological_finds", "treatmenttype") + tt = [ + # (slug, condition, fix) + ("packaging", {"change_current_location": False}, + {"change_current_location": True, "change_reference_location": True}), + ("moving", {"change_current_location": False}, + {"change_current_location": True, "change_reference_location": True}), + ("physical_grouping", {"create_new_find": False}, {"create_new_find": True}), + ("split", {"create_new_find": False}, {"create_new_find": True}), + ("reassembly", {"create_new_find": False}, {"create_new_find": True}), + ("loan", {"change_current_location": False}, {"change_current_location": True}), + ("loan-return", {"restore_reference_location": False}, {"restore_reference_location": True}), + ] + for slug, condition, fix in tt: + q = TreatmentType.objects.filter(txt_idx=slug).filter(**condition) + if not q.count(): + continue + t = q.all()[0] + for attr, value in fix.items(): + setattr(t, attr, value) + t.save() + for t in TreatmentType.objects.all(): + if t.txt_idx == "radioX": + t.txt_idx = "x-ray" + t.save() + if "_" in t.txt_idx: + t.txt_idx = t.txt_idx.replace("_", "-") + t.save() + + +class Migration(migrations.Migration): + dependencies = [ + ('archaeological_finds', '0120_museum_assigned_institution'), + ] + + operations = [ + migrations.RunPython(fix_typo) + ] diff --git a/changelog/en/changelog_2022-06-15.md b/changelog/en/changelog_2022-06-15.md index 29d371a53..c844d7740 100644 --- a/changelog/en/changelog_2022-06-15.md +++ b/changelog/en/changelog_2022-06-15.md @@ -61,6 +61,7 @@ v4.0.XX - 2099-12-31 - improve values format - context record relations graph - fix '\n' string (#5500) - fix consultation permissions on the contents of a container (#5767) +- fix default settings for treatment states and treatments types (#5782, #5774) v4.0.72 - 2024-02-05 diff --git a/changelog/fr/changelog_2023-01-25.md b/changelog/fr/changelog_2023-01-25.md index 1137e6d81..f86aeb4e4 100644 --- a/changelog/fr/changelog_2023-01-25.md +++ b/changelog/fr/changelog_2023-01-25.md @@ -62,6 +62,7 @@ v4.0.XX - 2099-12-31 - amélioration du formatage des valeurs - graphe de relations entre unité d'enregistrements - correction du caractère '\n' (#5500) - correction des droits de consultation sur le contenu d'un contenant (#5767) +- correction de paramétrage par défaut des types de traitements et des états de traitements (#5782, #5774) v4.0.72 - 2024-02-05 -------------------- |