@@ -359,7 +359,7 @@ def get_objects_by_appeal_code(self, appeal_code):
359359        drefs  =  (
360360            Dref .objects .filter (appeal_code = appeal_code )
361361            .prefetch_related ("planned_interventions" , "needs_identified" , "national_society_actions" , "users" )
362-             .order_by ("- created_at" )
362+             .order_by ("created_at" )
363363            .distinct ()
364364        )
365365        drefs  =  filter_dref_queryset_by_user_access (user , drefs )
@@ -370,7 +370,7 @@ def get_objects_by_appeal_code(self, appeal_code):
370370        operational_updates  =  (
371371            DrefOperationalUpdate .objects .filter (appeal_code = appeal_code )
372372            .prefetch_related ("planned_interventions" , "needs_identified" , "national_society_actions" , "users" )
373-             .order_by ("- created_at" )
373+             .order_by ("created_at" )
374374            .distinct ()
375375        )
376376        operational_updates  =  filter_dref_queryset_by_user_access (user , operational_updates )
@@ -380,7 +380,7 @@ def get_objects_by_appeal_code(self, appeal_code):
380380        final_reports  =  (
381381            DrefFinalReport .objects .filter (appeal_code = appeal_code )
382382            .prefetch_related ("planned_interventions" , "needs_identified" , "national_society_actions" , "users" )
383-             .order_by ("- created_at" )
383+             .order_by ("created_at" )
384384            .distinct ()
385385        )
386386        final_reports  =  filter_dref_queryset_by_user_access (user , final_reports )
@@ -399,14 +399,16 @@ def retrieve(self, request, *args, **kwargs):
399399
400400        serialized_data  =  []
401401        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" ]
403404        for  instance  in  instances :
404405            if  isinstance (instance , Dref ):
405406                serializer  =  Dref3Serializer (instance , context = {"stage" : "Application" , "allocation" : a [0 ]})
406407            elif  isinstance (instance , DrefOperationalUpdate ):
407408                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 
410412                else :
411413                    allocation  =  "No allocation" 
412414                serializer  =  DrefOperationalUpdate3Serializer (
0 commit comments