mirror of
https://github.com/lemeow125/DocManagerBackend.git
synced 2025-01-18 17:13:00 +08:00
Fix edge case with updating document request status
This commit is contained in:
parent
0415d99968
commit
957272cd07
1 changed files with 2 additions and 2 deletions
|
@ -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:
|
||||||
|
|
Loading…
Reference in a new issue