Fix edge case with updating document request status

This commit is contained in:
Keannu Bernasol 2024-11-25 12:30:46 +08:00
parent 0415d99968
commit 957272cd07

View file

@ -158,10 +158,10 @@ class DocumentRequestUpdateSerializer(serializers.ModelSerializer):
read_only_fields = ["id", "status"] read_only_fields = ["id", "status"]
def update(self, instance, validated_data): def update(self, instance, validated_data):
if instance.status == "denied": if instance.status == "denied" or instance.status == "approved":
raise serializers.ValidationError( raise serializers.ValidationError(
{ {
"error": "Denied requests cannot be updated. You should instead create a new request and approve it from there" "error": "Already approved/denied requests cannot be updated. You should instead create a new request and approve it from there"
} }
) )
elif validated_data["status"] == instance.status: elif validated_data["status"] == instance.status: