@@ -359,7 +359,7 @@ def get_objects_by_appeal_code(self, appeal_code):
359
359
drefs = (
360
360
Dref .objects .filter (appeal_code = appeal_code )
361
361
.prefetch_related ("planned_interventions" , "needs_identified" , "national_society_actions" , "users" )
362
- .order_by ("- created_at" )
362
+ .order_by ("created_at" )
363
363
.distinct ()
364
364
)
365
365
drefs = filter_dref_queryset_by_user_access (user , drefs )
@@ -370,7 +370,7 @@ def get_objects_by_appeal_code(self, appeal_code):
370
370
operational_updates = (
371
371
DrefOperationalUpdate .objects .filter (appeal_code = appeal_code )
372
372
.prefetch_related ("planned_interventions" , "needs_identified" , "national_society_actions" , "users" )
373
- .order_by ("- created_at" )
373
+ .order_by ("created_at" )
374
374
.distinct ()
375
375
)
376
376
operational_updates = filter_dref_queryset_by_user_access (user , operational_updates )
@@ -380,7 +380,7 @@ def get_objects_by_appeal_code(self, appeal_code):
380
380
final_reports = (
381
381
DrefFinalReport .objects .filter (appeal_code = appeal_code )
382
382
.prefetch_related ("planned_interventions" , "needs_identified" , "national_society_actions" , "users" )
383
- .order_by ("- created_at" )
383
+ .order_by ("created_at" )
384
384
.distinct ()
385
385
)
386
386
final_reports = filter_dref_queryset_by_user_access (user , final_reports )
@@ -399,14 +399,16 @@ def retrieve(self, request, *args, **kwargs):
399
399
400
400
serialized_data = []
401
401
ops_update_count = 0
402
- a = ["First" , "Second" , "Third" , "Fourth" , "Fifth" , "Sixth" , "Seventh" , "Eighth" , "Nineth" , "Tenth" ]
402
+ allocation_count = 1 # Dref Application is always the first allocation
403
+ a = ["First" , "Second" , "Third" , "Fourth" , "Fifth" , "Sixth" , "Seventh" , "Eighth" , "Ninth" , "Tenth" ]
403
404
for instance in instances :
404
405
if isinstance (instance , Dref ):
405
406
serializer = Dref3Serializer (instance , context = {"stage" : "Application" , "allocation" : a [0 ]})
406
407
elif isinstance (instance , DrefOperationalUpdate ):
407
408
ops_update_count += 1
408
- if instance .additional_allocation and len (a ) > ops_update_count :
409
- allocation = a [ops_update_count ]
409
+ if instance .additional_allocation and len (a ) > allocation_count :
410
+ allocation = a [allocation_count ]
411
+ allocation_count += 1
410
412
else :
411
413
allocation = "No allocation"
412
414
serializer = DrefOperationalUpdate3Serializer (
0 commit comments