From 2e7c42f61f787297cdcab154562d17e375e8e882 Mon Sep 17 00:00:00 2001 From: Rodolphe Breard Date: Sun, 3 Jun 2018 11:02:55 +0200 Subject: [PATCH] Add a footer with a legal page --- khaganat/static/khaganat/css/khaganat.css | 12 ++++++++---- khaganat/templates/khaganat/base.html | 10 ++++++++-- pages/templatetags/__init__.py | 0 pages/templatetags/get_page.py | 14 ++++++++++++++ 4 files changed, 30 insertions(+), 6 deletions(-) create mode 100644 pages/templatetags/__init__.py create mode 100644 pages/templatetags/get_page.py diff --git a/khaganat/static/khaganat/css/khaganat.css b/khaganat/static/khaganat/css/khaganat.css index 469c22e..a5ed946 100644 --- a/khaganat/static/khaganat/css/khaganat.css +++ b/khaganat/static/khaganat/css/khaganat.css @@ -11,6 +11,14 @@ html,body { opacity: 0.8; } +#page-footer { + text-align: center; +} + +#messages { + margin-top: 10px; +} + .tooltip-inner { background-color: #efeded; color: #222; @@ -40,7 +48,3 @@ html,body { font-style: italic; color: #9073FF; } - -.messages { - margin-top: 10px; -} diff --git a/khaganat/templates/khaganat/base.html b/khaganat/templates/khaganat/base.html index 4e6afdd..18e9e34 100644 --- a/khaganat/templates/khaganat/base.html +++ b/khaganat/templates/khaganat/base.html @@ -1,4 +1,4 @@ -{% load static %}{% load i18n %}{% load navbar %}{% get_current_language as LANGUAGE_CODE %} +{% load static %}{% load i18n %}{% load navbar %}{% load get_page %}{% get_current_language as LANGUAGE_CODE %} @@ -22,7 +22,7 @@ {% navbar %}
{% if messages %} -
+
{% for message in messages %} {% endif %} {% block content %}{% endblock %} +
diff --git a/pages/templatetags/__init__.py b/pages/templatetags/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/pages/templatetags/get_page.py b/pages/templatetags/get_page.py new file mode 100644 index 0000000..f922490 --- /dev/null +++ b/pages/templatetags/get_page.py @@ -0,0 +1,14 @@ +from django.utils.translation import get_language +from pages.models import PageContent +from django import template + +register = template.Library() + +@register.simple_tag(takes_context=True) +def get_page(context, slug): + request = context['request'] + obj = PageContent.objects.filter( + language=get_language(), + page__slug=slug + ).first + return obj