diff --git a/loko/inspections/locale/en/LC_MESSAGES/django.mo b/loko/inspections/locale/en/LC_MESSAGES/django.mo index dfd3154..02ac4aa 100644 Binary files a/loko/inspections/locale/en/LC_MESSAGES/django.mo and b/loko/inspections/locale/en/LC_MESSAGES/django.mo differ diff --git a/loko/inspections/locale/en/LC_MESSAGES/django.po b/loko/inspections/locale/en/LC_MESSAGES/django.po index f9b5e8a..2d0ebb8 100644 --- a/loko/inspections/locale/en/LC_MESSAGES/django.po +++ b/loko/inspections/locale/en/LC_MESSAGES/django.po @@ -1965,6 +1965,11 @@ msgstr "" "Please answer each of the 4 visual checks of the Hot Box repair (Flatness, " "Joints, Cracking, Drainage)." +msgid "" +"Contrôles visuels non encore renseignés (inspection planifiée ou en attente " +"d'évaluation)." +msgstr "Visual checks not yet filled in (scheduled or pending evaluation)." + #~ msgid "Renforcement de l'entretien préventif" #~ msgstr "Reinforcement of preventive maintenance" diff --git a/loko/inspections/locale/fr/LC_MESSAGES/django.mo b/loko/inspections/locale/fr/LC_MESSAGES/django.mo index 8b6f41f..9c33eb7 100644 Binary files a/loko/inspections/locale/fr/LC_MESSAGES/django.mo and b/loko/inspections/locale/fr/LC_MESSAGES/django.mo differ diff --git a/loko/inspections/locale/fr/LC_MESSAGES/django.po b/loko/inspections/locale/fr/LC_MESSAGES/django.po index 8d4f846..3b1c422 100644 --- a/loko/inspections/locale/fr/LC_MESSAGES/django.po +++ b/loko/inspections/locale/fr/LC_MESSAGES/django.po @@ -1973,6 +1973,13 @@ msgstr "" "Veuillez répondre à chacun des 4 contrôles visuels de la réparation Hot Box " "(Planéité, Joints, Fissuration, Évacuation des eaux)." +msgid "" +"Contrôles visuels non encore renseignés (inspection planifiée ou en attente " +"d'évaluation)." +msgstr "" +"Contrôles visuels non encore renseignés (inspection planifiée ou en attente " +"d'évaluation)." + #~ msgid "Renforcement de l'entretien préventif" #~ msgstr "Renforcement de l’entretien préventif" diff --git a/loko/inspections/locale/nl/LC_MESSAGES/django.mo b/loko/inspections/locale/nl/LC_MESSAGES/django.mo index 611b7f3..febaab2 100644 Binary files a/loko/inspections/locale/nl/LC_MESSAGES/django.mo and b/loko/inspections/locale/nl/LC_MESSAGES/django.mo differ diff --git a/loko/inspections/locale/nl/LC_MESSAGES/django.po b/loko/inspections/locale/nl/LC_MESSAGES/django.po index ba155cb..1f3d363 100644 --- a/loko/inspections/locale/nl/LC_MESSAGES/django.po +++ b/loko/inspections/locale/nl/LC_MESSAGES/django.po @@ -1964,6 +1964,13 @@ msgstr "" "Gelieve elk van de 4 visuele controles van de Hot Box-herstelling te " "beantwoorden (Vlakheid, Voegen, Scheurvorming, Afwatering)." +msgid "" +"Contrôles visuels non encore renseignés (inspection planifiée ou en attente " +"d'évaluation)." +msgstr "" +"Visuele controles nog niet ingevuld (geplande inspectie of in afwachting van" +" evaluatie)." + #~ msgid "Renforcement de l'entretien préventif" #~ msgstr "Versterking van preventief onderhoud" diff --git a/loko/inspections/migrations/0013_promote_existing_hotbox_inspections.py b/loko/inspections/migrations/0013_promote_existing_hotbox_inspections.py new file mode 100644 index 0000000..54f9164 --- /dev/null +++ b/loko/inspections/migrations/0013_promote_existing_hotbox_inspections.py @@ -0,0 +1,35 @@ +from django.db import migrations, models + + +def promote_existing_hotbox_inspections(apps, schema_editor): + Inspection = apps.get_model('inspections', 'Inspection') + HotBoxInspection = apps.get_model('inspections', 'HotBoxInspection') + db_alias = schema_editor.connection.alias + + existing_hb_ids = set(HotBoxInspection.objects.using(db_alias).values_list('inspection_ptr_id', flat=True)) + + inspections_to_promote = Inspection.objects.using(db_alias).filter( + models.Q(checked_intervention__sub_type__code='hotbox') | + models.Q(mission_intervention__sub_type__code='hotbox') + ).exclude(id__in=existing_hb_ids) + + for insp in inspections_to_promote: + hb = HotBoxInspection(inspection_ptr=insp) + for f in insp._meta.fields: + setattr(hb, f.attname, getattr(insp, f.attname)) + hb.save_base(raw=True, using=db_alias) + + +def reverse_func(apps, schema_editor): + pass + + +class Migration(migrations.Migration): + + dependencies = [ + ('inspections', '0012_alter_hotboxinspection_water_drainage'), + ] + + operations = [ + migrations.RunPython(promote_existing_hotbox_inspections, reverse_func), + ] diff --git a/loko/inspections/models.py b/loko/inspections/models.py index dafc01a..c085779 100644 --- a/loko/inspections/models.py +++ b/loko/inspections/models.py @@ -598,7 +598,10 @@ class Inspection(models.Model): return self.hotboxinspection if self.is_hotbox_related and self.pk: try: - hb, _ = HotBoxInspection.objects.get_or_create(inspection_ptr=self) + hb = HotBoxInspection(inspection_ptr=self) + for f in self._meta.fields: + setattr(hb, f.attname, getattr(self, f.attname)) + hb.save_base(raw=True) return hb except Exception: pass diff --git a/loko/inspections/templates/inspections/components/asset_details/_hotbox.html b/loko/inspections/templates/inspections/components/asset_details/_hotbox.html index a1cb635..93d9fd3 100644 --- a/loko/inspections/templates/inspections/components/asset_details/_hotbox.html +++ b/loko/inspections/templates/inspections/components/asset_details/_hotbox.html @@ -8,6 +8,12 @@