summaryrefslogtreecommitdiff
path: root/archaeological_finds/migrations/0141_data_migration_recommanded_treatments.py
diff options
context:
space:
mode:
Diffstat (limited to 'archaeological_finds/migrations/0141_data_migration_recommanded_treatments.py')
-rw-r--r--archaeological_finds/migrations/0141_data_migration_recommanded_treatments.py5
1 files changed, 4 insertions, 1 deletions
diff --git a/archaeological_finds/migrations/0141_data_migration_recommanded_treatments.py b/archaeological_finds/migrations/0141_data_migration_recommanded_treatments.py
index 034c34a4c..9fcc41f6a 100644
--- a/archaeological_finds/migrations/0141_data_migration_recommanded_treatments.py
+++ b/archaeological_finds/migrations/0141_data_migration_recommanded_treatments.py
@@ -25,9 +25,12 @@ def load_data(apps, __):
for find in q.all():
for treatment_type in find.preservation_to_considers.all():
if treatment_type.txt_idx not in reco:
+ slug = treatment_type.txt_idx
+ while RecommendedTreatmentType.objects.filter(txt_idx=slug).count():
+ slug += "1"
reco[treatment_type.txt_idx] = RecommendedTreatmentType.objects.create(
label=treatment_type.label,
- txt_idx=treatment_type.txt_idx,
+ txt_idx=slug,
parent=parent
)
find.recommended_treatments.add(reco[treatment_type.txt_idx])