From 3652568e8c95e55a3a96baedf46272bdf17e85f7 Mon Sep 17 00:00:00 2001 From: nickmwangemi Date: Tue, 15 Aug 2023 18:44:46 +0300 Subject: [PATCH] By-laws on LawLibrary --- lawlibrary/constants.py | 1 + lawlibrary/context_processors.py | 10 +++++ lawlibrary/settings.py | 5 +++ .../liiweb/locality_legislation_list.html | 10 +++++ lawlibrary/templates/peachjam/_header.html | 6 +++ .../peachjam/legislation_detail.html | 12 ++++-- lawlibrary/urls.py | 16 +++++--- lawlibrary/views/legislation.py | 39 +++++++++++++++++-- .../liiweb/locality_legislation.html | 2 +- .../liiweb/locality_legislation_list.html | 11 ++++-- liiweb/views/legislation.py | 2 +- 11 files changed, 96 insertions(+), 18 deletions(-) create mode 100644 lawlibrary/constants.py create mode 100644 lawlibrary/context_processors.py create mode 100644 lawlibrary/templates/liiweb/locality_legislation_list.html diff --git a/lawlibrary/constants.py b/lawlibrary/constants.py new file mode 100644 index 000000000..8dc7106c1 --- /dev/null +++ b/lawlibrary/constants.py @@ -0,0 +1 @@ +PROVINCIAL_CODES = ["ec", "fs", "gp", "lp", "mp", "nc", "nw", "wc", "kzn", "transvaal"] diff --git a/lawlibrary/context_processors.py b/lawlibrary/context_processors.py new file mode 100644 index 000000000..6e3bbf4cf --- /dev/null +++ b/lawlibrary/context_processors.py @@ -0,0 +1,10 @@ +from lawlibrary.constants import PROVINCIAL_CODES + + +def lawlibrary(request): + """ + Add some useful context to templates. + """ + return { + "PROVINCIAL_CODES": PROVINCIAL_CODES, + } diff --git a/lawlibrary/settings.py b/lawlibrary/settings.py index a2a3e2b45..39923b304 100644 --- a/lawlibrary/settings.py +++ b/lawlibrary/settings.py @@ -7,3 +7,8 @@ JAZZMIN_SETTINGS["site_title"] = "Lawlibrary" # noqa JAZZMIN_SETTINGS["site_header"] = "Lawlibrary" # noqa JAZZMIN_SETTINGS["site_brand"] = "Lawlibrary.org.za" # noqa + + +TEMPLATES[0]["OPTIONS"]["context_processors"].append( # noqa + "lawlibrary.context_processors.lawlibrary" +) diff --git a/lawlibrary/templates/liiweb/locality_legislation_list.html b/lawlibrary/templates/liiweb/locality_legislation_list.html new file mode 100644 index 000000000..b0f398912 --- /dev/null +++ b/lawlibrary/templates/liiweb/locality_legislation_list.html @@ -0,0 +1,10 @@ +{% extends "liiweb/locality_legislation_list.html" %} +{% load i18n %} +{% block page-heading %} + {% if locality.code in PROVINCIAL_CODES %} +

{% blocktrans with locality=locality.name %}{{ locality }} Legislation{% endblocktrans %}

+ {% else %} +

{% blocktrans with locality=locality.name %}{{ locality }} By-laws{% endblocktrans %}

+ {% endif %} + {% include 'lawlibrary/_legislation_alert.html' %} +{% endblock %} diff --git a/lawlibrary/templates/peachjam/_header.html b/lawlibrary/templates/peachjam/_header.html index 14de65d0e..e4ca84bd8 100644 --- a/lawlibrary/templates/peachjam/_header.html +++ b/lawlibrary/templates/peachjam/_header.html @@ -27,6 +27,12 @@ {% trans 'Provincial Legislation' %} + - + {% if show_subleg %} + + {% endif %}