Skip to content

Commit

Permalink
Merge pull request #2032 from laws-africa/gazettes-fix
Browse files Browse the repository at this point in the history
don't force a sub-type on gazettes
  • Loading branch information
longhotsummer authored Sep 14, 2024
2 parents 811d2d9 + 2f20192 commit ea5ee96
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 8 deletions.
1 change: 0 additions & 1 deletion peachjam/adapters/gazettes.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,6 @@ def update_document(self, url):
"frbr_uri_actor": frbr_uri.actor,
"frbr_uri_number": frbr_uri.number,
"frbr_uri_date": frbr_uri.date,
"nature": None, # see https://github.com/laws-africa/gazettemachine/issues/172
"language": language,
"date": date.fromisoformat(document["date"]),
"title": document["name"],
Expand Down
5 changes: 0 additions & 5 deletions peachjam/models/gazette.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,6 @@ class Meta(CoreDocument.Meta):
verbose_name_plural = _("gazettes")
permissions = [("api_gazette", "API gazette access")]

def set_frbr_uri_subtype(self):
# preserve the existing subtype if nature is not set
if self.nature:
self.frbr_uri_subtype = self.nature.code

def pre_save(self):
self.frbr_uri_doctype = "officialGazette"
self.doc_type = "gazette"
Expand Down
38 changes: 36 additions & 2 deletions peachjam/tests/test_documents.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,21 @@
from datetime import date

from cobalt.uri import FrbrUri
from django.test import TestCase

from peachjam.models import Book, CoreDocument, Country, Journal, Language
from peachjam.models import (
Book,
CoreDocument,
Country,
Gazette,
Journal,
Language,
get_country_and_locality,
)


class CoreDocumentTestCase(TestCase):
fixtures = ["tests/countries", "documents/sample_documents"]
fixtures = ["tests/countries", "tests/languages", "documents/sample_documents"]

def test_document_text_from_html(self):
doc = CoreDocument.objects.get(
Expand Down Expand Up @@ -116,3 +125,28 @@ def test_clean_content_html(self):
self.assertEqual(
doc.clean_content_html("""<div>test</div>"""), """<div>test</div>"""
)

def test_gazette(self):
frbr_uri = FrbrUri.parse(
"/akn/za/officialGazette/provincial-gazette/2024-09-13/3585/eng@2024-09-13"
)
country, locality = get_country_and_locality("za")

gazette = Gazette.objects.create(
**{
"expression_frbr_uri": frbr_uri.expression_uri(),
"jurisdiction": country,
"locality": locality,
"frbr_uri_doctype": frbr_uri.doctype,
"frbr_uri_subtype": frbr_uri.subtype,
"frbr_uri_actor": frbr_uri.actor,
"frbr_uri_number": frbr_uri.number,
"frbr_uri_date": frbr_uri.date,
"language": Language.objects.get(pk="en"),
"date": date.fromisoformat("2024-09-13"),
"title": "gazette title",
"publication": "Provincial Gazette",
"key": "key",
}
)
self.assertEqual(frbr_uri.expression_uri(), gazette.expression_frbr_uri)

0 comments on commit ea5ee96

Please sign in to comment.