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

DST-886 - RaB - Add name and business to end-user summary #294

Merged
merged 3 commits into from
Jan 10, 2025
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
Original file line number Diff line number Diff line change
Expand Up @@ -228,83 +228,95 @@ <h3 class="govuk-heading-s">Supplier</h3>
</dl>
{% if form_data.end_users %}
{% for end_user, value in form_data.end_users.items %}
<div class="action-wrapper">
<h3 class="govuk-heading-s" style="float:left">End-user {{ forloop.counter }}</h3>
<dl class="govuk-summary-card__actions">
<dd class="govuk-summary-list__action govuk-!-font-weight-regular">

{% if is_made_available_journey %}
<a class="govuk-link" style="font-size: 19px; text-align:right"
href="{% url 'report_a_suspected_breach:where_were_the_goods_made_available_to_end_user_uuid' end_user_uuid=end_user %}?redirect_to_url=report_a_suspected_breach:check_your_answers">Change<span
class="govuk-visually-hidden">end-user {{forloop.counter}} details</span></a>
{% else %}
<a class="govuk-link" style="font-size: 19px; text-align:right"
href="{% url 'report_a_suspected_breach:where_were_the_goods_supplied_to_end_user_uuid' end_user_uuid=end_user %}?redirect_to_url=report_a_suspected_breach:check_your_answers">Change<span
class="govuk-visually-hidden">end-user {{forloop.counter}} details</span></a>
{% endif %}
</dd>
<dd class="govuk-summary-list__action">
<form id="delete_end_user_form_{{ forloop.counter }}" method="post" enctype='multipart/form-data' novalidate
action="{% url 'report_a_suspected_breach:delete_end_user' %}?end_user_uuid={{ end_user }}&success_url=check_your_answers">
<input type="hidden" name="end_user_uuid" value="{{ end_user }}">
<input type="hidden" name="success_url" value = "check_your_answers">
{% csrf_token %}
<button type="submit" class="govuk-link button-that-looks-like-link" form="delete_end_user_form_{{ forloop.counter }}">
Remove<span
class="govuk-visually-hidden">end-user {{forloop.counter}} details</span>
</button>
</form>
</dd>
</dl>
</div>
<dl class="govuk-summary-list">
<div class="govuk-summary-list__row">
<dt class="govuk-summary-list__key govuk-!-font-weight-regular">
Name
</dt>
<dd class="govuk-summary-list__value">
{{ value.cleaned_data.name_of_person }}
</dd>
</div>
<div class="govuk-summary-list__row">
<dt class="govuk-summary-list__key govuk-!-font-weight-regular">
Business
</dt>
<dd class="govuk-summary-list__value">
{{ value.cleaned_data.name_of_business }}
</dd>
</div>
<div class="govuk-summary-list__row">
<dt class="govuk-summary-list__key govuk-!-font-weight-regular">
Address
</dt>
<dd class="govuk-summary-list__value">
{% include "report_a_suspected_breach/partials/truncated_text.html" with text=value.cleaned_data.readable_address|linebreaksbr %}
</dd>
<div data-testid="end-user-{{ forloop.counter }}">
<div class="action-wrapper">
<h3 class="govuk-heading-s" style="float:left">End-user {{ forloop.counter }}</h3>
<dl class="govuk-summary-card__actions">
<dd class="govuk-summary-list__action govuk-!-font-weight-regular">
{% if is_made_available_journey %}
<a class="govuk-link" style="font-size: 19px; text-align:right"
href="{% url 'report_a_suspected_breach:where_were_the_goods_made_available_to_end_user_uuid' end_user_uuid=end_user %}?redirect_to_url=report_a_suspected_breach:check_your_answers">Change<span
class="govuk-visually-hidden">end-user {{forloop.counter}} details</span></a>
{% else %}
<a class="govuk-link" style="font-size: 19px; text-align:right"
href="{% url 'report_a_suspected_breach:where_were_the_goods_supplied_to_end_user_uuid' end_user_uuid=end_user %}?redirect_to_url=report_a_suspected_breach:check_your_answers">Change<span
class="govuk-visually-hidden">end-user {{forloop.counter}} details</span></a>
{% endif %}
</dd>
<dd class="govuk-summary-list__action">
<form id="delete_end_user_form_{{ forloop.counter }}" method="post" enctype='multipart/form-data' novalidate
action="{% url 'report_a_suspected_breach:delete_end_user' %}?end_user_uuid={{ end_user }}&success_url=check_your_answers">
<input type="hidden" name="end_user_uuid" value="{{ end_user }}">
<input type="hidden" name="success_url" value = "check_your_answers">
{% csrf_token %}
<button type="submit" class="govuk-link button-that-looks-like-link" form="delete_end_user_form_{{ forloop.counter }}">
Remove<span class="govuk-visually-hidden">end-user {{forloop.counter}} details</span>
</button>
</form>
</dd>
</dl>
</div>
{% if value.cleaned_data.website %}
<dl class="govuk-summary-list">
<div class="govuk-summary-list__row">
<dt class="govuk-summary-list__key govuk-!-font-weight-regular">
Website
Name
</dt>
<dd class="govuk-summary-list__value">
<a class="govuk-link"
href="{{ value.cleaned_data.website }}">{{ value.cleaned_data.website }}<span
class="govuk-visually-hidden"></span></a>
{% if value.cleaned_data.name_of_person %}
{{ value.cleaned_data.name_of_person }}
{% else %}
Not provided
{% endif %}
</dd>
</div>
{% endif %}
{% if value.cleaned_data.additional_contact_details %}
<div class="govuk-summary-list__row">
<dt class="govuk-summary-list__key govuk-!-font-weight-regular">
Additional contact information
Business
</dt>
<dd class="govuk-summary-list__value">
{% include "report_a_suspected_breach/partials/truncated_text.html" with text=value.cleaned_data.additional_contact_details|linebreaksbr %}
{% if value.cleaned_data.name_of_business %}
{{ value.cleaned_data.name_of_business }}
{% else %}
Not provided
{% endif %}
</dd>
</div>
{% endif %}
</dl>
<div class="govuk-summary-list__row">
<dt class="govuk-summary-list__key govuk-!-font-weight-regular">
Address
</dt>
<dd class="govuk-summary-list__value">
{% if value.cleaned_data.readable_address %}
{% include "report_a_suspected_breach/partials/truncated_text.html" with text=value.cleaned_data.readable_address|linebreaksbr %}
{% else %}
Not provided
{% endif %}
</dd>
</div>
{% if value.cleaned_data.website %}
<div class="govuk-summary-list__row">
<dt class="govuk-summary-list__key govuk-!-font-weight-regular">
Website
</dt>
<dd class="govuk-summary-list__value">
<a class="govuk-link"
href="{{ value.cleaned_data.website }}">{{ value.cleaned_data.website }}<span
class="govuk-visually-hidden"></span></a>
</dd>
</div>
{% endif %}
{% if value.cleaned_data.additional_contact_details %}
<div class="govuk-summary-list__row">
<dt class="govuk-summary-list__key govuk-!-font-weight-regular">
Additional contact information
</dt>
<dd class="govuk-summary-list__value">
{% include "report_a_suspected_breach/partials/truncated_text.html" with text=value.cleaned_data.additional_contact_details|linebreaksbr %}
</dd>
</div>
{% endif %}
</dl>
</div>
{% endfor %}
{% else %}
<h3 class="govuk-heading-s" style="float:left">End-users</h3>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -193,15 +193,16 @@ <h3 class="govuk-heading-s">End-user {{ forloop.counter }}</h3>
Address
</dt>
<dd class="govuk-summary-list__value">
{% if end_user.address %}
{% include "report_a_suspected_breach/partials/truncated_text.html" with text=end_user.address|linebreaksbr %}
{% else %}
Not provided
{% endif %}
{% with readable_address=end_user.get_readable_address %}
{% if readable_address %}
{% include "report_a_suspected_breach/partials/truncated_text.html" with text=readable_address|linebreaksbr %}
{% else %}
Not provided
{% endif %}
{% endwith %}
</dd>
</div>
{% if end_user.website %}

