camp/content/templatetags/available_content.py

21 lines
453 B
Python
Raw Normal View History

2018-02-21 20:52:33 +05:30
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 21:00:42 +05:30
reverse(type),
2018-02-21 21:02:28 +05:30
type.upper()
2018-02-21 20:52:33 +05:30
])
return sections