From 81f1f97a6ba4d9c5bd903a82c7ffb460a2c4342e Mon Sep 17 00:00:00 2001 From: jedi Date: Wed, 13 Dec 2023 18:33:32 +0100 Subject: [PATCH] stash --- core/inventory/api_v2.py | 10 +++++++++- web/src/store/index.js | 2 +- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/core/inventory/api_v2.py b/core/inventory/api_v2.py index 5f5e5ca..f7306da 100644 --- a/core/inventory/api_v2.py +++ b/core/inventory/api_v2.py @@ -131,7 +131,7 @@ def item(request, event_slug): return Response(status=404) -@api_view(['GET', 'PUT', 'DELETE']) +@api_view(['GET', 'PUT', 'DELETE', 'PATCH']) @permission_classes([IsAuthenticated]) def item_by_id(request, event_slug, id): try: @@ -149,6 +149,14 @@ def item_by_id(request, event_slug, id): validated_data.save() return Response(validated_data.data) return Response(validated_data.errors, status=400) + elif request.method == 'PATCH': + if not request.user.has_event_perm(event, 'change_item'): + return Response(status=403) + validated_data = ItemSerializer(item, data=request.data, partial=True) + if validated_data.is_valid(): + validated_data.save() + return Response(validated_data.data) + return Response(validated_data.errors, status=400) elif request.method == 'DELETE': if not request.user.has_event_perm(event, 'delete_item'): return Response(status=403) diff --git a/web/src/store/index.js b/web/src/store/index.js index da630ef..5312770 100644 --- a/web/src/store/index.js +++ b/web/src/store/index.js @@ -282,7 +282,7 @@ const store = new Vuex.Store({ commit('updateItem', data); }, async markItemReturned({commit, getters}, item) { - await axios.put(`/2/${getters.getEventSlug}/item/${item.uid}/`, {returned: true}); + await axios.patch(`/2/${getters.getEventSlug}/item/${item.uid}/`, {returned: true}); commit('removeItem', item); }, async deleteItem({commit, getters}, item) {