diff --git a/hypha/apply/api/v1/determination/views.py b/hypha/apply/api/v1/determination/views.py index 2169989105cf06fe7a1e480e55cb8c054813c924..ee4ffffcca542f36c33a62228304f77f7653767d 100644 --- a/hypha/apply/api/v1/determination/views.py +++ b/hypha/apply/api/v1/determination/views.py @@ -1,3 +1,4 @@ +from django import forms from django.conf import settings from django.db import transaction from django.shortcuts import get_object_or_404 @@ -120,8 +121,14 @@ class SubmissionDeterminationViewSet( outcome_choices = outcome_choices_for_phase( submission, self.request.user ) - # Outcome field choices need to be set according to the phase. - form_fields[field_block.id].choices = outcome_choices + if self.action == 'update': + # Outcome can not be edited after being set once, so we do not + # need to render this field. + # form_fields.pop(field_block.id) + form_fields[field_block.id].widget = forms.TextInput(attrs={'readonly': 'readonly'}) + else: + # 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']) diff --git a/hypha/apply/api/v1/stream_serializers.py b/hypha/apply/api/v1/stream_serializers.py index 69e99b95395c6079f66b4a04b5648421e9915308..a33383b1919bf17dd58efdb42c20a20d2a8b7061 100644 --- a/hypha/apply/api/v1/stream_serializers.py +++ b/hypha/apply/api/v1/stream_serializers.py @@ -110,6 +110,10 @@ class WagtailSerializer: if attrs.get('required') and 'default' in attrs: del attrs['required'] + # avoid "May not set both `read_only` and `required`" + if form_field.widget.attrs.get('readonly', False) == 'readonly': + attrs['read_only'] = True + del attrs['required'] return attrs def get_serializer_field_class(self, field):