Skip to content
Snippets Groups Projects
Commit 6cbf78bd authored by Branson Stephens's avatar Branson Stephens Committed by Brian Moe
Browse files

added custom template filter for slots

parent 44df0e02
No related branches found
No related tags found
No related merge requests found
......@@ -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.
......
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