only show avaiable content

This commit is contained in:
j 2018-02-21 20:52:33 +05:30
parent 57481d4dbe
commit b24f42689b
4 changed files with 27 additions and 6 deletions

View File

@ -46,8 +46,8 @@ urlpatterns = [
url(r'^texts/(?P<shortname>.+)/$', views.texts, name='texts'),
url(r'^events/(?P<shortname>.+)/$', views.events, name='events'),
url(r'^projects/(?P<shortname>.+)/$', views.projects, name='projects'),
url(r'^works/(?P<shortname>.+)/$', views.works, name='works'),
url(r'^works/$', views.works),
url(r'^works/(?P<shortname>.+)/$', views.works, name='work'),
url(r'^works/$', views.works, name='works'),
url(r'^projects/$', views.projects),
url(r'^events/$', views.events),
url(r'^texts/$', views.texts),

View File

@ -1,3 +1,4 @@
{% load available_content%}
<!doctype html>
<html class="no-js" lang="en">
<head>
@ -21,10 +22,10 @@
<ul class="vertical-menu">
<li><a href="/">HOME</a></li>
<li><a href="/about">ABOUT</a></li>
<li><a href="/projects">PROJECTS</a></li>
<li><a href="/events">EVENTS</a></li>
<li><a href="/works">WORKS</a></li>
<li><a href="/texts">TEXTS</a></li>
{% available_content as sections %}
{% for url, title in sections %}
<li><a href="{Purl}}">{{title}}</a></li>
{% endfor %}
<li><a href="/contact">CONTACT</a></li>
</ul>
</div>

View File

View File

@ -0,0 +1,20 @@
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([
reverse('works'),
type.capitalize()
])
return sections