summaryrefslogtreecommitdiff
path: root/archaeological_finds
diff options
context:
space:
mode:
authorÉtienne Loks <etienne.loks@iggdrasil.net>2024-02-29 15:06:43 +0100
committerÉtienne Loks <etienne.loks@iggdrasil.net>2024-04-16 16:43:02 +0200
commit1bb16f58b96cdb1a95611178c42401592cdb3b82 (patch)
tree736c15cdc6f28c2364c592a793e5feb9f13a96eb /archaeological_finds
parent35cdf463830050813ea4e8835eb032ae471c3fda (diff)
downloadIshtar-1bb16f58b96cdb1a95611178c42401592cdb3b82.tar.bz2
Ishtar-1bb16f58b96cdb1a95611178c42401592cdb3b82.zip
🔧 fix default settings for treatment states and treatments types (#5782, #5774)
Diffstat (limited to 'archaeological_finds')
-rw-r--r--archaeological_finds/admin.py9
-rw-r--r--archaeological_finds/fixtures/initial_data-fr.json54
-rw-r--r--archaeological_finds/migrations/0121_fix_bad_treatment_types_states.py56
3 files changed, 95 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)
+ ]