8
0
Fork 0
mirror of https://gitlab2.federez.net/re2o/re2o synced 2024-11-06 01:46:27 +00:00

Merge branch 'custom_link' into 'dev'

add custom_link to navbar

See merge request re2o/re2o!631
This commit is contained in:
nanoy 2022-08-02 09:36:08 +00:00
commit 710cb0a16c
4 changed files with 51 additions and 0 deletions

View file

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

View file

@ -118,6 +118,9 @@ OPTIONNAL_APPS_RE2O = ()
# Some Django apps you want to add in you local project # Some Django apps you want to add in you local project
OPTIONNAL_APPS = OPTIONNAL_APPS_RE2O + () OPTIONNAL_APPS = OPTIONNAL_APPS_RE2O + ()
# 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 # Add statiffiles dir that were installed using system packaging
# Example to reproduce re2o2.9 behavior # Example to reproduce re2o2.9 behavior
# SYSTEM_STATICFILES_DIRS = ("/usr/share/fonts-font-awesome/", "/usr/share/javascript/") # SYSTEM_STATICFILES_DIRS = ("/usr/share/fonts-font-awesome/", "/usr/share/javascript/")

View file

@ -0,0 +1,38 @@
# Re2o est un logiciel d'administration développé initiallement au Rézo Metz. Il
# se veut agnostique au réseau considéré, de manière à être installable en
# quelques clics.
#
# Copyright © 2022 Cyprien de Cerval
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License along
# with this program; if not, write to the Free Software Foundation, Inc.,
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.from django import template
from django import template
from django.conf import settings
register = template.Library()
@register.simple_tag
def nav_link(position):
template = """
<li>
<a href="{}">
<i class="fa {}"></i> {}
</a>
</li>
"""
res = ""
for link in settings.NAVBAR_LINKS:
if position == link[3]:
res += template.format(link[0],link[1],link[2])
return res

View file

@ -23,6 +23,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
{% load static %} {% load static %}
{% load acl %} {% load acl %}
{% load custom_link %}
{% load i18n %} {% load i18n %}
<nav class="navbar navbar-inverse navbar-fixed-top" id="navbar-header"> <nav class="navbar navbar-inverse navbar-fixed-top" id="navbar-header">
<div class="container-fluid"> <div class="container-fluid">
@ -264,8 +265,14 @@ with this program; if not, write to the Free Software Foundation, Inc.,
</ul> </ul>
</li> </li>
{% acl_end %} {% acl_end %}
{% autoescape off %}
{% nav_link "left"%}
{% endautoescape %}
</ul> </ul>
<ul class="nav navbar-nav navbar-right"> <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> <li><a href="{% url 'contact' %}"><i class="fa fa-at"></i> {% trans "Contact" %}</a>
{% if not request.user.is_authenticated %} {% if not request.user.is_authenticated %}
{% for template in optionnal_templates_navbar_logout_list %} {% for template in optionnal_templates_navbar_logout_list %}