<div class="govuk-summary-list__row">
<dt class="govuk-summary-list__key govuk-!-font-weight-regular">
Website
Expand Down
8 changes: 6 additions & 2 deletions django_app/utils/address_formatter.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,11 @@ def get_formatted_address(address_dict: AddressData) -> str:
address_string += f",\n {postal_code}"

if country_code := address_dict.get("country"):
country = countries.name(country_code)
address_string += f",\n {country}"
if address_string:
# we only want to add the country if the address string already contains something, as country is added
# by the backend in UK cases, so we end up with something strange-looking like
# , United Kingdom
country = countries.name(country_code)
address_string += f",\n {country}"

return address_string
Original file line number Diff line number Diff line change
Expand Up @@ -349,6 +349,14 @@ def test_can_add_another_end_user(self):
self.page.get_by_role("link", name="Continue").click()
self.declaration_and_complete_page(self.page)

def test_empty_address_business_name_doesnt_display(self):
self.page.goto(self.base_url)
breach = breach_details_owner.copy()
breach["end_users"] = ["end_user1", "end_user2", "end_user3"]
self.create_breach(self.page, breach)
assert self.page.get_by_test_id("end-user-2").text_content().count("Not provided") == 2
assert self.page.get_by_test_id("end-user-3").text_content().count("Not provided") == 0


class TestCheckYourAnswersSanctionsBreachDetails(conftest.PlaywrightTestBase):
"""
Expand Down
Loading