From 511f2c131efa423270bfdabf1ba91c50d61609fe Mon Sep 17 00:00:00 2001 From: sks444 <krishnasingh.ss30@gmail.com> Date: Wed, 30 Sep 2020 12:48:17 +0530 Subject: [PATCH] Change determination choice field outcome based on phase --- hypha/apply/api/v1/determination/views.py | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/hypha/apply/api/v1/determination/views.py b/hypha/apply/api/v1/determination/views.py index 54f8cf1fb..216998910 100644 --- a/hypha/apply/api/v1/determination/views.py +++ b/hypha/apply/api/v1/determination/views.py @@ -111,15 +111,9 @@ class SubmissionDeterminationViewSet( ) return Response(ser.data) - @action(detail=False, methods=['get']) - def fields(self, request, *args, **kwargs): - """ - List details of all the form fields that were created by admin for adding determinations. - - These field details will be used in frontend to render the determination form. - """ + def get_form_fields(self): + form_fields = super(SubmissionDeterminationViewSet, self).get_form_fields() submission = self.get_submission_object() - form_fields = self.get_form_fields() field_blocks = self.get_defined_fields() for field_block in field_blocks: if isinstance(field_block.block, DeterminationBlock): @@ -128,6 +122,16 @@ class SubmissionDeterminationViewSet( ) # Outcome field choices need to be set according to the phase. form_fields[field_block.id].choices = outcome_choices + return form_fields + + @action(detail=False, methods=['get']) + def fields(self, request, *args, **kwargs): + """ + List details of all the form fields that were created by admin for adding determinations. + + These field details will be used in frontend to render the determination form. + """ + form_fields = self.get_form_fields() fields = FieldSerializer(form_fields.items(), many=True) return Response(fields.data) -- GitLab