Browse Source

feat(custom_link): choose position in the navbar for links

fix-autocapture^2
Cyprien de Cerval 3 years ago
parent
commit
854accfab0
  1. 2
      docker/settings_local.template.py
  2. 2
      re2o/settings_local.example.py
  3. 5
      re2o/templatetags/custom_link.py
  4. 5
      templates/nav.html

2
docker/settings_local.template.py

@ -100,5 +100,5 @@ OPTIONNAL_APPS_RE2O = ()
# Some Django apps you want to add in you local project
OPTIONNAL_APPS = OPTIONNAL_APPS_RE2O + ()
# Some optinnal link for the navbar in a tuple (link,icon class,text)
# Some optinnal link for the navbar in a tuple (link,icon class,text,position (left or right))
NAVBAR_LINKS = ()

2
re2o/settings_local.example.py

@ -118,7 +118,7 @@ OPTIONNAL_APPS_RE2O = ()
# Some Django apps you want to add in you local project
OPTIONNAL_APPS = OPTIONNAL_APPS_RE2O + ()
# Some optinnal link for the navbar in a tuple (link,icon class,text)
# Some optinnal link for the navbar in a tuple (link,icon class,text,position (left or right))
NAVBAR_LINKS= ()
# Add statiffiles dir that were installed using system packaging

5
re2o/templatetags/custom_link.py

@ -23,7 +23,7 @@ from django.conf import settings
register = template.Library()
@register.simple_tag
def nav_link():
def nav_link(position):
template = """
<li>
<a href="{}">
@ -33,5 +33,6 @@ def nav_link():
"""
res = ""
for link in settings.NAVBAR_LINKS:
res += template.format(link[0],link[1],link[2])
if position == link[3]:
res += template.format(link[0],link[1],link[2])
return res

5
templates/nav.html

@ -266,10 +266,13 @@ with this program; if not, write to the Free Software Foundation, Inc.,
</li>
{% acl_end %}
{% autoescape off %}
{% nav_link %}
{% nav_link "left"%}
{% endautoescape %}
</ul>
<ul class="nav navbar-nav navbar-right">
{% autoescape off %}
{% nav_link "right"%}
{% endautoescape %}
<li><a href="{% url 'contact' %}"><i class="fa fa-at"></i> {% trans "Contact" %}</a>
{% if not request.user.is_authenticated %}
{% for template in optionnal_templates_navbar_logout_list %}

Loading…
Cancel
Save