Skip to content

Commit

Permalink
Show LII for an AU member state
Browse files Browse the repository at this point in the history
  • Loading branch information
nickmwangemi committed Aug 2, 2023
1 parent a605fe6 commit 5a16894
Show file tree
Hide file tree
Showing 4 changed files with 119 additions and 97 deletions.
90 changes: 90 additions & 0 deletions africanlii/context_processors.py
Original file line number Diff line number Diff line change
@@ -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
35 changes: 24 additions & 11 deletions africanlii/templates/africanlii/au_detail_page.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{% extends "peachjam/layouts/main.html" %}
{% load i18n %}
{% load static i18n %}
{% block title %}
{% trans 'African Union (AU)' %}
{% endblock %}
Expand Down Expand Up @@ -75,16 +75,29 @@ <h3 class="mb-4 heading-underlined" id="au-institutions">{% trans 'African Union
</section>
<section class="container">
<div class="row">
<div class="col-sm-12">
<h3 class="mb-4 heading-underlined" id="member-states">{% trans 'Member States' %}</h3>
<ul class="list-unstyled">
{% for member_state in member_states %}
<li>
<a href="{% url 'member_state_detail_view' member_state.country.iso %}">{{ member_state.country }}</a>
</li>
{% endfor %}
</ul>
</div>
<h3 class="mb-4 heading-underlined" id="member-states">{% trans 'Member States' %}</h3>
{% for member_state in member_states %}
<div class="col-6 col-md-4 col-lg-3">
<div class="card lii-card mb-3">
<div class="card-body">
<img src="{% static 'lib/flag-icons/flags/4x3/' %}{{ member_state.country.iso|lower }}.svg"
alt="{{ member_state.name }}"
class="mb-3"/>
<h5 class="card-title">
<a href="{% url 'member_state_detail_view' member_state.country.iso %}"
class="stretched-link"
target="_blank">{{ member_state.country }}</a>
</h5>
{% for lii in liis %}
{% if lii.country == member_state.country.name %}
<div>{{ lii.name }}</div>
<a href="{{ lii.url }}" class="stretched-link" target="_blank">{{ lii.domain }}</a>
{% endif %}
{% endfor %}
</div>
</div>
</div>
{% endfor %}
</div>
</section>
{% endblock %}
2 changes: 2 additions & 0 deletions africanlii/views/au.py
Original file line number Diff line number Diff line change
@@ -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,
Expand All @@ -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


Expand Down
89 changes: 3 additions & 86 deletions africanlii/views/home.py
Original file line number Diff line number Diff line change
@@ -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,
Expand Down Expand Up @@ -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]

Expand Down

0 comments on commit 5a16894

Please sign in to comment.