camp/content/templatetags/available_content.py

21 lines
453 B
Python
Raw Normal View History

2018-02-21 15:22:33 +00:00
from django import template
from django.urls import reverse
from ..models import Content
register = template.Library()
@register.assignment_tag
def available_content():
sections = []
for type in ['projects', 'events', 'works', 'texts']:
if Content.objects.filter(type__name=type, published=True).exists():
sections.append([
2018-02-21 15:30:42 +00:00
reverse(type),
2018-02-21 15:32:28 +00:00
type.upper()
2018-02-21 15:22:33 +00:00
])
return sections