Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TCCP: Fix phone number parsing #8505

Merged
merged 1 commit into from
Jul 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions cfgov/tccp/jinja2/tccp/includes/contact_info.html
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
{% if urls or phone_numbers -%}
{% if urls or phone_number -%}
<div class="o-contact-info">
{% for value in urls %}
{%- include "v1/includes/molecules/contact-hyperlink.html" -%}
{% endfor %}

{% for phone_number in phone_numbers %}
{% if phone_number %}
{% with value = {"phones": [{"number": phone_number}]} %}
{%- include "v1/includes/molecules/contact-phone.html" -%}
{% endwith %}
{%- endfor %}
{%- endif %}
</div>
{%- endif %}
5 changes: 2 additions & 3 deletions cfgov/tccp/jinja2tags.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,8 @@ def fmt_list(format_fn, value):
"urls": fmt_list(
_format_contact_website, card["website_for_consumer"]
),
"phone_numbers": fmt_list(
_format_contact_phone_number,
card["telephone_number_for_consumers"],
"phone_number": _format_contact_phone_number(
card["telephone_number_for_consumers"] or ""
),
}

Expand Down
3 changes: 2 additions & 1 deletion cfgov/tccp/tests/test_jinja2tags.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,11 +75,12 @@ def test_render(self):
html = render_contact_info(
{
"website_for_consumer": "https://example.com foo.com",
"telephone_number_for_consumers": "212-555-1234",
"telephone_number_for_consumers": "1 212-555-1234",
}
)

self.assertEqual(len(re.findall("m-contact-hyperlink", html)), 2)
self.assertIn('<a href="https://example.com">', html)
self.assertNotIn('<a href="foo.com">', html)
self.assertEqual(len(re.findall("m-contact-phone", html)), 1)
self.assertIn("2125551234", html)
Loading