diff --git a/src/persistence/api/serializers.py b/src/persistence/api/serializers.py index ff98635..a4c4207 100644 --- a/src/persistence/api/serializers.py +++ b/src/persistence/api/serializers.py @@ -11,13 +11,7 @@ class CompatibleCharactersRequestSerializer(serializers.Serializer): class CharacterSerializer(serializers.ModelSerializer): class Meta: model = Character - fields = ( - "id", - "account", - "fork_compatibility", - "character_sheet_version", - "data", - ) + fields = ("id", "account", "fork_compatibility", "character_sheet_version", "data", "last_updated") read_only_fields = ("id", "last_updated") @@ -25,13 +19,7 @@ class Meta: class UpdateCharacterSerializer(serializers.ModelSerializer): class Meta: model = Character - fields = ( - "id", - "account", - "fork_compatibility", - "character_sheet_version", - "data", - ) + fields = ("id", "account", "fork_compatibility", "character_sheet_version", "data", "last_updated") read_only_fields = ("id", "account", "last_updated") diff --git a/src/persistence/api/views.py b/src/persistence/api/views.py index efccf00..de8a20f 100644 --- a/src/persistence/api/views.py +++ b/src/persistence/api/views.py @@ -79,7 +79,7 @@ class UpdateCharacterView(GenericAPIView): serializer_class = UpdateCharacterSerializer queryset = Character.objects.all() - def patch(self, request, pk): + def update_character(self, request, pk): try: character = Character.objects.get(pk=pk) if character.account != request.user: @@ -99,6 +99,12 @@ def patch(self, request, pk): else: return Response(serializer.errors, status=status.HTTP_400_BAD_REQUEST) + def patch(self, request, pk): + return self.update_character(request, pk) + + def put(self, request, pk): + return self.update_character(request, pk) + class DeleteCharacterView(GenericAPIView): serializer_class = CharacterSerializer