Skip to content

Commit

Permalink
Treat creates like saves
Browse files Browse the repository at this point in the history
  • Loading branch information
jacobtylerwalls committed Oct 22, 2024
1 parent 03b4790 commit 901a25a
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion arches_lingo/views/api/pythonic_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ def destroy(self, request, *args, **kwargs):
)
return super().destroy(request, *args, **kwargs)

def perform_update(self, serializer):
def validate_tile_data_and_save_resource(self, serializer):
"""Re-raise ValidationError as DRF ValidationError.
In 3.0 (2014), DRF decided to stop full_clean()'ing before save(),
Expand All @@ -76,6 +76,12 @@ def perform_update(self, serializer):
except DjangoValidationError as django_error:
raise ValidationError(detail=django_error) from django_error

def perform_create(self, serializer):
self.validate_tile_data_and_save_resource(serializer)

def perform_update(self, serializer):
self.validate_tile_data_and_save_resource(serializer)


class SchemeDetailView(PythonicModelAPIMixin, RetrieveUpdateDestroyAPIView):
permission_classes = [IsAuthenticated]
Expand Down

0 comments on commit 901a25a

Please sign in to comment.