Skip to content

Commit

Permalink
Fix ValueConflictValidator
Browse files Browse the repository at this point in the history
  • Loading branch information
jochenklar committed Dec 9, 2023
1 parent 4a3b094 commit fdc796d
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions rdmo/projects/validators.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from datetime import timedelta

from django.conf import settings
from django.core.exceptions import ObjectDoesNotExist
from django.core.exceptions import MultipleObjectsReturned, ObjectDoesNotExist
from django.utils.dateparse import parse_datetime
from django.utils.translation import gettext_lazy as _

Expand Down Expand Up @@ -35,13 +35,16 @@ def __call__(self, data, serializer):
set_index=data.get('set_index'),
collection_index=data.get('collection_index')
)
raise serializers.ValidationError({
'conflict': [_('An existing value for this attribute/set_prefix/set_index/collection_index'
' was found.')]
})
except ObjectDoesNotExist:
return
except MultipleObjectsReturned:
pass

raise serializers.ValidationError({
'conflict': [_('An existing value for this attribute/set_prefix/set_index/collection_index'
' was found.')]
})

class ValueQuotaValidator:

requires_context = True
Expand Down

0 comments on commit fdc796d

Please sign in to comment.