This commit is contained in:
j3d1 2023-12-13 18:33:32 +01:00
parent 125232d1c5
commit 81f1f97a6b
2 changed files with 10 additions and 2 deletions

View file

@ -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)

View file

@ -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) {