From e33d9f45279970295ba5b1d04e0f0e24e93aa069 Mon Sep 17 00:00:00 2001 From: Edward Ribeiro Date: Fri, 8 Jan 2016 19:37:45 -0200 Subject: [PATCH] Add header settings via Cadastro Casa Legislativa. --- sapl/context_processors.py | 21 ++++++++++++++++++++- templates/base.html | 8 ++++++-- 2 files changed, 26 insertions(+), 3 deletions(-) diff --git a/sapl/context_processors.py b/sapl/context_processors.py index d3dca8e69..29e570794 100644 --- a/sapl/context_processors.py +++ b/sapl/context_processors.py @@ -1,6 +1,15 @@ + +from base.models import CasaLegislativa + + +# TODO: this need to be cached and retrieved once!!! +def query_database(): + return CasaLegislativa.objects.first() + + def parliament_info(request): - return { + context = { 'state': 'Estado', 'state_abbr': 'UF', 'city': 'Cidade', @@ -11,3 +20,13 @@ def parliament_info(request): 'url_portal': '#', 'url_email': '#', } + + casa_legislativa = query_database() + + if casa_legislativa: + context['parliament_type'] = casa_legislativa.nome + context['city'] = casa_legislativa.municipio + context['state'] = casa_legislativa.uf + context['logotipo'] = casa_legislativa.logotipo + + return context; diff --git a/templates/base.html b/templates/base.html index 983aef960..31f9d7858 100644 --- a/templates/base.html +++ b/templates/base.html @@ -117,8 +117,12 @@ {% block main_header %}
-
{# XXX Make better use of translation tags in html blocks ie. actually use the proper blocktrans tag efficiently #}