From 0aafe98be98c3b78fab69d254aedd305c9f1fef3 Mon Sep 17 00:00:00 2001 From: Phil Dominguez <142051477+phildominguez-gsa@users.noreply.github.com> Date: Thu, 5 Sep 2024 12:29:17 -0400 Subject: [PATCH 1/2] Handling emails with invalid characters (#4245) * Handling bad emails for user roles page * Filling in name/email inputs * Creating get_user_role_management_context * Lint * Removing duplicate code * Validating emails for step 3 * Lint * Fixing unit test * Email validation for gen form * Fixing unit test * Adding 'scroll down' messages * Remembering auditee and auditor step 3 info * Fixing some field values * Lint * Forgot to add this --- backend/api/views.py | 22 +++++- .../manage-submission-change-access.html | 23 +++--- .../audit/views/manage_submission_access.py | 77 ++++++++++++------- backend/report_submission/forms.py | 4 +- .../templates/report_submission/step-3.html | 35 +++++++-- backend/report_submission/test_views.py | 5 +- backend/report_submission/views.py | 13 ++-- 7 files changed, 122 insertions(+), 57 deletions(-) diff --git a/backend/api/views.py b/backend/api/views.py index 43f5c10ee1..275328a1f6 100644 --- a/backend/api/views.py +++ b/backend/api/views.py @@ -183,7 +183,27 @@ def access_and_submission_check(user, data): return {"report_id": sac.report_id, "next": "TBD"} - return {"errors": serializer.errors} + return { + "errors": serializer.errors, + "certifying_auditee_contact_fullname": data.get( + "certifying_auditee_contact_fullname" + ), + "certifying_auditee_contact_email": data.get( + "certifying_auditee_contact_email" + ), + "certifying_auditee_contact_re_email": data.get( + "certifying_auditee_contact_re_email" + ), + "certifying_auditor_contact_fullname": data.get( + "certifying_auditor_contact_fullname" + ), + "certifying_auditor_contact_email": data.get( + "certifying_auditor_contact_email" + ), + "certifying_auditor_contact_re_email": data.get( + "certifying_auditor_contact_re_email" + ), + } class Sprite(generic.View): diff --git a/backend/audit/templates/audit/manage-submission-change-access.html b/backend/audit/templates/audit/manage-submission-change-access.html index 61216e7ddc..ad07e07967 100644 --- a/backend/audit/templates/audit/manage-submission-change-access.html +++ b/backend/audit/templates/audit/manage-submission-change-access.html @@ -31,23 +31,26 @@

Add Audit Editor

For the changes to take effect, users must log out and log back in to their account.

{% endif %} - -
- {% if errors %} - + There were errors when attempting to submit the form. Scroll down for more details. {% endif %} - + +
+ - - + + + placeholder="[email address]" + value="{{ email }}"/> + {{ errors.email }} * Indicates a required field.

+ {% if errors %} + There were errors when attempting to submit the form. Scroll down for more details. + {% endif %}
@@ -46,7 +49,8 @@ aria-required="true" required data-validate-not-null="" - data-validate-length="<= 100 >= 2"/> + data-validate-length="<= 100 >= 2" + value="{{ certifying_auditee_contact_fullname | default_if_none:'' }}" />
@@ -74,7 +78,8 @@ data-validate-not-null="" data-validate-email="" data-validate-must-not-match="certifying_auditor_contact_email" - data-validate-length="<= 340 >= 6"/> + data-validate-length="<= 340 >= 6" + value="{{ certifying_auditee_contact_email | default_if_none:'' }}" />
@@ -95,10 +100,14 @@ aria-required="true" required data-validate-must-match="certifying_auditee_contact_email" - data-validate-length="<= 340 >= 6"/> + data-validate-length="<= 340 >= 6" + value="{{ certifying_auditee_contact_re_email | default_if_none:'' }}" />
+ {% if errors.certifying_auditee_contact_email %} + Enter a valid email address. + {% endif %}
@@ -130,7 +139,8 @@ aria-required="true" required data-validate-not-null="" - data-validate-length="<= 100 >= 2"/> + data-validate-length="<= 100 >= 2" + value="{{ certifying_auditor_contact_fullname | default_if_none:'' }}" />
@@ -158,7 +168,8 @@ data-validate-not-null="" data-validate-email="" data-validate-must-not-match="certifying_auditee_contact_email" - data-validate-length="<= 340 >= 6"/> + data-validate-length="<= 340 >= 6" + value="{{ certifying_auditor_contact_email | default_if_none:'' }}" />
@@ -179,13 +190,17 @@ aria-required="true" required data-validate-must-match="certifying_auditor_contact_email" - data-validate-length="<= 340 >= 6"/> + data-validate-length="<= 340 >= 6" + value="{{ certifying_auditor_contact_re_email | default_if_none:'' }}" />
+ {% if errors.certifying_auditor_contact_email %} + Enter a valid email address. + {% endif %} - +
@@ -255,6 +270,9 @@ + {% if errors.auditee_contacts_email %} + Enter a valid email address. + {% endif %}