From a9830dba8fc4246f9ae56dc95d49cba558c33d79 Mon Sep 17 00:00:00 2001 From: Bryan Brancotte <bryan.brancotte@pasteur.fr> Date: Mon, 2 Sep 2019 10:47:57 +0200 Subject: [PATCH] Populating upper nav_bar with pasteur link Adding credits in footer printing warnings only once WIP #2 --- .../css/basetheme_bootstrap4_pasteur.css | 6 +++--- .../basetheme_bootstrap/basePasteur.html | 19 +++++-------------- .../basetheme_bootstrap/credits.example.html | 4 ++++ .../upper_nav_bar.example.html | 2 ++ .../templatetags/basetheme_bootstrap.py | 19 +++++++++++++------ setup.py | 2 +- 6 files changed, 28 insertions(+), 24 deletions(-) create mode 100644 basetheme_bootstrap/templates/basetheme_bootstrap/credits.example.html create mode 100644 basetheme_bootstrap/templates/basetheme_bootstrap/upper_nav_bar.example.html diff --git a/basetheme_bootstrap/static/css/basetheme_bootstrap4_pasteur.css b/basetheme_bootstrap/static/css/basetheme_bootstrap4_pasteur.css index a708346..f6cd4de 100644 --- a/basetheme_bootstrap/static/css/basetheme_bootstrap4_pasteur.css +++ b/basetheme_bootstrap/static/css/basetheme_bootstrap4_pasteur.css @@ -258,6 +258,8 @@ footer .inner-wrap { display: inline-block; vertical-align: middle; flex: 0 0 auto; + display: flex; + flex-direction: column; } .footer__section:last-child{ flex: 0 1 auto; @@ -313,9 +315,7 @@ footer .inner-wrap { .footer__section ul .nav-link { padding:0px; } -.footer__section:last-child nav+span{ - position: absolute; - bottom: 0; +.footer__section:last-child span{ text-align: right; font-size: initial; } diff --git a/basetheme_bootstrap/templates/basetheme_bootstrap/basePasteur.html b/basetheme_bootstrap/templates/basetheme_bootstrap/basePasteur.html index ffada8b..a08343d 100644 --- a/basetheme_bootstrap/templates/basetheme_bootstrap/basePasteur.html +++ b/basetheme_bootstrap/templates/basetheme_bootstrap/basePasteur.html @@ -36,6 +36,7 @@ </button> <div class="collapse navbar-collapse" id="navbarCollapse"> <ul class="navbar-nav mr-auto"> + {% include_if_exists "upper_nav_bar.html"|localize_template "basetheme_bootstrap/upper_nav_bar.example.html" %} </ul> {% block form_in_nav_bar %} <form class="form-inline mt-2 mt-md-0" action="search/" method="post"> @@ -70,9 +71,7 @@ </nav> <div class="header__middle"> <div class="header__logo-wrapper"> - <a href="/" title="Accueil" rel="home"> - <img src="https://www.pasteur.fr/sites/default/files/logo_institut_pasteur_noir.png" alt="Accueil"> - </a> + <img src="https://www.pasteur.fr/sites/default/files/logo_institut_pasteur_noir.png" alt="Accueil"> </div> <div class="header__nav"> <nav class="main-nav" role="navigation"> @@ -145,25 +144,17 @@ </nav> </div> </div> - <div class="footer__section footer__menu-social"> + <div class="footer__section"> <div class="block block-menu block-menu-menu-footer-menu-social"> <nav> <ul> - <li> - <a class="suivre_pasteur_facebook" href="" target="_blank"></a> - </li> - <li> - <a class="suivre_pasteur_linkedin" href="" target="_blank"></a> - </li> - <li> - <a class="suivre_pasteur_twitter" href="" target="_blank"></a> - </li> + {% include_if_exists "credits.html"|localize_template "basetheme_bootstrap/credits.example.html" %} </ul> </nav> + </div> <span class="text-muted float-right"> {% include_if_exists "last_update.html"|localize_template "basetheme_bootstrap/last_update.example.html" %} </span> - </div> </div> </div> </footer> diff --git a/basetheme_bootstrap/templates/basetheme_bootstrap/credits.example.html b/basetheme_bootstrap/templates/basetheme_bootstrap/credits.example.html new file mode 100644 index 0000000..73b2ac2 --- /dev/null +++ b/basetheme_bootstrap/templates/basetheme_bootstrap/credits.example.html @@ -0,0 +1,4 @@ +{% load basetheme_bootstrap %} +{% load i18n %} +<li class="nav-item "><a href="https://www.pasteur.fr/" target="_blank" class="nav-link">{%trans "L'Institut Pasteur"%}</a></li> +<li class="nav-item "><a href="https://research.pasteur.fr/fr/team/bioinformatics-and-biostatistics-hub/" target="_blank" class="nav-link">{%trans "Bioinformatics and Biostatistics HUB"%}</a></li> \ No newline at end of file diff --git a/basetheme_bootstrap/templates/basetheme_bootstrap/upper_nav_bar.example.html b/basetheme_bootstrap/templates/basetheme_bootstrap/upper_nav_bar.example.html new file mode 100644 index 0000000..60d1d1e --- /dev/null +++ b/basetheme_bootstrap/templates/basetheme_bootstrap/upper_nav_bar.example.html @@ -0,0 +1,2 @@ +{% load i18n %} +<li class="nav-item "><a href="https://www.pasteur.fr/" target="_blank" class="nav-link">{%trans "L'Institut Pasteur"%}</a></li> \ No newline at end of file diff --git a/basetheme_bootstrap/templatetags/basetheme_bootstrap.py b/basetheme_bootstrap/templatetags/basetheme_bootstrap.py index 199d817..3230434 100644 --- a/basetheme_bootstrap/templatetags/basetheme_bootstrap.py +++ b/basetheme_bootstrap/templatetags/basetheme_bootstrap.py @@ -2,6 +2,7 @@ import logging from django import template from django.conf import settings +from django.core.cache import cache from django.template.base import Token from django.template.loader import get_template from django.template.loader_tags import do_include @@ -55,6 +56,7 @@ class IncludeIfExistsNode(template.Node): self.template_node = do_include(parser, Token(token.token_type, 'do_include %s' % split_contents[1])) self.default_template_name = None self.default_template_node = None + self.__template_seen=set() try: self.default_template_name = split_contents[2] self.default_template_node = do_include(parser, @@ -66,13 +68,18 @@ class IncludeIfExistsNode(template.Node): try: return self.template_node.render(context) except template.TemplateDoesNotExist: - logger.warning( - 'Template %s was not found and could not be included.' % self.template_name + - ( - ('Please see %s to have an example' % self.default_template_name) - if self.default_template_name else '' + cache_key = 'Template_not_found_%s' % self.template_name + if cache.get(cache_key, None) is None: + cache.set(cache_key, '', None) + self.__template_seen.add(self.template_name) + print(self.__template_seen) + logger.warning( + 'Template %s was not found and could not be included.' % self.template_name + + ( + ('Please see %s to have an example' % self.default_template_name) + if self.default_template_name else '' + ) ) - ) if self.default_template_node: return self.default_template_node.render(context) return '' diff --git a/setup.py b/setup.py index ab97c1d..42db4cd 100644 --- a/setup.py +++ b/setup.py @@ -7,7 +7,7 @@ readme = open('README.rst').read() setup( name='django-basetheme-bootstrap', - version='0.2.11', + version='0.2.12', description='Django Basetheme Bootstrap', long_description=readme, author='Bryan Brancotte', -- GitLab