diff --git a/notifications_utils/formatters.py b/notifications_utils/formatters.py index 330bde9c..0d5b70d3 100644 --- a/notifications_utils/formatters.py +++ b/notifications_utils/formatters.py @@ -33,6 +33,8 @@ TAG_IMG_IRCC_COAT_OF_ARMS = r"\[\[ircc-coat-arms\]\]" # matches [[ircc-coat-arms]] TAG_IMG_IRCC_GLOBAL_AFFAIRS = r"\[\[ircc-ga-seal\]\]" # matches [[ircc-ga-seal]] +TAG_IMG_IRCC_IRCC_SEAL = r"\[\[ircc-seal\]\]" # matches [[ircc-seal]] +TAG_IMG_IRCC_GC_SEAL = r"\[\[ircc-gc-seal\]\]" # matches [[ircc-gc-seal]] mistune._block_quote_leading_pattern = re.compile(r"^ *\^ ?", flags=re.M) mistune.BlockGrammar.block_quote = re.compile(r"^( *\^[^\n]+(\n[^\n]+)*\n*)+") @@ -670,6 +672,36 @@ def add_ircc_ga_seal(_content: str) -> str: return add_img_tag(_content, TAG_IMG_IRCC_GLOBAL_AFFAIRS, img_loc, alt_text, 295, 281) +def add_ircc_seal(_content: str) -> str: + """ + Custom parser to add IRCC seal logo. + + This is a custom temporary change not meant to exist for more than a few + weeks. This should either be removed or upgraded into a full-fledged + feature. + + TODO: Review, remove/upgrade this functionality. + """ + img_loc = "https://assets.notification.canada.ca/gc-ircc-seal.png" + alt_text = "Immigration, Refugees and Citizenship Canada / Immigration, Réfugiés et Citoyenneté Canada" + return add_img_tag(_content, TAG_IMG_IRCC_IRCC_SEAL, img_loc, alt_text, 295, 281) + + +def add_ircc_gc_seal(_content: str) -> str: + """ + Custom parser to add Government of Canada seal logo. + + This is a custom temporary change not meant to exist for more than a few + weeks. This should either be removed or upgraded into a full-fledged + feature. + + TODO: Review, remove/upgrade this functionality. + """ + img_loc = "https://assets.notification.canada.ca/gc-ircc-gc-seal.png" + alt_text = "Government of Canada / Gouvernement du Canada" + return add_img_tag(_content, TAG_IMG_IRCC_GC_SEAL, img_loc, alt_text, 295, 281) + + def add_ircc_coat_of_arms(_content: str) -> str: """ Custom parser to add IRCC coat of arms logo. diff --git a/notifications_utils/template.py b/notifications_utils/template.py index b5d8d2b6..946d978c 100644 --- a/notifications_utils/template.py +++ b/notifications_utils/template.py @@ -16,6 +16,8 @@ nl2li, add_ircc_coat_of_arms, add_ircc_ga_seal, + add_ircc_seal, + add_ircc_gc_seal, add_language_divs, add_prefix, add_newlines_around_lang_tags, @@ -753,6 +755,8 @@ def get_html_email_body(template_content, template_values, redact_missing_person .then(add_language_divs) .then(add_ircc_coat_of_arms) .then(add_ircc_ga_seal) + .then(add_ircc_seal) + .then(add_ircc_gc_seal) .then(do_nice_typography) ) diff --git a/notifications_utils/version.py b/notifications_utils/version.py index c9b8ad47..39d67450 100644 --- a/notifications_utils/version.py +++ b/notifications_utils/version.py @@ -1,2 +1,2 @@ -__version__ = "46.0.0" +__version__ = "46.1.0" # GDS version '34.0.1' diff --git a/tests/test_formatters.py b/tests/test_formatters.py index 78f4b8bb..1e83b22b 100644 --- a/tests/test_formatters.py +++ b/tests/test_formatters.py @@ -5,6 +5,8 @@ from notifications_utils.formatters import ( add_ircc_coat_of_arms, add_ircc_ga_seal, + add_ircc_seal, + add_ircc_gc_seal, add_language_divs, remove_language_divs, unlink_govuk_escaped, @@ -1014,6 +1016,48 @@ def test_add_ga_seal(input: str, output_dict: List[Dict]): assert "[[ircc-" not in parsed_input +@pytest.mark.parametrize( + "input,output_dict", + ( + ("abc 123", [{"string": "abc 123", "occurances": 1}]), + ( + "Hi,\n[[ircc-seal]]\nBye", + [{"string": "Hi,", "occurances": 1}, {"string": "