Add the missing navbars to the Jinja2 version of the layout

This commit is contained in:
Danielle McLean 2018-06-12 10:47:53 +10:00
parent e94a856a08
commit f0678c3379
Signed by: 00dani
GPG key ID: 8EB789DDF3ABD240
2 changed files with 43 additions and 4 deletions

View file

@ -1,19 +1,23 @@
from django.contrib.staticfiles.storage import staticfiles_storage from django.contrib.staticfiles.storage import staticfiles_storage
from django.urls import reverse from django.urls import reverse
from jinja2 import Environment from jinja2 import Environment
from compressor.contrib.jinja2ext import CompressorExtension
from compressor.contrib.jinja2ext import CompressorExtension
from django_activeurl.ext.django_jinja import ActiveUrl
from entries.kinds import all as entry_kinds
from .utils import load_package_json from .utils import load_package_json
def environment(**options): def environment(**options):
env = Environment( env = Environment(
extensions=[CompressorExtension], extensions=[ActiveUrl, CompressorExtension],
trim_blocks=True, trim_blocks=True,
lstrip_blocks=True, lstrip_blocks=True,
**options **options
) )
env.globals.update({ env.globals.update({
'entry_kinds': entry_kinds,
'package': load_package_json(), 'package': load_package_json(),
'static': staticfiles_storage.url, 'static': staticfiles_storage.url,
'url': reverse, 'url': reverse,

View file

@ -31,8 +31,43 @@
<span class="navbar-toggler-icon"></span> <span class="navbar-toggler-icon"></span>
</button> </button>
<div class="collapse navbar-collapse" id="navbar"> {% activeurl %}<div class="collapse navbar-collapse" id="navbar">
</div> <ul class="navbar-nav">
{% for kind in entry_kinds %}
<li class="nav-item">
<a class="nav-link" href="{{ kind.index }}">
<i class="{{ kind.icon }} fa-fw" aria-hidden="true"></i>
{{ kind.plural }}
</a>
</li>
{% endfor %}
</ul>
<ul class="navbar-nav">
{% if request.user.is_authenticated %}
<li class="nav-item">
<a class="nav-link" href="{{ url('admin:index') }}">
<i class="fas fa-cog fa-fw" aria-hidden="true"></i>
admin
</a>
</li>
<li class="nav-item">
<a class="nav-link" href="{{ url('lemonauth:logout') }}">
<i class="fas fa-sign-out-alt fa-fw" aria-hidden="true"></i>
log out
</a>
</li>
{% else %}
<li class="nav-item">
<a class="nav-link" href="{{ url('lemonauth:login') }}">
<i class="fas fa-sign-in-alt fa-fw" aria-hidden="true"></i>
log in
</a>
</li>
{% endif %}
</ul>
</div>{% endactiveurl %}
</nav> </nav>
</header> </header>