From 86cb5f89abfc350dc6ded6a4c2b3d7c1f6e94fc6 Mon Sep 17 00:00:00 2001
From: Branson Stephens <stephenb@uwm.edu>
Date: Wed, 9 Jan 2013 16:16:51 -0600
Subject: [PATCH] added DELETE method for slots.

---
 gracedb/api.py | 23 ++++++++++++++++++++++-
 1 file changed, 22 insertions(+), 1 deletion(-)

diff --git a/gracedb/api.py b/gracedb/api.py
index 4024315d4..496d62fd5 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)
+
-- 
GitLab