diff --git a/africanlii/context_processors.py b/africanlii/context_processors.py new file mode 100644 index 000000000..45fba70d0 --- /dev/null +++ b/africanlii/context_processors.py @@ -0,0 +1,90 @@ +LIIS = [ + { + "name": "EswatiniLII", + "country": "Eswatini", + "url": "https://eswatinilii.org", + "logo": "images/liis/eswatinilii.png", + }, + { + "name": "GhaLII", + "country": "Ghana", + "url": "https://ghalii.org", + "logo": "images/liis/ghalii.png", + }, + { + "name": "Kenya Law", + "country": "Kenya", + "url": "http://kenyalaw.org", + "logo": "images/liis/kenyalaw.png", + }, + { + "name": "LesothoLII", + "country": "Lesotho", + "url": "https://lesotholii.org", + "logo": "images/liis/lesotholii.png", + }, + { + "name": "MalawiLII", + "country": "Malawi", + "url": "https://malawilii.org", + "logo": "images/liis/malawilii.png", + }, + { + "name": "NamibLII", + "country": "Namibia", + "url": "https://namiblii.org", + "logo": "images/liis/namiblii.png", + }, + { + "name": "SierraLII", + "country": "Sierra Leone", + "url": "https://sierralii.org", + "logo": "images/liis/sierralii.png", + }, + { + "name": "SeyLII", + "country": "Seychelles", + "url": "https://seylii.org", + "logo": "images/liis/seylii.png", + }, + { + "name": "LawLibrary", + "country": "South Africa", + "url": "https://lawlibrary.org.za", + "logo": "images/liis/lawlibrary.png", + }, + { + "name": "TanzLII", + "country": "Tanzania", + "url": "https://tanzlii.org", + "logo": "images/liis/tanzlii.png", + }, + { + "name": "ULII", + "country": "Uganda", + "url": "https://ulii.org", + "logo": "images/liis/ulii.png", + }, + { + "name": "ZambiaLII", + "country": "Zambia", + "url": "https://zambialii.org", + "logo": "images/liis/zambialii.png", + }, + { + "name": "ZanzibarLII", + "country": "Zanzibar", + "url": "https://zanzibarlii.org", + "logo": "images/liis/zanzibarlii.png", + }, + { + "name": "ZimLII", + "country": "Zimbabwe", + "url": "https://zimlii.org", + "logo": "images/liis/zimlii.png", + }, +] + + +def show_liis(request): + return LIIS diff --git a/africanlii/templates/africanlii/au_detail_page.html b/africanlii/templates/africanlii/au_detail_page.html index 0b64ae91e..c3c812eb5 100644 --- a/africanlii/templates/africanlii/au_detail_page.html +++ b/africanlii/templates/africanlii/au_detail_page.html @@ -1,5 +1,5 @@ {% extends "peachjam/layouts/main.html" %} -{% load i18n %} +{% load static i18n %} {% block title %} {% trans 'African Union (AU)' %} {% endblock %} @@ -75,16 +75,29 @@

{% trans 'African Union
-
-

{% trans 'Member States' %}

- -
+

{% trans 'Member States' %}

+ {% for member_state in member_states %} +
+
+
+ {{ member_state.name }} +
+ {{ member_state.country }} +
+ {% for lii in liis %} + {% if lii.country == member_state.country.name %} +
{{ lii.name }}
+ {{ lii.domain }} + {% endif %} + {% endfor %} +
+
+
+ {% endfor %}
{% endblock %} diff --git a/africanlii/views/au.py b/africanlii/views/au.py index cc894e2bd..88f225be7 100644 --- a/africanlii/views/au.py +++ b/africanlii/views/au.py @@ -1,6 +1,7 @@ from django.shortcuts import get_object_or_404 from django.views.generic import DetailView, TemplateView +from africanlii.context_processors import show_liis from africanlii.models import ( AfricanUnionInstitution, AfricanUnionOrgan, @@ -27,6 +28,7 @@ def get_context_data(self, **kwargs): context["au_institutions"] = AfricanUnionInstitution.objects.prefetch_related( "author" ) + context["liis"] = show_liis(self.request) return context diff --git a/africanlii/views/home.py b/africanlii/views/home.py index 0dca03faa..2dca9c744 100644 --- a/africanlii/views/home.py +++ b/africanlii/views/home.py @@ -1,5 +1,6 @@ from django.utils.translation import get_language_from_request +from africanlii.context_processors import show_liis from africanlii.models import ( AfricanUnionInstitution, AfricanUnionOrgan, @@ -39,92 +40,8 @@ def get_context_data(self, **kwargs): context["taxonomies"] = Taxonomy.get_tree() context["court_classes"] = CourtClass.objects.prefetch_related("courts") - context["liis"] = [ - { - "name": "EswatiniLII", - "country": "Eswatini", - "url": "https://eswatinilii.org", - "logo": "images/liis/eswatinilii.png", - }, - { - "name": "GhaLII", - "country": "Ghana", - "url": "https://ghalii.org", - "logo": "images/liis/ghalii.png", - }, - { - "name": "Kenya Law", - "country": "Kenya", - "url": "http://kenyalaw.org", - "logo": "images/liis/kenyalaw.png", - }, - { - "name": "LesothoLII", - "country": "Lesotho", - "url": "https://lesotholii.org", - "logo": "images/liis/lesotholii.png", - }, - { - "name": "MalawiLII", - "country": "Malawi", - "url": "https://malawilii.org", - "logo": "images/liis/malawilii.png", - }, - { - "name": "NamibLII", - "country": "Namibia", - "url": "https://namiblii.org", - "logo": "images/liis/namiblii.png", - }, - { - "name": "SierraLII", - "country": "Sierra Leone", - "url": "https://sierralii.org", - "logo": "images/liis/sierralii.png", - }, - { - "name": "SeyLII", - "country": "Seychelles", - "url": "https://seylii.org", - "logo": "images/liis/seylii.png", - }, - { - "name": "LawLibrary", - "country": "South Africa", - "url": "https://lawlibrary.org.za", - "logo": "images/liis/lawlibrary.png", - }, - { - "name": "TanzLII", - "country": "Tanzania", - "url": "https://tanzlii.org", - "logo": "images/liis/tanzlii.png", - }, - { - "name": "ULII", - "country": "Uganda", - "url": "https://ulii.org", - "logo": "images/liis/ulii.png", - }, - { - "name": "ZambiaLII", - "country": "Zambia", - "url": "https://zambialii.org", - "logo": "images/liis/zambialii.png", - }, - { - "name": "ZanzibarLII", - "country": "Zanzibar", - "url": "https://zanzibarlii.org", - "logo": "images/liis/zanzibarlii.png", - }, - { - "name": "ZimLII", - "country": "Zimbabwe", - "url": "https://zimlii.org", - "logo": "images/liis/zimlii.png", - }, - ] + context["liis"] = show_liis(self.request) + for lii in context["liis"]: lii["domain"] = lii["url"].split("/", 3)[2]