Skip to content
Snippets Groups Projects
Commit 08876dfd authored by Branson Stephens's avatar Branson Stephens
Browse files

added custom template filter for slots

parent 19e4ccb6
No related branches found
No related tags found
No related merge requests found
...@@ -917,7 +917,7 @@ class EventSlot(APIView): ...@@ -917,7 +917,7 @@ class EventSlot(APIView):
# when encoded in the HTTP request body. Hence the 'None' string # when encoded in the HTTP request body. Hence the 'None' string
# below. If somebody intentionally named a file 'None', then # below. If somebody intentionally named a file 'None', then
# they deserve to get this error message. # 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.", return Response("Please submit a filename or upload a file.",
status=status.HTTP_400_BAD_REQUEST) status=status.HTTP_400_BAD_REQUEST)
# Check for existence of the file. # Check for existence of the file.
......
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)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment