Skip to content

Serializers

hypha.apply.api.v1.determination.serializers

SubmissionDeterminationSerializer

Bases: ModelSerializer

Meta

model class-attribute instance-attribute
model = Determination
fields class-attribute instance-attribute
fields = ['id', 'is_draft']
extra_kwargs class-attribute instance-attribute
extra_kwargs = {'is_draft': {'required': False}}

validate

validate(data)
Source code in hypha/apply/api/v1/determination/serializers.py
def validate(self, data):
    validated_data = super().validate(data)
    validated_data["form_data"] = dict(validated_data.items())
    return validated_data

update

update(instance, validated_data)
Source code in hypha/apply/api/v1/determination/serializers.py
def update(self, instance, validated_data):
    instance = super().update(instance, validated_data)
    instance.send_notice = (
        self.validated_data[instance.send_notice_field.id]
        if instance.send_notice_field
        else True
    )
    message = self.validated_data[instance.message_field.id]
    instance.message = "" if message is None else message
    try:
        instance.outcome = int(self.validated_data[instance.determination_field.id])
        # Need to catch KeyError as outcome field would not exist in case of edit.
    except KeyError:
        pass
    instance.is_draft = self.validated_data.get("is_draft", False)
    instance.form_data = self.validated_data["form_data"]
    instance.save()
    return instance