@@ -264,8 +264,14 @@ class DisasterCategory(models.IntegerChoices):
264
264
RED = 2 , _ ("Red" )
265
265
266
266
class Status (models .IntegerChoices ):
267
- IN_PROGRESS = 0 , _ ("In Progress" )
268
- COMPLETED = 1 , _ ("Completed" )
267
+ DRAFT = 1 , _ ("Draft" )
268
+ """Draft: Initial stage content is being created and is not ready for review."""
269
+ FINALIZING = 2 , _ ("Finalizing" )
270
+ """Finalizing: Content is in the translation process from the original language into English."""
271
+ FINALIZED = 3 , _ ("Finalized" )
272
+ """Finalized: Translation is completed, content is ready for review, and updates to the original language are locked."""
273
+ APPROVED = 4 , _ ("Approved" )
274
+ """Approved: The content has been reviewed, accepted, and is ready for use."""
269
275
270
276
created_at = models .DateTimeField (verbose_name = _ ("created at" ), auto_now_add = True )
271
277
modified_at = models .DateTimeField (verbose_name = _ ("modified at" ), default = timezone .now , null = True )
@@ -329,7 +335,13 @@ class Status(models.IntegerChoices):
329
335
verbose_name = _ ("If available please upload additional support documentation for targeting strategy" ),
330
336
related_name = "dref_targeting_strategy_support_file" ,
331
337
)
332
- status = models .IntegerField (choices = Status .choices , verbose_name = _ ("status" ), null = True , blank = True )
338
+ status = models .IntegerField (choices = Status .choices , verbose_name = _ ("status" ), default = Status .DRAFT )
339
+ original_language = models .CharField (
340
+ blank = True ,
341
+ null = True ,
342
+ verbose_name = _ ("Original language" ),
343
+ help_text = "The language in which this record was first created." ,
344
+ ) # NOTE: This field is set at creation with the active language.
333
345
num_assisted = models .IntegerField (verbose_name = _ ("number of assisted" ), blank = True , null = True )
334
346
num_affected = models .IntegerField (verbose_name = _ ("number of affected" ), blank = True , null = True )
335
347
estimated_number_of_affected_male = models .IntegerField (
@@ -645,10 +657,6 @@ class Status(models.IntegerChoices):
645
657
verbose_name = _ ("cover image" ),
646
658
related_name = "cover_image_dref" ,
647
659
)
648
- is_published = models .BooleanField (
649
- default = False ,
650
- verbose_name = _ ("Is published" ),
651
- )
652
660
is_final_report_created = models .BooleanField (
653
661
default = False ,
654
662
verbose_name = _ ("Is final report created" ),
@@ -748,8 +756,6 @@ def save(self, *args, **kwargs):
748
756
self .budget_file_preview .save (filename , thumb_data , save = False )
749
757
else :
750
758
raise ValidationError ({"budget_file" : "Sorry cannot generate preview for empty pdf" })
751
-
752
- self .status = Dref .Status .COMPLETED if self .is_published else Dref .Status .IN_PROGRESS
753
759
self .__budget_file_id = self .budget_file_id
754
760
super ().save (* args , ** kwargs )
755
761
@@ -859,7 +865,13 @@ class DrefOperationalUpdate(models.Model):
859
865
disaster_category = models .IntegerField (
860
866
choices = Dref .DisasterCategory .choices , verbose_name = _ ("disaster category" ), null = True , blank = True
861
867
)
862
- status = models .IntegerField (choices = Dref .Status .choices , verbose_name = _ ("status" ), null = True , blank = True )
868
+ status = models .IntegerField (choices = Dref .Status .choices , verbose_name = _ ("status" ), default = Dref .Status .DRAFT )
869
+ original_language = models .CharField (
870
+ blank = True ,
871
+ null = True ,
872
+ verbose_name = _ ("Original language" ),
873
+ help_text = "The language in which this record was first created." ,
874
+ ) # NOTE: This field is set at creation with the active language.
863
875
number_of_people_targeted = models .IntegerField (verbose_name = _ ("Number of people targeted" ), blank = True , null = True )
864
876
number_of_people_affected = models .IntegerField (verbose_name = _ ("number of people affected" ), blank = True , null = True )
865
877
estimated_number_of_affected_male = models .IntegerField (
@@ -1094,10 +1106,6 @@ class DrefOperationalUpdate(models.Model):
1094
1106
null = True ,
1095
1107
)
1096
1108
planned_interventions = models .ManyToManyField (PlannedIntervention , verbose_name = _ ("planned intervention" ), blank = True )
1097
- is_published = models .BooleanField (
1098
- default = False ,
1099
- verbose_name = _ ("Is published" ),
1100
- )
1101
1109
country = models .ForeignKey (
1102
1110
Country ,
1103
1111
verbose_name = _ ("country" ),
@@ -1232,7 +1240,6 @@ def save(self, *args, **kwargs):
1232
1240
raise ValidationError ({"budget_file" : "Sorry cannot generate preview for empty pdf" })
1233
1241
1234
1242
self .__budget_file_id = self .budget_file_id
1235
- self .status = Dref .Status .COMPLETED if self .is_published else Dref .Status .IN_PROGRESS
1236
1243
super ().save (* args , ** kwargs )
1237
1244
1238
1245
@staticmethod
@@ -1297,7 +1304,13 @@ class DrefFinalReport(models.Model):
1297
1304
disaster_category = models .IntegerField (
1298
1305
choices = Dref .DisasterCategory .choices , verbose_name = _ ("disaster category" ), null = True , blank = True
1299
1306
)
1300
- status = models .IntegerField (choices = Dref .Status .choices , verbose_name = _ ("status" ), null = True , blank = True )
1307
+ status = models .IntegerField (choices = Dref .Status .choices , verbose_name = _ ("status" ), default = Dref .Status .DRAFT )
1308
+ original_language = models .CharField (
1309
+ blank = True ,
1310
+ null = True ,
1311
+ verbose_name = _ ("Original language" ),
1312
+ help_text = "The language in which this record was first created." ,
1313
+ ) # NOTE: This field is set at creation with the active language.
1301
1314
number_of_people_targeted = models .IntegerField (verbose_name = _ ("Number of people targeted" ), blank = True , null = True )
1302
1315
number_of_people_affected = models .IntegerField (verbose_name = _ ("number of people affected" ), blank = True , null = True )
1303
1316
estimated_number_of_affected_male = models .IntegerField (
@@ -1481,7 +1494,6 @@ class DrefFinalReport(models.Model):
1481
1494
verbose_name = _ ("Additional National Societies Actions" ), null = True , blank = True
1482
1495
)
1483
1496
planned_interventions = models .ManyToManyField (PlannedIntervention , verbose_name = _ ("planned intervention" ), blank = True )
1484
- is_published = models .BooleanField (verbose_name = _ ("Is Published" ), default = False )
1485
1497
country = models .ForeignKey (
1486
1498
Country ,
1487
1499
verbose_name = _ ("country" ),
@@ -1651,12 +1663,11 @@ def save(self, *args, **kwargs):
1651
1663
else :
1652
1664
raise ValidationError ({"financial_report" : "Sorry cannot generate preview for empty pdf" })
1653
1665
1654
- self .status = Dref .Status .COMPLETED if self .is_published else Dref .Status .IN_PROGRESS
1655
1666
self .__financial_report_id = self .financial_report_id
1656
1667
super ().save (* args , ** kwargs )
1657
1668
1658
1669
@staticmethod
1659
- def get_for (user , is_published = False ):
1670
+ def get_for (user , status = None ):
1660
1671
from dref .utils import get_dref_users
1661
1672
1662
1673
# get the user in dref
@@ -1675,6 +1686,6 @@ def get_for(user, is_published=False):
1675
1686
final_report_created_by = DrefFinalReport .objects .filter (created_by = user ).distinct ()
1676
1687
union_query = final_report_users .union (final_report_created_by )
1677
1688
queryset = DrefFinalReport .objects .filter (id__in = union_query .values ("id" )).distinct ()
1678
- if is_published :
1679
- return queryset .filter (is_published = True )
1689
+ if status == Dref . Status . APPROVED :
1690
+ return queryset .filter (status = Dref . Status . APPROVED )
1680
1691
return queryset
0 commit comments