diff --git a/gracedb/api.py b/gracedb/api.py index 8a440ba97fbcb73b5ff8b6b37b619cb4c3dc2ea7..cb138f868da27b27ddabf01631719d238ba1967e 100644 --- a/gracedb/api.py +++ b/gracedb/api.py @@ -862,7 +862,7 @@ class EventSlot(APIView): # when encoded in the HTTP request body. Hence the 'None' string # below. If somebody intentionally named a file 'None', then # they deserve to get this error message. - if filename=='' or filename=='None' or filename=None: + if filename=='' or filename=='None' or filename==None: return Response("Please submit a filename or upload a file.", status=status.HTTP_400_BAD_REQUEST) # Check for existence of the file. diff --git a/gracedb/templatetags/slot.py b/gracedb/templatetags/slot.py new file mode 100644 index 0000000000000000000000000000000000000000..4ce6c98d7b1c4b5408e1b972b19ef9fb18ca8491 --- /dev/null +++ b/gracedb/templatetags/slot.py @@ -0,0 +1,18 @@ + +from django import template +from django.utils.encoding import force_unicode +from django.utils.safestring import mark_safe +from ..models import Slot, EventLog +register = template.Library() + +@register.filter("slot") +def slot(event,slotname): + if event is None: + return mark_safe("") + try: + slot = Slot.objects.filter(event=event).filter(name=slotname)[0] + out = slot.value + except: + return mark_safe("Object not found.") + return mark_safe(out) +