diff --git a/gracedb/api.py b/gracedb/api.py index 4024315d48f43df03ccdc6a0b63fc05f64ec013a..496d62fd53726a9d507d41cf0e03963035b5f93e 100644 --- a/gracedb/api.py +++ b/gracedb/api.py @@ -817,7 +817,7 @@ class EventSlot(APIView): try: slot = Slot.objects.filter(event=event).filter(name=slotname)[0] - except Slot.DoesNotExist: + except: # Okay, no slot yet. Probably want an error message. # Try looking for files that contain the slot name. return Response("No slot. Search based on slotname not implemented yet.", @@ -859,3 +859,24 @@ class EventSlot(APIView): slot.save() return Response("Slot created.",status=status.HTTP_201_CREATED) + # Delete a slot. + def delete(self, request, graceid, slotname): + try: + event = Event.getByGraceid(graceid) + except Event.DoesNotExist: + # XXX Real error message. + return Response("Event does not exist.", + status=status.HTTP_404_NOT_FOUND) + + # Gotta find the poor devil before we can delete him. + try: + slot = Slot.objects.filter(event=event).filter(name=slotname)[0] + except: + # Okay, no slot yet. Probably want an error message. + # Try looking for files that contain the slot name. + return Response("No such slot.", + status=status.HTTP_404_NOT_FOUND) + + slot.delete() + return Response("Slot deleted.",status=status.HTTP_200_OK) +