Skip to content

Commit 60ebab5

Browse files
authored
Merge pull request #2213 from laws-africa/pdf-notices
PDF notices
2 parents 93dd156 + d797501 commit 60ebab5

File tree

67 files changed

+6698
-5724
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

67 files changed

+6698
-5724
lines changed

indigo/locale/af/LC_MESSAGES/django.po

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -600,4 +600,3 @@ msgstr ""
600600
#: pipelines/text.py:30
601601
msgid "There is not enough text in the document to import. You may need to OCR the file first."
602602
msgstr ""
603-

indigo/locale/fr/LC_MESSAGES/django.po

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -646,4 +646,3 @@ msgstr "%s (vers être importé)"
646646
#: pipelines/text.py:30
647647
msgid "There is not enough text in the document to import. You may need to OCR the file first."
648648
msgstr "Il n'y a pas assez de texte dans le document pour l'importation. Vous pouvez avoir besoin de OCR le fichier d'abord."
649-

indigo/locale/nso/LC_MESSAGES/django.po

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -600,4 +600,3 @@ msgstr ""
600600
#: pipelines/text.py:30
601601
msgid "There is not enough text in the document to import. You may need to OCR the file first."
602602
msgstr ""
603-

indigo/locale/pl/LC_MESSAGES/django.po

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -600,4 +600,3 @@ msgstr ""
600600
#: pipelines/text.py:30
601601
msgid "There is not enough text in the document to import. You may need to OCR the file first."
602602
msgstr ""
603-

indigo/locale/pt/LC_MESSAGES/django.po

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -646,4 +646,3 @@ msgstr "%s (prestes a ser importado)"
646646
#: pipelines/text.py:30
647647
msgid "There is not enough text in the document to import. You may need to OCR the file first."
648648
msgstr "Não há texto suficiente no documento para importar. Talvez seja preciso primeiro fazer OCR ao ficheiro."
649-

indigo/locale/st/LC_MESSAGES/django.po

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -600,4 +600,3 @@ msgstr ""
600600
#: pipelines/text.py:30
601601
msgid "There is not enough text in the document to import. You may need to OCR the file first."
602602
msgstr ""
603-

indigo/locale/sw/LC_MESSAGES/django.po

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -646,4 +646,3 @@ msgstr "%s (inakaribia kuingizwa)"
646646
#: pipelines/text.py:30
647647
msgid "There is not enough text in the document to import. You may need to OCR the file first."
648648
msgstr "Hakuna maandishi ya kutosha katika hati ya kuleta. Huenda ukahitaji OCR faili kwanza."
649-

indigo/locale/tn/LC_MESSAGES/django.po

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -600,4 +600,3 @@ msgstr ""
600600
#: pipelines/text.py:30
601601
msgid "There is not enough text in the document to import. You may need to OCR the file first."
602602
msgstr ""
603-

indigo/locale/ts/LC_MESSAGES/django.po

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -600,4 +600,3 @@ msgstr ""
600600
#: pipelines/text.py:30
601601
msgid "There is not enough text in the document to import. You may need to OCR the file first."
602602
msgstr ""
603-

indigo/locale/ve/LC_MESSAGES/django.po

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -600,4 +600,3 @@ msgstr ""
600600
#: pipelines/text.py:30
601601
msgid "There is not enough text in the document to import. You may need to OCR the file first."
602602
msgstr ""
603-

indigo/locale/xh/LC_MESSAGES/django.po

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -600,4 +600,3 @@ msgstr ""
600600
#: pipelines/text.py:30
601601
msgid "There is not enough text in the document to import. You may need to OCR the file first."
602602
msgstr ""
603-

indigo/locale/zu/LC_MESSAGES/django.po

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -600,4 +600,3 @@ msgstr ""
600600
#: pipelines/text.py:30
601601
msgid "There is not enough text in the document to import. You may need to OCR the file first."
602602
msgstr ""
603-

indigo_api/exporters.py

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import datetime
12
import logging
23
import math
34
import os
@@ -228,6 +229,7 @@ def get_static_content_context(self, document):
228229
'document': document,
229230
'ns': document.doc.namespace,
230231
'place_string': self.get_place_string(document),
232+
'notices': self.get_notices(document, short=True),
231233
}
232234

233235
def get_place_string(self, document):
@@ -269,8 +271,56 @@ def get_frontmatter_context(self, document):
269271
'toc': toc,
270272
'include_country': document.country not in self.dont_include_countries,
271273
'place_string': self.get_place_string(document),
274+
'notices': self.get_notices(document),
272275
}
273276

277+
def get_notices(self, document, short=False):
278+
work = document.work
279+
notices = []
280+
281+
if short:
282+
# we only care if it's uncommenced and/or repealed for the running header
283+
if not work.commenced and work.repealed_date:
284+
return _('Not commenced; Repealed')
285+
if not work.commenced:
286+
return _('Not commenced')
287+
if work.repealed_date:
288+
return _('Repealed')
289+
return
290+
291+
# repeal
292+
if work.repealed_date:
293+
notice = _('This %(friendly_type)s was <b>repealed</b> on %(date)s by <ref href="%(url)s">%(work)s</ref>') % {
294+
'friendly_type': work.friendly_type(), 'date': work.repealed_date, 'work': work.repealed_by.title, 'url': work.repealed_by.frbr_uri}
295+
notice += f' ({work.repealed_by.numbered_title()}).' if work.repealed_by.numbered_title() else '.'
296+
notices.append(notice)
297+
298+
# commencement
299+
if not work.commenced:
300+
notices.append(_('This %(friendly_type)s has <b>not yet come into force</b>.') % {'friendly_type': work.friendly_type()})
301+
# no notice for an unknown commencement date (commenced is True but there are no commencements)
302+
elif work.commencements.exists():
303+
latest_commencement_date = work.latest_commencement_date()
304+
if work.all_uncommenced_provision_ids(date=document.expression_date, return_bool=True):
305+
notices.append(_('This %(friendly_type)s has not yet come into force in full. '
306+
'See the commencements table for more information.') % {'friendly_type': work.friendly_type()})
307+
# no notice for a future commencement if the work also hasn't commenced in full
308+
elif latest_commencement_date > datetime.date.today():
309+
notices.append(_('This %(friendly_type)s will come into force on %(date)s.') % {'friendly_type': work.friendly_type(), 'date': latest_commencement_date})
310+
311+
# not the latest expression / amendments outstanding
312+
later_amendments = work.amendments_after_date(document.expression_date)
313+
if not document.is_latest_expression():
314+
notices.append(_('This is not the latest available version of this %(friendly_type)s. '
315+
'<ref href="%(url)s">View it online</ref>.') % {'friendly_type': work.friendly_type(), 'url': work.frbr_uri})
316+
# no notice for outstanding amendments if this also isn't the latest expression
317+
elif later_amendments:
318+
numbered_titles = ', '.join(a.amending_work.numbered_title() or a.amending_work.short_title for a in later_amendments)
319+
notices.append(_('There are <b>outstanding amendments</b> that have not yet been applied:<br/>'
320+
'%(numbered_titles)s.') % {'numbered_titles': numbered_titles})
321+
322+
return notices
323+
274324
def get_base_toc(self, document):
275325
return document.table_of_contents()
276326

0 commit comments

Comments
 (0)