-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'origin/main' into sandrava-1714
- Loading branch information
Showing
119 changed files
with
3,913 additions
and
530 deletions.
There are no files selected for viewing
34 changes: 0 additions & 34 deletions
34
.github/ISSUE_TEMPLATE/adding-new-fields-to-a-document-type.md
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -55,9 +55,26 @@ jobs: | |
git_remote_url: 'ssh://[email protected]:22/ulii-peachjam' | ||
git_push_flags: '--force' | ||
|
||
deploy-zanzibarlii: | ||
deploy-gazettes: | ||
if: ${{ !cancelled() }} | ||
needs: deploy-lawlibrary | ||
name: Deploy to gazettes.africa | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
with: | ||
fetch-depth: 0 | ||
|
||
- name: git push to gazettes.africa | ||
uses: dokku/github-action@master | ||
with: | ||
ssh_private_key: ${{ secrets.SSH_DEPLOYMENT_KEY }} | ||
git_remote_url: 'ssh://[email protected]:22/gazettes' | ||
git_push_flags: '--force' | ||
|
||
deploy-zanzibarlii: | ||
if: ${{ !cancelled() }} | ||
needs: deploy-gazettes | ||
name: Deploy to zanzibarlii | ||
runs-on: ubuntu-latest | ||
steps: | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
default_app_config = "gazettes.apps.GazettesAfricaConfig" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
from django.apps import AppConfig | ||
|
||
|
||
class GazettesAfricaConfig(AppConfig): | ||
name = "gazettes" | ||
verbose_name = "Gazettes.Africa" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
from gazettes.jurisdictions import jurisdiction_list | ||
|
||
|
||
def jurisdictions(request): | ||
return {"jurisdictions": jurisdiction_list()} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,211 @@ | ||
from dataclasses import dataclass | ||
from typing import List | ||
|
||
|
||
@dataclass | ||
class Jurisdiction: | ||
code: str | ||
name: str | ||
parent_code: str = None | ||
publication: str = "Government Gazette" | ||
sub_publication_label: str = "Sub-publication" | ||
sub_publication_required: bool = False | ||
sub_publications: List[str] = None | ||
number_short: str = "no" | ||
number_long: str = "number" | ||
stitched_supplements: bool = False | ||
ident_requires_last_page: bool = False | ||
|
||
@property | ||
def parent(self): | ||
if self.parent_code: | ||
return JURISDICTION_MAP[self.parent_code] | ||
|
||
@property | ||
def full_name(self): | ||
if self.parent_code: | ||
return f"{self.name}, {self.parent.name}" | ||
return self.name | ||
|
||
@property | ||
def full_name_for_search(self): | ||
if self.parent_code: | ||
return f"{self.parent.name} - {self.name}" | ||
return self.name | ||
|
||
@property | ||
def children(self): | ||
return sorted( | ||
[x for x in JURISDICTIONS if x.parent_code == self.code], | ||
key=lambda x: x.name, | ||
) | ||
|
||
@property | ||
def place_code(self): | ||
return self.code | ||
|
||
|
||
JURISDICTIONS = [ | ||
Jurisdiction("dz", "Algeria"), | ||
Jurisdiction( | ||
"ao", | ||
"Angola", | ||
sub_publications=["Series I", "Series II", "Series III"], | ||
sub_publication_label="Series", | ||
sub_publication_required=True, | ||
), | ||
Jurisdiction("bw", "Botswana"), | ||
Jurisdiction("cg", "Congo", publication="Journal Officiel"), | ||
Jurisdiction("aa", "African Regional Bodies"), | ||
Jurisdiction("aa-eac", "East African Community", "aa", publication="Gazette"), | ||
Jurisdiction( | ||
"aa-ecowas", | ||
"Economic Community of West African States", | ||
"aa", | ||
publication="Official Journal", | ||
number_short="vol", | ||
number_long="volume", | ||
), | ||
Jurisdiction("gh", "Ghana"), | ||
Jurisdiction("ke", "Kenya"), | ||
Jurisdiction("ls", "Lesotho"), | ||
Jurisdiction("mu", "Mauritius"), | ||
Jurisdiction("mw", "Malawi"), | ||
Jurisdiction( | ||
"mz", | ||
"Mozambique", | ||
sub_publications=["Series I", "Series II", "Series III"], | ||
sub_publication_label="Series", | ||
sub_publication_required=True, | ||
), | ||
Jurisdiction("na", "Namibia"), | ||
Jurisdiction("ng", "Nigeria"), | ||
Jurisdiction("rw", "Rwanda"), | ||
Jurisdiction("sc", "Seychelles", stitched_supplements=True), | ||
Jurisdiction("sl", "Sierra Leone"), | ||
Jurisdiction("sz", "Eswatini"), | ||
Jurisdiction("tz", "Tanzania"), | ||
Jurisdiction("tz-znz", "Zanzibar", "tz"), | ||
Jurisdiction("ug", "Uganda"), | ||
Jurisdiction("zm", "Zambia"), | ||
# ZW supplements require the date from the last page | ||
Jurisdiction( | ||
"zw", "Zimbabwe", ident_requires_last_page=True, stitched_supplements=True | ||
), | ||
Jurisdiction( | ||
"za", | ||
"South Africa", | ||
sub_publications=[ | ||
"Regulation Gazette", | ||
"Legal Notices A", | ||
"Legal Notices B", | ||
"Legal Notices C", | ||
"Legal Notices D", | ||
], | ||
), | ||
Jurisdiction("za-wc", "Western Cape", "za", "Provincial Gazette"), | ||
Jurisdiction("za-ec", "Eastern Cape", "za", "Provincial Gazette"), | ||
Jurisdiction("za-gp", "Gauteng", "za", "Provincial Gazette"), | ||
Jurisdiction("za-kzn", "KwaZulu-Natal", "za", "Provincial Gazette"), | ||
Jurisdiction("za-lp", "Limpopo", "za", "Provincial Gazette"), | ||
Jurisdiction("za-mp", "Mpumalanga", "za", "Provincial Gazette"), | ||
Jurisdiction("za-nw", "North-West", "za", "Provincial Gazette"), | ||
Jurisdiction("za-nc", "Northern Cape", "za", "Provincial Gazette"), | ||
Jurisdiction("za-fs", "Free State", "za", "Provincial Gazette"), | ||
Jurisdiction("za-transvaal", "Transvaal", "za", "Provincial Gazette"), | ||
Jurisdiction("ng-la", "Lagos State", "ng", "Official Gazette"), | ||
Jurisdiction("ma", "Morocco", publication="Bulletin Officiel"), | ||
Jurisdiction("so", "Somalia"), | ||
Jurisdiction("so-sl", "Somaliland", "so", "Official Gazette"), | ||
] | ||
JURISDICTION_MAP = {x.code: x for x in JURISDICTIONS} | ||
JURISDICTION_CHOICES = [(x.code, x.name) for x in JURISDICTIONS] | ||
|
||
COMMUNITIES = {"aa-eac", "aa-ecowas"} | ||
|
||
CONTRIBUTORS = { | ||
"sz": [ | ||
{ | ||
"name": "Werksmans", | ||
"url": "https://www.werksmans.com/", | ||
"img": "werksmans-logo.png", | ||
} | ||
], | ||
"bw": [ | ||
{ | ||
"name": "Werksmans", | ||
"url": "https://www.werksmans.com/", | ||
"img": "werksmans-logo.png", | ||
} | ||
], | ||
"za": [ | ||
{ | ||
"name": "GIZ", | ||
"url": "https://www.giz.de/", | ||
"img": "giz-logo.gif", | ||
}, | ||
{ | ||
"name": "Webber Wentzel", | ||
"url": "https://www.webberwentzel.com", | ||
"img": "ww-logo.png", | ||
}, | ||
], | ||
"za-fs": [ | ||
{ | ||
"name": "Free State Province", | ||
"url": "http://www.premier.fs.gov.za", | ||
"img": "za-fs-logo.jpg", | ||
} | ||
], | ||
"zw": [ | ||
{ | ||
"name": "Veritas Zimbabwe", | ||
"url": "https://www.veritaszim.net/", | ||
"img": "veritas-logo.png", | ||
} | ||
], | ||
None: [ | ||
{ | ||
"name": "The Indigo Trust", | ||
"url": "https://indigotrust.org.uk/", | ||
"img": "indigo-trust-logo.png", | ||
}, | ||
{ | ||
"name": "UCT Government Publications", | ||
"url": "http://www.governmentpublications.lib.uct.ac.za/", | ||
"img": "uct-logo.png", | ||
}, | ||
{ | ||
"name": "C4ADS", | ||
"url": "https://c4ads.org", | ||
"img": "c4ads-logo.png", | ||
}, | ||
], | ||
} | ||
ALL_CONTRIBUTORS = sorted( | ||
list({c["name"]: c for x in CONTRIBUTORS.values() for c in x}.values()), | ||
key=lambda c: c["name"], | ||
) | ||
|
||
|
||
def get_country_locality(code): | ||
from countries_plus.models import Country | ||
|
||
from peachjam.models import Locality | ||
|
||
if "-" in code: | ||
ctry, loc = code.split("-", 1) | ||
else: | ||
ctry = code | ||
loc = None | ||
|
||
ctry = Country.objects.get(pk=ctry.upper()) | ||
if loc: | ||
loc = Locality.objects.get(jurisdiction=ctry, code=loc) | ||
|
||
return ctry, loc | ||
|
||
|
||
def jurisdiction_list(): | ||
"""List of (code, name) tuples for active jurisdictions.""" | ||
return sorted(JURISDICTIONS, key=lambda j: j.name) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
from django.conf import settings | ||
from django.http import HttpResponseNotFound, HttpResponsePermanentRedirect | ||
from django.utils.deprecation import MiddlewareMixin | ||
|
||
|
||
class RedirectMiddleware(MiddlewareMixin): | ||
"""Middleware that redirects requests to: | ||
- the legacy archive.gazettes.laws.africa | ||
- www.gazettes.africa | ||
to gazettes.africa. | ||
""" | ||
|
||
def process_request(self, request): | ||
host = request.get_host() | ||
if host in ["archive.gazettes.laws.africa", "www.gazettes.africa"]: | ||
uri = f"https://gazettes.africa{request.get_full_path()}" | ||
return HttpResponsePermanentRedirect(uri) | ||
|
||
|
||
class NoIPMiddleware(MiddlewareMixin): | ||
"""Middleware that forces a 404 for an request that does not use a | ||
domain name. | ||
We use this because otherwise Google indexes the gazettes archive using | ||
the IP of the server, for some odd reason. | ||
Note that during deployment, the dokku aliveness check comes from a local host | ||
with an ip, but with ':5000' | ||
""" | ||
|
||
def process_request(self, request): | ||
host = request.get_host() | ||
if ( | ||
not settings.DEBUG | ||
and "africa" not in host | ||
and "localhost" not in host | ||
and not host.endswith(":5000") | ||
): | ||
return HttpResponseNotFound("not found") |
Oops, something went wrong.