Skip to content

Commit ed5c2f4

Browse files
committed
chore(dref): merge migrations
1 parent b40c591 commit ed5c2f4

File tree

4 files changed

+78
-153
lines changed

4 files changed

+78
-153
lines changed

dref/migrations/0084_dref_original_language_and_more.py

Lines changed: 0 additions & 96 deletions
This file was deleted.

dref/migrations/0086_dref_addressed_humanitarian_impacts_ar_and_more.py renamed to dref/migrations/0084_remove_dref_is_published_and_more.py

Lines changed: 76 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,46 @@
1-
# Generated by Django 4.2.19 on 2025-11-05 08:22
1+
# Generated by Django 4.2.19 on 2025-11-05 11:03
22

33
from django.db import migrations, models
44

5+
def update_status(apps, schema_editor):
6+
"""
7+
Update old status to new workflow:
8+
- Not published or IN_PROGRESS → DRAFT
9+
- Published or COMPLETED → APPROVED
10+
Applies to Dref, DrefOperationalUpdate, and DrefFinalReport.
11+
"""
12+
models = [
13+
"Dref",
14+
"DrefOperationalUpdate",
15+
"DrefFinalReport",
16+
]
17+
for model_name in models:
18+
Model = apps.get_model("dref", model_name)
19+
Model.objects.filter(is_published=True).update(status=4) # Published → APPROVED
20+
Model.objects.filter(is_published=False).update(status=1) # Not published → DRAFT
21+
22+
def update_starting_language(apps, schema_editor):
23+
"""
24+
Populate the starting_language field with 'en' for all existing records.
25+
"""
26+
models = [
27+
"Dref",
28+
"DrefOperationalUpdate",
29+
"DrefFinalReport",
30+
]
31+
for model_name in models:
32+
Model = apps.get_model("dref", model_name)
33+
Model.objects.update(starting_language="en")
34+
535

636
class Migration(migrations.Migration):
737

838
dependencies = [
9-
('dref', '0085_remove_dref_is_published_and_more'),
39+
('dref', '0083_dreffinalreport_total_operation_timeframe_imminent'),
1040
]
1141

1242
operations = [
43+
migrations.RunPython(update_status,reverse_code=migrations.RunPython.noop),
1344
migrations.AddField(
1445
model_name='dref',
1546
name='addressed_humanitarian_impacts_ar',
@@ -70,4 +101,47 @@ class Migration(migrations.Migration):
70101
name='hazard_vulnerabilities_and_risks_fr',
71102
field=models.TextField(blank=True, help_text='Explain the underlying vulnerabilities and risks the hazard poses for at-risk communities?', null=True, verbose_name='Hazard Vulnerabilities and Risks'),
72103
),
104+
migrations.AddField(
105+
model_name='dref',
106+
name='starting_language',
107+
field=models.CharField(blank=True, help_text='The language in which this record was first created.', null=True, verbose_name='Starting language'),
108+
),
109+
migrations.AddField(
110+
model_name='dreffinalreport',
111+
name='starting_language',
112+
field=models.CharField(blank=True, help_text='The language in which this record was first created.', null=True, verbose_name='Starting language'),
113+
),
114+
migrations.AddField(
115+
model_name='drefoperationalupdate',
116+
name='starting_language',
117+
field=models.CharField(blank=True, help_text='The language in which this record was first created.', null=True, verbose_name='Starting language'),
118+
),
119+
migrations.AlterField(
120+
model_name='dref',
121+
name='status',
122+
field=models.IntegerField(choices=[(1, 'Draft'), (2, 'Finalizing'), (3, 'Finalized'), (4, 'Approved'), (5, 'Finalizing Failed')], default=1, verbose_name='status'),
123+
),
124+
migrations.AlterField(
125+
model_name='dreffinalreport',
126+
name='status',
127+
field=models.IntegerField(choices=[(1, 'Draft'), (2, 'Finalizing'), (3, 'Finalized'), (4, 'Approved'), (5, 'Finalizing Failed')], default=1, verbose_name='status'),
128+
),
129+
migrations.AlterField(
130+
model_name='drefoperationalupdate',
131+
name='status',
132+
field=models.IntegerField(choices=[(1, 'Draft'), (2, 'Finalizing'), (3, 'Finalized'), (4, 'Approved'), (5, 'Finalizing Failed')], default=1, verbose_name='status'),
133+
),
134+
migrations.RemoveField(
135+
model_name='dref',
136+
name='is_published',
137+
),
138+
migrations.RemoveField(
139+
model_name='dreffinalreport',
140+
name='is_published',
141+
),
142+
migrations.RemoveField(
143+
model_name='drefoperationalupdate',
144+
name='is_published',
145+
),
146+
migrations.RunPython(update_starting_language,reverse_code=migrations.RunPython.noop),
73147
]

dref/migrations/0085_remove_dref_is_published_and_more.py

Lines changed: 0 additions & 55 deletions
This file was deleted.

dref/models.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -272,6 +272,8 @@ class Status(models.IntegerChoices):
272272
"""Finalized: Translation is completed, content is ready for review, and updates to the original language are locked."""
273273
APPROVED = 4, _("Approved")
274274
"""Approved: The content has been reviewed, accepted, and is ready for use."""
275+
FINALIZING_FAILED = 5, _("Finalizing Failed")
276+
"""FINALIZING_FAILED: The content translation process has been Failed."""
275277

276278
created_at = models.DateTimeField(verbose_name=_("created at"), auto_now_add=True)
277279
modified_at = models.DateTimeField(verbose_name=_("modified at"), default=timezone.now, null=True)

0 commit comments

Comments
 (0)