Skip to content

Commit

Permalink
Merge branch 'main' into password-validation
Browse files Browse the repository at this point in the history
  • Loading branch information
nickmwangemi authored Aug 11, 2023
2 parents 37545d5 + 2733077 commit 6ced974
Show file tree
Hide file tree
Showing 24 changed files with 432 additions and 117 deletions.
100 changes: 100 additions & 0 deletions africanlii/constants.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
LIIS = [
{
"name": "EswatiniLII",
"country": "Eswatini",
"url": "https://eswatinilii.org",
"logo": "images/liis/eswatinilii.png",
"domain": "eswatinilii.org",
},
{
"name": "GhaLII",
"country": "Ghana",
"url": "https://ghalii.org",
"logo": "images/liis/ghalii.png",
"domain": "ghalii.org",
},
{
"name": "Kenya Law",
"country": "Kenya",
"url": "http://kenyalaw.org",
"logo": "images/liis/kenyalaw.png",
"domain": "kenyalaw.org",
},
{
"name": "LesothoLII",
"country": "Lesotho",
"url": "https://lesotholii.org",
"logo": "images/liis/lesotholii.png",
"domain": "lesotholii.org",
},
{
"name": "MalawiLII",
"country": "Malawi",
"url": "https://malawilii.org",
"logo": "images/liis/malawilii.png",
"domain": "malawilii.org",
},
{
"name": "NamibLII",
"country": "Namibia",
"url": "https://namiblii.org",
"logo": "images/liis/namiblii.png",
"domain": "namiblii.org",
},
{
"name": "SierraLII",
"country": "Sierra Leone",
"url": "https://sierralii.org",
"logo": "images/liis/sierralii.png",
"domain": "sierralii.org",
},
{
"name": "SeyLII",
"country": "Seychelles",
"url": "https://seylii.org",
"logo": "images/liis/seylii.png",
"domain": "seylii.org",
},
{
"name": "LawLibrary",
"country": "South Africa",
"url": "https://lawlibrary.org.za",
"logo": "images/liis/lawlibrary.png",
"domain": "lawlibrary.org.za",
},
{
"name": "TanzLII",
"country": "Tanzania",
"url": "https://tanzlii.org",
"logo": "images/liis/tanzlii.png",
"domain": "tanzlii.org",
},
{
"name": "ULII",
"country": "Uganda",
"url": "https://ulii.org",
"logo": "images/liis/ulii.png",
"domain": "ulii.org",
},
{
"name": "ZambiaLII",
"country": "Zambia",
"url": "https://zambialii.org",
"logo": "images/liis/zambialii.png",
"domain": "zambialii.org",
},
{
"name": "ZanzibarLII",
"country": "Zanzibar",
"url": "https://zanzibarlii.org",
"logo": "images/liis/zanzibarlii.png",
"domain": "zanzibarlii.org",
},
{
"name": "ZimLII",
"country": "Zimbabwe",
"url": "https://zimlii.org",
"logo": "images/liis/zimlii.png",
"domain": "zimlii.org",
},
]
13 changes: 13 additions & 0 deletions africanlii/templates/africanlii/_lii_info.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{% load i18n %}
{% for lii in liis %}
{% if lii.country == member_state.country.name %}
<div>
{% blocktrans trimmed with lii_name=lii.name %}
Visit {{ lii_name }} for more legal information.
{% endblocktrans %}
</div>
<div>
<a href="{{ lii.url }}" target="_blank">{{ lii.domain }}</a>
</div>
{% endif %}
{% endfor %}
29 changes: 18 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,23 @@ <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/'|add:member_state.country.iso|lower|add:".svg" %}"
alt="{{ member_state.name }}"
class="mb-3"/>
<h5 class="card-title">
<a href="{% url 'member_state_detail_view' member_state.country.iso %}"
target="_blank">{{ member_state.country }}</a>
</h5>
{% include 'africanlii/_lii_info.html' %}
</div>
</div>
</div>
{% endfor %}
</div>
</section>
{% endblock %}
1 change: 1 addition & 0 deletions africanlii/templates/africanlii/member_state_detail.html
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
{% endblock %}
{% block page-header %}
<h1 class="mt-4">{{ member_state }}</h1>
{% include 'africanlii/_lii_info.html' %}
{% include 'peachjam/_document_count.html' %}
{% endblock %}
{% block page-list-facets %}{% endblock %}
Expand Down
3 changes: 3 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.constants import 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"] = LIIS
return context


Expand Down Expand Up @@ -67,5 +69,6 @@ def get_context_data(self, **kwargs):
country=self.get_object().country
)
context["doc_count"] = ratification_countries.count()
context["liis"] = LIIS

return context
90 changes: 2 additions & 88 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.constants import LIIS
from africanlii.models import (
AfricanUnionInstitution,
AfricanUnionOrgan,
Expand Down Expand Up @@ -39,94 +40,7 @@ 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",
},
]
for lii in context["liis"]:
lii["domain"] = lii["url"].split("/", 3)[2]
context["liis"] = LIIS

# check user's preferred language
current_language = get_language_from_request(self.request)
Expand Down
7 changes: 5 additions & 2 deletions peachjam/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,11 @@ def _wrapped_view(request, *args, **kwargs):

def get_language(request):
"""Get language from the request object and return its 3-letter language code."""
language = get_language_from_request(request)
return Language.objects.get(iso_639_1__iexact=language).iso_639_3
if not hasattr(request, "language"):
language = get_language_from_request(request)
# store it on the request object because it won't change
request.language = Language.objects.get(iso_639_1__iexact=language).iso_639_3
return request.language


def pdfjs_to_text(fname):
Expand Down
6 changes: 3 additions & 3 deletions peachjam/js/locale/fr/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,15 @@
"Delete": "Supprimez",
"Document nature": "Type de document",
"Document type": "Type de document",
"Edit": "Edit",
"Edit": "Modifier",
"Enter end date": "Entrez la date de fin",
"Enter start date": "Entrez la date de début",
"Expand all": "Développer tout",
"Filters": "Filtres",
"Judges": "Juges",
"Jurisdiction": "Juridiction",
"Language": "Langue",
"Link citation": "Link citation",
"Link citation": "Citation de lien",
"Loading": "En cours de chargement",
"Locality": "Localité",
"Matter type": "Type de matière",
Expand All @@ -48,7 +48,7 @@
"Relevance": "Pertinence",
"Search": "Recherche",
"Search {{appName}}": {
"": "Search {{appName}}..."
"": "Rechercher dans {{appName}}..."
},
"Search document content": "Rechercher le contenu du document",
"Search documents": "Rechercher des documents",
Expand Down
5 changes: 5 additions & 0 deletions peachjam/js/locale/pt/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,15 @@
"Delete": "Excluir",
"Document nature": "Natureza do documento",
"Document type": "Tipo de documento",
"Edit": "Editar",
"Enter end date": "Digite a data final",
"Enter start date": "Digite a data inicial",
"Expand all": "Expandir tudo",
"Filters": "Filtros",
"Judges": "Juízes",
"Jurisdiction": "Jurisdição",
"Language": "Idioma",
"Link citation": "Citação de link",
"Loading": "Carregando...",
"Locality": "Localidade",
"Matter type": "Tipo de matéria",
Expand All @@ -45,6 +47,9 @@
"Regional body": "Corpo regional",
"Relevance": "Relevância",
"Search": "Pesquisa",
"Search {{appName}}": {
"": "Pesquisar {{appName}}..."
},
"Search document content": "Pesquisar conteúdo de documento",
"Search documents": "Pesquisar documentos",
"Search table of contents": "Pesquisar na tabela de conteúdos",
Expand Down
6 changes: 3 additions & 3 deletions peachjam/js/locale/sw/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,15 @@
"Delete": "Futa",
"Document nature": "Asili ya hati",
"Document type": "Aina ya hati",
"Edit": "Edit",
"Edit": "Hariri",
"Enter end date": "Weka tarehe ya mwisho",
"Enter start date": "Weka tarehe ya kuanza",
"Expand all": "Panua zote",
"Filters": "Vichujio",
"Judges": "Majaji",
"Jurisdiction": "Mamlaka ya kisheria",
"Language": "Lugha",
"Link citation": "Link citation",
"Link citation": "Nukuu ya kiungo",
"Loading": "Inapakia",
"Locality": "Eneo",
"Matter type": "Aina ya jambo",
Expand All @@ -48,7 +48,7 @@
"Relevance": "Muhimu",
"Search": "Tafuta",
"Search {{appName}}": {
"": "Search {{appName}}..."
"": "Tafuta {{appName}}..."
},
"Search document content": "Tafuta yaliyomo kwenye waraka",
"Search documents": "Tafuta nyaraka",
Expand Down
Loading

0 comments on commit 6ced974

Please sign in to comment.