From 957272cd07cc32eea6f5cd94c314a6f246469b7f Mon Sep 17 00:00:00 2001 From: Keannu Bernasol Date: Mon, 25 Nov 2024 12:30:46 +0800 Subject: [PATCH] Fix edge case with updating document request status --- docmanager_backend/document_requests/serializers.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docmanager_backend/document_requests/serializers.py b/docmanager_backend/document_requests/serializers.py index 62f4748..4e45a1a 100644 --- a/docmanager_backend/document_requests/serializers.py +++ b/docmanager_backend/document_requests/serializers.py @@ -158,10 +158,10 @@ class DocumentRequestUpdateSerializer(serializers.ModelSerializer): read_only_fields = ["id", "status"] def update(self, instance, validated_data): - if instance.status == "denied": + if instance.status == "denied" or instance.status == "approved": 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: