From 32c138032bf20cad5f51bf458d07bbd743394ae2 Mon Sep 17 00:00:00 2001 From: zandercymatics <141044360+zandercymatics@users.noreply.github.com> Date: Wed, 3 Jan 2024 15:11:42 -0700 Subject: [PATCH 001/137] Rough mock --- src/registrar/assets/sass/_theme/_tables.scss | 4 ++++ src/registrar/templates/domain_users.html | 23 +++++++++++++++++++ src/registrar/views/domain.py | 15 ++++++++++++ 3 files changed, 42 insertions(+) diff --git a/src/registrar/assets/sass/_theme/_tables.scss b/src/registrar/assets/sass/_theme/_tables.scss index 6dcc6f3bc..892427f82 100644 --- a/src/registrar/assets/sass/_theme/_tables.scss +++ b/src/registrar/assets/sass/_theme/_tables.scss @@ -25,6 +25,10 @@ color: color('primary-darker'); padding-bottom: units(2px); } + td.shift-action-button { + padding-right: 0; + transform: translateX(10px); + } } .dotgov-table { diff --git a/src/registrar/templates/domain_users.html b/src/registrar/templates/domain_users.html index 0eecd35b3..147c0bb8e 100644 --- a/src/registrar/templates/domain_users.html +++ b/src/registrar/templates/domain_users.html @@ -31,6 +31,7 @@ Email Role + Action @@ -40,6 +41,28 @@ {{ permission.user.email }} {{ permission.role|title }} + + Remove + {# Use data-force-action to take esc out of the equation and pass cancel_button_resets_ds_form to effectuate a reset in the view #} +
+
+ {% include 'includes/modal.html' with modal_heading="Warning: You are about to remove all DS records on your domain" modal_description="To fully disable DNSSEC: In addition to removing your DS records here you’ll also need to delete the DS records at your DNS host. To avoid causing your domain to appear offline you should wait to delete your DS records at your DNS host until the Time to Live (TTL) expires. This is often less than 24 hours, but confirm with your provider." modal_button=modal_button|safe %} +
+
+ {% endfor %} diff --git a/src/registrar/views/domain.py b/src/registrar/views/domain.py index 59b206993..aaad016a7 100644 --- a/src/registrar/views/domain.py +++ b/src/registrar/views/domain.py @@ -625,6 +625,21 @@ class DomainUsersView(DomainBaseView): template_name = "domain_users.html" + def get_context_data(self, **kwargs): + """The initial value for the form (which is a formset here).""" + context = super().get_context_data(**kwargs) + + # Create HTML for the modal button + modal_button = ( + '' + ) + + context["modal_button"] = modal_button + + return context + class DomainAddUserView(DomainFormBaseView): """Inside of a domain's user management, a form for adding users. From 64687ea7862f230b90263d98ef0d34602b0fb98b Mon Sep 17 00:00:00 2001 From: zandercymatics <141044360+zandercymatics@users.noreply.github.com> Date: Thu, 4 Jan 2024 10:27:51 -0700 Subject: [PATCH 002/137] Some view logic --- src/registrar/config/urls.py | 5 +++ src/registrar/templates/domain_users.html | 6 ++-- src/registrar/views/__init__.py | 1 + src/registrar/views/domain.py | 13 ++++++++ src/registrar/views/utility/mixins.py | 30 ++++++++++++++++++ .../views/utility/permission_views.py | 31 +++++++++++++++++++ 6 files changed, 84 insertions(+), 2 deletions(-) diff --git a/src/registrar/config/urls.py b/src/registrar/config/urls.py index 607bf5f61..416cb7c36 100644 --- a/src/registrar/config/urls.py +++ b/src/registrar/config/urls.py @@ -138,6 +138,11 @@ urlpatterns = [ views.DomainInvitationDeleteView.as_view(http_method_names=["post"]), name="invitation-delete", ), + path( + "domain//users//delete", + views.DomainDeleteUserView.as_view(http_method_names=["post"]), + name="domain-user-delete", + ), ] # we normally would guard these with `if settings.DEBUG` but tests run with diff --git a/src/registrar/templates/domain_users.html b/src/registrar/templates/domain_users.html index 147c0bb8e..22ef88533 100644 --- a/src/registrar/templates/domain_users.html +++ b/src/registrar/templates/domain_users.html @@ -58,8 +58,10 @@ aria-describedby="Your DNSSEC records will be deleted from the registry." data-force-action > -
- {% include 'includes/modal.html' with modal_heading="Warning: You are about to remove all DS records on your domain" modal_description="To fully disable DNSSEC: In addition to removing your DS records here you’ll also need to delete the DS records at your DNS host. To avoid causing your domain to appear offline you should wait to delete your DS records at your DNS host until the Time to Live (TTL) expires. This is often less than 24 hours, but confirm with your provider." modal_button=modal_button|safe %} + + {% with heading="Are you sure you want to remove <"|add:permission.user.email|add:">?" %} + {% include 'includes/modal.html' with modal_heading=heading modal_description="<"|add:permission.user.email|add:"> will no longer be able to manage the domain "|add:domain.name|add:"." modal_button=modal_button|safe %} + {% endwith %}
diff --git a/src/registrar/views/__init__.py b/src/registrar/views/__init__.py index c1400d7c0..8785c9076 100644 --- a/src/registrar/views/__init__.py +++ b/src/registrar/views/__init__.py @@ -12,6 +12,7 @@ from .domain import ( DomainUsersView, DomainAddUserView, DomainInvitationDeleteView, + DomainDeleteUserView, ) from .health import * from .index import * diff --git a/src/registrar/views/domain.py b/src/registrar/views/domain.py index aaad016a7..8884f9436 100644 --- a/src/registrar/views/domain.py +++ b/src/registrar/views/domain.py @@ -33,6 +33,7 @@ from registrar.utility.errors import ( SecurityEmailErrorCodes, ) from registrar.models.utility.contact_error import ContactError +from registrar.views.utility.permission_views import UserDomainRolePermissionView from ..forms import ( ContactForm, @@ -753,3 +754,15 @@ class DomainInvitationDeleteView(DomainInvitationPermissionDeleteView, SuccessMe def get_success_message(self, cleaned_data): return f"Successfully canceled invitation for {self.object.email}." + + +class DomainDeleteUserView(UserDomainRolePermissionView, SuccessMessageMixin): + """Inside of a domain's user management, a form for deleting users. + """ + object: UserDomainRole # workaround for type mismatch in DeleteView + + def get_success_url(self): + return reverse("domain-users", kwargs={"pk": self.object.domain.id}) + + def get_success_message(self, cleaned_data): + return f"Successfully removed manager for {self.object.email}." diff --git a/src/registrar/views/utility/mixins.py b/src/registrar/views/utility/mixins.py index 0cf5970df..af8f66279 100644 --- a/src/registrar/views/utility/mixins.py +++ b/src/registrar/views/utility/mixins.py @@ -286,6 +286,36 @@ class DomainApplicationPermission(PermissionsLoginMixin): return True +class UserDomainRolePermission(PermissionsLoginMixin): + + """Permission mixin for UserDomainRole if user + has access, otherwise 403""" + + def has_permission(self): + """Check if this user has access to this domain application. + + The user is in self.request.user and the domain needs to be looked + up from the domain's primary key in self.kwargs["pk"] + """ + domain_pk = self.kwargs["pk"] + user_pk = self.kwargs["user_pk"] + print(f"here is the user: {self.request.user} and kwargs: {domain_pk}") + if not self.request.user.is_authenticated: + return False + print("User was authenticated!") + x = UserDomainRole.objects.filter( + id=user_pk + ).get() + print(x) + # TODO - exclude the creator from this + if not UserDomainRole.objects.filter( + domain__id=domain_pk, domain__permissions__user=self.request.user + ).exists(): + return False + + return True + + class DomainApplicationPermissionWithdraw(PermissionsLoginMixin): """Permission mixin that redirects to withdraw action on domain application diff --git a/src/registrar/views/utility/permission_views.py b/src/registrar/views/utility/permission_views.py index 1798ec79d..5c5ebc494 100644 --- a/src/registrar/views/utility/permission_views.py +++ b/src/registrar/views/utility/permission_views.py @@ -4,6 +4,7 @@ import abc # abstract base class from django.views.generic import DetailView, DeleteView, TemplateView from registrar.models import Domain, DomainApplication, DomainInvitation +from registrar.models.user_domain_role import UserDomainRole from .mixins import ( DomainPermission, @@ -11,6 +12,7 @@ from .mixins import ( DomainApplicationPermissionWithdraw, DomainInvitationPermission, ApplicationWizardPermission, + UserDomainRolePermission, ) import logging @@ -122,3 +124,32 @@ class DomainInvitationPermissionDeleteView(DomainInvitationPermission, DeleteVie model = DomainInvitation object: DomainInvitation # workaround for type mismatch in DeleteView + + +class UserDomainRolePermissionView(UserDomainRolePermission, DetailView, abc.ABC): + + """Abstract base view for UserDomainRole that enforces permissions. + + This abstract view cannot be instantiated. Actual views must specify + `template_name`. + """ + + # DetailView property for what model this is viewing + model = UserDomainRole + # variable name in template context for the model object + context_object_name = "userdomainrole" + + +class UserDomainRolePermissionDeleteView(UserDomainRolePermissionView, DeleteView, abc.ABC): + + """Abstract base view for domain application withdraw function + + This abstract view cannot be instantiated. Actual views must specify + `template_name`. + """ + + # DetailView property for what model this is viewing + model = UserDomainRole + # variable name in template context for the model object + context_object_name = "userdomainrole" + From 1710c902da22c7168cef3b1ee861984ed4f17a70 Mon Sep 17 00:00:00 2001 From: zandercymatics <141044360+zandercymatics@users.noreply.github.com> Date: Thu, 4 Jan 2024 11:39:47 -0700 Subject: [PATCH 003/137] Add delete --- src/registrar/views/domain.py | 10 ++++++++-- src/registrar/views/utility/mixins.py | 10 +++------- 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/src/registrar/views/domain.py b/src/registrar/views/domain.py index 8884f9436..80cc50a1d 100644 --- a/src/registrar/views/domain.py +++ b/src/registrar/views/domain.py @@ -33,7 +33,7 @@ from registrar.utility.errors import ( SecurityEmailErrorCodes, ) from registrar.models.utility.contact_error import ContactError -from registrar.views.utility.permission_views import UserDomainRolePermissionView +from registrar.views.utility.permission_views import UserDomainRolePermissionDeleteView, UserDomainRolePermissionView from ..forms import ( ContactForm, @@ -756,11 +756,17 @@ class DomainInvitationDeleteView(DomainInvitationPermissionDeleteView, SuccessMe return f"Successfully canceled invitation for {self.object.email}." -class DomainDeleteUserView(UserDomainRolePermissionView, SuccessMessageMixin): +class DomainDeleteUserView(UserDomainRolePermissionDeleteView, SuccessMessageMixin): """Inside of a domain's user management, a form for deleting users. """ object: UserDomainRole # workaround for type mismatch in DeleteView + def get_object(self, queryset=None): + """Custom get_object definition to grab a UserDomainRole object from a domain_id and user_id""" + domain_id = self.kwargs.get('pk') + user_id = self.kwargs.get('user_pk') + return UserDomainRole.objects.get(domain=domain_id, user=user_id) + def get_success_url(self): return reverse("domain-users", kwargs={"pk": self.object.domain.id}) diff --git a/src/registrar/views/utility/mixins.py b/src/registrar/views/utility/mixins.py index af8f66279..ca5dceeb8 100644 --- a/src/registrar/views/utility/mixins.py +++ b/src/registrar/views/utility/mixins.py @@ -299,17 +299,13 @@ class UserDomainRolePermission(PermissionsLoginMixin): """ domain_pk = self.kwargs["pk"] user_pk = self.kwargs["user_pk"] - print(f"here is the user: {self.request.user} and kwargs: {domain_pk}") + if not self.request.user.is_authenticated: return False - print("User was authenticated!") - x = UserDomainRole.objects.filter( - id=user_pk - ).get() - print(x) + # TODO - exclude the creator from this if not UserDomainRole.objects.filter( - domain__id=domain_pk, domain__permissions__user=self.request.user + user=user_pk, domain=domain_pk ).exists(): return False From b0d05dd5df386143fc1a798f8c1e7941660ba74b Mon Sep 17 00:00:00 2001 From: zandercymatics <141044360+zandercymatics@users.noreply.github.com> Date: Thu, 4 Jan 2024 12:52:49 -0700 Subject: [PATCH 004/137] Update mixins.py --- src/registrar/views/utility/mixins.py | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/src/registrar/views/utility/mixins.py b/src/registrar/views/utility/mixins.py index ca5dceeb8..bfa9d7330 100644 --- a/src/registrar/views/utility/mixins.py +++ b/src/registrar/views/utility/mixins.py @@ -300,13 +300,26 @@ class UserDomainRolePermission(PermissionsLoginMixin): domain_pk = self.kwargs["pk"] user_pk = self.kwargs["user_pk"] + # Check if the user is authenticated if not self.request.user.is_authenticated: return False - # TODO - exclude the creator from this - if not UserDomainRole.objects.filter( - user=user_pk, domain=domain_pk - ).exists(): + # Check if the UserDomainRole object exists, then check + # if the user requesting the delete has permissions to do so + has_delete_permission = UserDomainRole.objects.filter( + user=user_pk, + domain=domain_pk, + domain__permissions__user=self.request.user, + ).exists() + if not has_delete_permission: + return False + + # Check if more than one manager exists on the domain. + # If only one exists, prevent this from happening + has_multiple_managers = len(UserDomainRole.objects.filter( + domain=domain_pk + )) > 1 + if not has_multiple_managers: return False return True From 232a3e2d06820b0f72c54f98411c98353cac1ba4 Mon Sep 17 00:00:00 2001 From: zandercymatics <141044360+zandercymatics@users.noreply.github.com> Date: Thu, 4 Jan 2024 13:09:04 -0700 Subject: [PATCH 005/137] Add success message --- src/registrar/views/domain.py | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/src/registrar/views/domain.py b/src/registrar/views/domain.py index 80cc50a1d..da81ba6a3 100644 --- a/src/registrar/views/domain.py +++ b/src/registrar/views/domain.py @@ -756,19 +756,26 @@ class DomainInvitationDeleteView(DomainInvitationPermissionDeleteView, SuccessMe return f"Successfully canceled invitation for {self.object.email}." -class DomainDeleteUserView(UserDomainRolePermissionDeleteView, SuccessMessageMixin): +class DomainDeleteUserView(UserDomainRolePermissionDeleteView): """Inside of a domain's user management, a form for deleting users. """ object: UserDomainRole # workaround for type mismatch in DeleteView def get_object(self, queryset=None): """Custom get_object definition to grab a UserDomainRole object from a domain_id and user_id""" - domain_id = self.kwargs.get('pk') - user_id = self.kwargs.get('user_pk') + domain_id = self.kwargs.get("pk") + user_id = self.kwargs.get("user_pk") return UserDomainRole.objects.get(domain=domain_id, user=user_id) def get_success_url(self): return reverse("domain-users", kwargs={"pk": self.object.domain.id}) def get_success_message(self, cleaned_data): - return f"Successfully removed manager for {self.object.email}." + return f"Successfully removed manager for {self.object.user.email}." + + def form_valid(self, form): + """Delete the specified user on this domain.""" + super().form_valid(form) + messages.success(self.request, f"Successfully removed manager for {self.object.user.email}.") + + return redirect(self.get_success_url()) \ No newline at end of file From 9d11653386670edfe9b4660e70aeb9ba29741ff7 Mon Sep 17 00:00:00 2001 From: zandercymatics <141044360+zandercymatics@users.noreply.github.com> Date: Thu, 4 Jan 2024 13:14:44 -0700 Subject: [PATCH 006/137] Update domain_users.html --- src/registrar/templates/domain_users.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/registrar/templates/domain_users.html b/src/registrar/templates/domain_users.html index 22ef88533..20079f64f 100644 --- a/src/registrar/templates/domain_users.html +++ b/src/registrar/templates/domain_users.html @@ -55,7 +55,7 @@ class="usa-modal" id="toggle-user-alert-{{ forloop.counter }}" aria-labelledby="Are you sure you want to continue?" - aria-describedby="Your DNSSEC records will be deleted from the registry." + aria-describedby="User will be removed" data-force-action >
From 01a6de2392307a9a580e5150a629ee0fc0649fd4 Mon Sep 17 00:00:00 2001 From: zandercymatics <141044360+zandercymatics@users.noreply.github.com> Date: Thu, 4 Jan 2024 13:53:59 -0700 Subject: [PATCH 007/137] Clean up html --- src/registrar/templates/domain_users.html | 43 ++++++++++++----------- 1 file changed, 22 insertions(+), 21 deletions(-) diff --git a/src/registrar/templates/domain_users.html b/src/registrar/templates/domain_users.html index 20079f64f..b6798ac16 100644 --- a/src/registrar/templates/domain_users.html +++ b/src/registrar/templates/domain_users.html @@ -43,27 +43,28 @@ {{ permission.role|title }} Remove - {# Use data-force-action to take esc out of the equation and pass cancel_button_resets_ds_form to effectuate a reset in the view #} -
- - {% with heading="Are you sure you want to remove <"|add:permission.user.email|add:">?" %} - {% include 'includes/modal.html' with modal_heading=heading modal_description="<"|add:permission.user.email|add:"> will no longer be able to manage the domain "|add:domain.name|add:"." modal_button=modal_button|safe %} - {% endwith %} - -
+ id="button-toggle-user-alert-{{ forloop.counter }}" + href="#toggle-user-alert-{{ forloop.counter }}" + class="usa-button--unstyled" + aria-controls="toggle-user-alert-{{ forloop.counter }}" + data-open-modal + > + Remove + + +
+
+ {% with heading="Are you sure you want to remove <"|add:permission.user.email|add:">?" %} + {% include 'includes/modal.html' with modal_heading=heading modal_description="<"|add:permission.user.email|add:"> will no longer be able to manage the domain "|add:domain.name|add:"." modal_button=modal_button|safe %} + {% endwith %} +
+
{% endfor %} From 4c2718654585b1a3734bfd593f8133cff48737bf Mon Sep 17 00:00:00 2001 From: zandercymatics <141044360+zandercymatics@users.noreply.github.com> Date: Mon, 8 Jan 2024 09:59:24 -0700 Subject: [PATCH 008/137] Add conditional logic --- src/registrar/templates/domain_users.html | 54 ++++++++++++----------- src/registrar/views/domain.py | 9 ++++ 2 files changed, 38 insertions(+), 25 deletions(-) diff --git a/src/registrar/templates/domain_users.html b/src/registrar/templates/domain_users.html index b6798ac16..5375b45e8 100644 --- a/src/registrar/templates/domain_users.html +++ b/src/registrar/templates/domain_users.html @@ -31,7 +31,9 @@ Email Role - Action + {% if can_delete_users %} + Action + {% endif %} @@ -41,31 +43,33 @@ {{ permission.user.email }} {{ permission.role|title }} - - - Remove - + {% if can_delete_users %} + + + Remove + -
-
- {% with heading="Are you sure you want to remove <"|add:permission.user.email|add:">?" %} - {% include 'includes/modal.html' with modal_heading=heading modal_description="<"|add:permission.user.email|add:"> will no longer be able to manage the domain "|add:domain.name|add:"." modal_button=modal_button|safe %} - {% endwith %} -
-
- +
+
+ {% with heading="Are you sure you want to remove <"|add:permission.user.email|add:">?" %} + {% include 'includes/modal.html' with modal_heading=heading modal_description="<"|add:permission.user.email|add:"> will no longer be able to manage the domain "|add:domain.name|add:"." modal_button=modal_button|safe %} + {% endwith %} +
+
+ + {% endif %} {% endfor %} diff --git a/src/registrar/views/domain.py b/src/registrar/views/domain.py index da81ba6a3..c8aa7083f 100644 --- a/src/registrar/views/domain.py +++ b/src/registrar/views/domain.py @@ -630,6 +630,15 @@ class DomainUsersView(DomainBaseView): """The initial value for the form (which is a formset here).""" context = super().get_context_data(**kwargs) + domain_pk = None + can_delete_users = False + if self.kwargs is not None and "pk" in self.kwargs: + domain_pk = self.kwargs["pk"] + # Prevent the end user from deleting themselves as a manager if they are the + # only manager that exists on a domain. + can_delete_users = UserDomainRole.objects.filter(domain__id=domain_pk).count() > 1 + context["can_delete_users"] = can_delete_users + # Create HTML for the modal button modal_button = ( '' - ) + return context + def _add_modal_buttons_to_context(self, context): + """Adds modal buttons (and their HTML) to the context""" + # Create HTML for the modal button + modal_button = self._create_modal_button_html( + button_name="delete_domain_manager", + button_text_content="Yes, remove domain manager", + classes=["usa-button", "usa-button--secondary"] + ) context["modal_button"] = modal_button + # Create HTML for the modal button when deleting yourself + modal_button_self= self._create_modal_button_html( + button_name="delete_domain_manager_self", + button_text_content="Yes, remove myself", + classes=["usa-button", "usa-button--secondary"] + ) + context["modal_button_self"] = modal_button_self + return context + def _create_modal_button_html(self, button_name: str, button_text_content: str, classes: List[str] | str): + """Template for modal submit buttons""" + + if isinstance(classes, list): + class_list = " ".join(classes) + elif isinstance(classes, str): + class_list = classes + + html_class = f'class="{class_list}"' if class_list else None + + modal_button = ( + '' + ) + return modal_button + class DomainAddUserView(DomainFormBaseView): """Inside of a domain's user management, a form for adding users. @@ -779,12 +822,30 @@ class DomainDeleteUserView(UserDomainRolePermissionDeleteView): def get_success_url(self): return reverse("domain-users", kwargs={"pk": self.object.domain.id}) - def get_success_message(self, cleaned_data): - return f"Successfully removed manager for {self.object.user.email}." + def get_success_message(self, delete_self = False): + if delete_self: + message = f"You are no longer managing the domain {self.object.domain}." + else: + message = f"Removed {self.object.user.email} as a manager for this domain." + return message def form_valid(self, form): """Delete the specified user on this domain.""" super().form_valid(form) - messages.success(self.request, f"Successfully removed manager for {self.object.user.email}.") - return redirect(self.get_success_url()) \ No newline at end of file + # Is the user deleting themselves? If so, display a different message + delete_self = self.request.user.email == self.object.user.email + + # Add a success message + messages.success(self.request, self.get_success_message(delete_self)) + + return redirect(self.get_success_url()) + + def post(self, request, *args, **kwargs): + response = super().post(request, *args, **kwargs) + + # If the user is deleting themselves, redirect to home + if self.request.user.email == self.object.user.email: + return redirect(reverse("home")) + + return response \ No newline at end of file From 40e91ead1f40939b7f28b636945a08a71506b55e Mon Sep 17 00:00:00 2001 From: zandercymatics <141044360+zandercymatics@users.noreply.github.com> Date: Tue, 16 Jan 2024 10:56:56 -0700 Subject: [PATCH 014/137] Add logic for self deletion --- .../assets/sass/_theme/_buttons.scss | 9 +- src/registrar/templates/domain_users.html | 97 +++++++++++-------- src/registrar/views/domain.py | 10 +- 3 files changed, 69 insertions(+), 47 deletions(-) diff --git a/src/registrar/assets/sass/_theme/_buttons.scss b/src/registrar/assets/sass/_theme/_buttons.scss index 02089ec6d..c890b7a55 100644 --- a/src/registrar/assets/sass/_theme/_buttons.scss +++ b/src/registrar/assets/sass/_theme/_buttons.scss @@ -26,18 +26,21 @@ a.usa-button { text-decoration: none; } -a.usa-button.disabled-link { +a.usa-button.disabled-link, +a.usa-button--unstyled.disabled-link { background-color: #ccc !important; color: #454545 !important } -a.usa-button.disabled-link:hover { +a.usa-button.disabled-link:hover, +a.usa-button--unstyled.disabled-link { background-color: #ccc !important; cursor: not-allowed !important; color: #454545 !important } -a.usa-button.disabled-link:focus { +a.usa-button.disabled-link:focus, +a.usa-button--unstyled.disabled-link { background-color: #ccc !important; cursor: not-allowed !important; outline: none !important; diff --git a/src/registrar/templates/domain_users.html b/src/registrar/templates/domain_users.html index 4a0d25625..216c21942 100644 --- a/src/registrar/templates/domain_users.html +++ b/src/registrar/templates/domain_users.html @@ -16,10 +16,8 @@
  • There is no limit to the number of domain managers you can add.
  • After adding a domain manager, an email invitation will be sent to that user with instructions on how to set up an account.
  • -
  • To remove a domain manager, contact us for - assistance.
  • All domain managers must keep their contact information updated and be responsive if contacted by the .gov team.
  • +
  • Domains must have at least one domain manager. You can’t remove yourself as a domain manager if you’re the only one assigned to this domain. Add another domain manager before you remove yourself from this domain.
  • {% if domain.permissions %} @@ -31,9 +29,7 @@ Email Role - {% if can_delete_users %} - Action - {% endif %} + Action @@ -43,49 +39,66 @@ {{ permission.user.email }} {{ permission.role|title }} + {% if can_delete_users %} - - + Remove + + {# Display a custom message if the user is trying to delete themselves #} + {% if permission.user.email == current_user_email %} +
    - Remove - - {# Display a custom message if the user is trying to delete themselves #} - {% if permission.user.email == current_user_email %} -
    + {% with domain_name=domain.name|force_escape %} + {% include 'includes/modal.html' with modal_heading="Are you sure you want to remove yourself as a domain manager for "|add:domain_name|add:"?"|safe modal_description="You will no longer be able to manage the domain "|add:domain_name|add:"."|safe modal_button=modal_button_self|safe %} + {% endwith %} + +
    + {% else %} +
    -
    - {% with domain_name=domain.name|force_escape %} - {% include 'includes/modal.html' with modal_heading="Are you sure you want to remove yourself as a domain manager for "|add:domain_name|add:"?"|safe modal_description="You will no longer be able to manage the domain "|add:domain_name|add:"."|safe modal_button=modal_button_self|safe %} - {% endwith %} -
    -
    - {% else %} -
    -
    - {% with email=permission.user.email|force_escape domain_name=domain.name|force_escape %} - {% include 'includes/modal.html' with modal_heading="Are you sure you want to remove <"|add:email|add:">?"|safe modal_description="<"|add:email|add:"> will no longer be able to manage the domain "|add:domain_name|add:"."|safe modal_button=modal_button|safe %} - {% endwith %} -
    -
    - {% endif %} - + > +
    + {% with email=permission.user.email|default:permission.user|force_escape domain_name=domain.name|force_escape %} + {% include 'includes/modal.html' with modal_heading="Are you sure you want to remove <"|add:email|add:">?"|safe modal_description="<"|add:email|add:"> will no longer be able to manage the domain "|add:domain_name|add:"."|safe modal_button=modal_button|safe %} + {% endwith %} +
    +
    + {% endif %} + {% else %} + + Remove + {% endif %} + + {% comment %} + usa-tooltip disabled-link" + data-position="right" + title="Coming in 2024" + aria-disabled="true" + data-tooltip="true" + {% endcomment %} {% endfor %} diff --git a/src/registrar/views/domain.py b/src/registrar/views/domain.py index b55d490ce..0f894a985 100644 --- a/src/registrar/views/domain.py +++ b/src/registrar/views/domain.py @@ -820,13 +820,18 @@ class DomainDeleteUserView(UserDomainRolePermissionDeleteView): return UserDomainRole.objects.get(domain=domain_id, user=user_id) def get_success_url(self): + """Refreshes the page after a delete is successful""" return reverse("domain-users", kwargs={"pk": self.object.domain.id}) def get_success_message(self, delete_self = False): + """Returns confirmation content for the deletion event """ + email_or_name = self.object.user.email + if email_or_name is None: + email_or_name = self.object.user if delete_self: message = f"You are no longer managing the domain {self.object.domain}." else: - message = f"Removed {self.object.user.email} as a manager for this domain." + message = f"Removed {email_or_name} as a manager for this domain." return message def form_valid(self, form): @@ -842,10 +847,11 @@ class DomainDeleteUserView(UserDomainRolePermissionDeleteView): return redirect(self.get_success_url()) def post(self, request, *args, **kwargs): + """Custom post implementation to redirect to home in the event that the user deletes themselves""" response = super().post(request, *args, **kwargs) # If the user is deleting themselves, redirect to home - if self.request.user.email == self.object.user.email: + if self.request.user == self.object.user: return redirect(reverse("home")) return response \ No newline at end of file From 12d5905ef975597b493fa856c8880df081774e9e Mon Sep 17 00:00:00 2001 From: zandercymatics <141044360+zandercymatics@users.noreply.github.com> Date: Tue, 16 Jan 2024 11:56:49 -0700 Subject: [PATCH 015/137] Add success message for self delete --- src/registrar/templates/dashboard_base.html | 26 ++++++++++----------- src/registrar/templates/home.html | 3 +++ src/registrar/tests/test_url_auth.py | 1 + src/registrar/views/domain.py | 13 ++++++++--- 4 files changed, 27 insertions(+), 16 deletions(-) diff --git a/src/registrar/templates/dashboard_base.html b/src/registrar/templates/dashboard_base.html index 27b5ea717..46b04570b 100644 --- a/src/registrar/templates/dashboard_base.html +++ b/src/registrar/templates/dashboard_base.html @@ -3,22 +3,22 @@ {% block wrapper %}
    - {% block messages %} - {% if messages %} -
      - {% for message in messages %} - - {{ message }} - - {% endfor %} -
    - {% endif %} - {% endblock %} - {% block section_nav %}{% endblock %} {% block hero %}{% endblock %} - {% block content %}{% endblock %} + {% block content %} + {% block messages %} + {% if messages %} +
      + {% for message in messages %} + + {{ message }} + + {% endfor %} +
    + {% endif %} + {% endblock %} + {% endblock %}
    {% block complementary %}{% endblock %}
    diff --git a/src/registrar/templates/home.html b/src/registrar/templates/home.html index 15835920b..d25cd3de8 100644 --- a/src/registrar/templates/home.html +++ b/src/registrar/templates/home.html @@ -10,6 +10,9 @@ {# the entire logged in page goes here #}
    + {% block messages %} + {% include "includes/form_messages.html" %} + {% endblock %}

    Manage your domains

    diff --git a/src/registrar/tests/test_url_auth.py b/src/registrar/tests/test_url_auth.py index 34f80ac44..3e0514a85 100644 --- a/src/registrar/tests/test_url_auth.py +++ b/src/registrar/tests/test_url_auth.py @@ -23,6 +23,7 @@ SAMPLE_KWARGS = { "content_type_id": "2", "object_id": "3", "domain": "whitehouse.gov", + "user_pk": "1", } # Our test suite will ignore some namespaces. diff --git a/src/registrar/views/domain.py b/src/registrar/views/domain.py index 0f894a985..e00c90b19 100644 --- a/src/registrar/views/domain.py +++ b/src/registrar/views/domain.py @@ -825,13 +825,19 @@ class DomainDeleteUserView(UserDomainRolePermissionDeleteView): def get_success_message(self, delete_self = False): """Returns confirmation content for the deletion event """ + + # Grab the text representation of the user we want to delete email_or_name = self.object.user.email - if email_or_name is None: + if email_or_name is None or email_or_name.strip() == "": email_or_name = self.object.user + + # If the user is deleting themselves, return a special message. + # If not, return something more generic. if delete_self: message = f"You are no longer managing the domain {self.object.domain}." else: message = f"Removed {email_or_name} as a manager for this domain." + return message def form_valid(self, form): @@ -839,7 +845,7 @@ class DomainDeleteUserView(UserDomainRolePermissionDeleteView): super().form_valid(form) # Is the user deleting themselves? If so, display a different message - delete_self = self.request.user.email == self.object.user.email + delete_self = self.request.user == self.object.user # Add a success message messages.success(self.request, self.get_success_message(delete_self)) @@ -851,7 +857,8 @@ class DomainDeleteUserView(UserDomainRolePermissionDeleteView): response = super().post(request, *args, **kwargs) # If the user is deleting themselves, redirect to home - if self.request.user == self.object.user: + delete_self = self.request.user == self.object.user + if delete_self: return redirect(reverse("home")) return response \ No newline at end of file From f16382e946f62e8a9b0813d4a26f75d20b808ed9 Mon Sep 17 00:00:00 2001 From: zandercymatics <141044360+zandercymatics@users.noreply.github.com> Date: Wed, 17 Jan 2024 09:41:19 -0700 Subject: [PATCH 016/137] Linting --- src/registrar/views/application.py | 12 +++++++- src/registrar/views/domain.py | 29 ++++++++----------- src/registrar/views/utility/mixins.py | 6 ++-- .../views/utility/permission_views.py | 1 - 4 files changed, 25 insertions(+), 23 deletions(-) diff --git a/src/registrar/views/application.py b/src/registrar/views/application.py index 23c8cf55e..cfb16336b 100644 --- a/src/registrar/views/application.py +++ b/src/registrar/views/application.py @@ -10,6 +10,7 @@ from django.contrib import messages from registrar.forms import application_wizard as forms from registrar.models import DomainApplication +from registrar.models.user import User from registrar.utility import StrEnum from registrar.views.utility import StepsHelper @@ -131,11 +132,19 @@ class ApplicationWizard(ApplicationWizardPermissionView, TemplateView): if self._application: return self._application + # For linter. The else block should never be hit, but if it does, + # there may be a UI consideration. That will need to be handled in another ticket. + creator = None + if self.request.user is not None and isinstance(self.request.user, User): + creator = self.request.user + else: + raise ValueError("Invalid value for User") + if self.has_pk(): id = self.storage["application_id"] try: self._application = DomainApplication.objects.get( - creator=self.request.user, # type: ignore + creator=creator, pk=id, ) return self._application @@ -476,6 +485,7 @@ class DotgovDomain(ApplicationWizard): self.application.save() return response + class Purpose(ApplicationWizard): template_name = "application_purpose.html" forms = [forms.PurposeForm] diff --git a/src/registrar/views/domain.py b/src/registrar/views/domain.py index e00c90b19..d4a7b8066 100644 --- a/src/registrar/views/domain.py +++ b/src/registrar/views/domain.py @@ -34,7 +34,7 @@ from registrar.utility.errors import ( SecurityEmailErrorCodes, ) from registrar.models.utility.contact_error import ContactError -from registrar.views.utility.permission_views import UserDomainRolePermissionDeleteView, UserDomainRolePermissionView +from registrar.views.utility.permission_views import UserDomainRolePermissionDeleteView from ..forms import ( ContactForm, @@ -643,7 +643,6 @@ class DomainUsersView(DomainBaseView): return context def _add_booleans_to_context(self, context): - # Determine if the current user can delete managers domain_pk = None can_delete_users = False @@ -660,17 +659,17 @@ class DomainUsersView(DomainBaseView): """Adds modal buttons (and their HTML) to the context""" # Create HTML for the modal button modal_button = self._create_modal_button_html( - button_name="delete_domain_manager", + button_name="delete_domain_manager", button_text_content="Yes, remove domain manager", - classes=["usa-button", "usa-button--secondary"] + classes=["usa-button", "usa-button--secondary"], ) context["modal_button"] = modal_button # Create HTML for the modal button when deleting yourself - modal_button_self= self._create_modal_button_html( + modal_button_self = self._create_modal_button_html( button_name="delete_domain_manager_self", button_text_content="Yes, remove myself", - classes=["usa-button", "usa-button--secondary"] + classes=["usa-button", "usa-button--secondary"], ) context["modal_button_self"] = modal_button_self @@ -686,11 +685,7 @@ class DomainUsersView(DomainBaseView): html_class = f'class="{class_list}"' if class_list else None - modal_button = ( - '' - ) + modal_button = '' return modal_button @@ -809,8 +804,8 @@ class DomainInvitationDeleteView(DomainInvitationPermissionDeleteView, SuccessMe class DomainDeleteUserView(UserDomainRolePermissionDeleteView): - """Inside of a domain's user management, a form for deleting users. - """ + """Inside of a domain's user management, a form for deleting users.""" + object: UserDomainRole # workaround for type mismatch in DeleteView def get_object(self, queryset=None): @@ -823,8 +818,8 @@ class DomainDeleteUserView(UserDomainRolePermissionDeleteView): """Refreshes the page after a delete is successful""" return reverse("domain-users", kwargs={"pk": self.object.domain.id}) - def get_success_message(self, delete_self = False): - """Returns confirmation content for the deletion event """ + def get_success_message(self, delete_self=False): + """Returns confirmation content for the deletion event""" # Grab the text representation of the user we want to delete email_or_name = self.object.user.email @@ -860,5 +855,5 @@ class DomainDeleteUserView(UserDomainRolePermissionDeleteView): delete_self = self.request.user == self.object.user if delete_self: return redirect(reverse("home")) - - return response \ No newline at end of file + + return response diff --git a/src/registrar/views/utility/mixins.py b/src/registrar/views/utility/mixins.py index bfa9d7330..980c0dad5 100644 --- a/src/registrar/views/utility/mixins.py +++ b/src/registrar/views/utility/mixins.py @@ -307,7 +307,7 @@ class UserDomainRolePermission(PermissionsLoginMixin): # Check if the UserDomainRole object exists, then check # if the user requesting the delete has permissions to do so has_delete_permission = UserDomainRole.objects.filter( - user=user_pk, + user=user_pk, domain=domain_pk, domain__permissions__user=self.request.user, ).exists() @@ -316,9 +316,7 @@ class UserDomainRolePermission(PermissionsLoginMixin): # Check if more than one manager exists on the domain. # If only one exists, prevent this from happening - has_multiple_managers = len(UserDomainRole.objects.filter( - domain=domain_pk - )) > 1 + has_multiple_managers = len(UserDomainRole.objects.filter(domain=domain_pk)) > 1 if not has_multiple_managers: return False diff --git a/src/registrar/views/utility/permission_views.py b/src/registrar/views/utility/permission_views.py index 5c5ebc494..295fbc65c 100644 --- a/src/registrar/views/utility/permission_views.py +++ b/src/registrar/views/utility/permission_views.py @@ -152,4 +152,3 @@ class UserDomainRolePermissionDeleteView(UserDomainRolePermissionView, DeleteVie model = UserDomainRole # variable name in template context for the model object context_object_name = "userdomainrole" - From 353e2d518f158c678733fc7da834a7f2e2a8967e Mon Sep 17 00:00:00 2001 From: zandercymatics <141044360+zandercymatics@users.noreply.github.com> Date: Wed, 17 Jan 2024 13:01:02 -0700 Subject: [PATCH 017/137] Update get-gov.js --- src/registrar/assets/js/get-gov.js | 61 +++++++++++++++++++++++++++++- 1 file changed, 60 insertions(+), 1 deletion(-) diff --git a/src/registrar/assets/js/get-gov.js b/src/registrar/assets/js/get-gov.js index 68e8af69c..23e40858a 100644 --- a/src/registrar/assets/js/get-gov.js +++ b/src/registrar/assets/js/get-gov.js @@ -227,10 +227,69 @@ function handleValidationClick(e) { for(const button of activatesValidation) { button.addEventListener('click', handleValidationClick); } + + + // Add event listener to the "Check availability" button + const checkAvailabilityButton = document.getElementById('check-availability-button'); + if (checkAvailabilityButton) { + const targetId = checkAvailabilityButton.getAttribute('validate-for'); + const checkAvailabilityInput = document.getElementById(targetId); + checkAvailabilityButton.addEventListener('click', + function() { + removeFormErrors(checkAvailabilityInput) + } + ); + } + + // Add event listener to the alternate domains input + const alternateDomainsInputs = document.querySelectorAll('[auto-validate]'); + if (alternateDomainsInputs) { + for (const domainInput of alternateDomainsInputs){ + // Only apply this logic to alternate domains input + if (domainInput.classList.contains('alternate-domain-input')){ + domainInput.addEventListener('input', function() { + removeFormErrors(domainInput); + } + ); + } + } + } })(); /** - * Delete method for formsets that diff in the view and delete in the model (Nameservers, DS Data) + * Removes form errors surrounding a form input + */ +function removeFormErrors(input){ + console.log("in the function...") + // Remove error message + let errorMessage = document.getElementById(`${input.id}__error-message`); + if (errorMessage) { + errorMessage.remove(); + console.log("Error message removed") + }else{ + return + } + + // Remove error classes + if (input.classList.contains('usa-input--error')) { + input.classList.remove('usa-input--error'); + } + + let label = document.querySelector(`label[for="${input.id}"]`); + if (label) { + label.classList.remove('usa-label--error'); + + // Remove error classes from parent div + let parentDiv = label.parentElement; + if (parentDiv) { + parentDiv.classList.remove('usa-form-group--error'); + } + } +} + +/** + * Prepare the namerservers and DS data forms delete buttons + * We will call this on the forms init, and also every time we add a form * */ function removeForm(e, formLabel, isNameserversForm, addButton, formIdentifier){ From 1a5c8930edbc591f9854c4795460a3a66d6e1352 Mon Sep 17 00:00:00 2001 From: zandercymatics <141044360+zandercymatics@users.noreply.github.com> Date: Wed, 17 Jan 2024 14:37:13 -0700 Subject: [PATCH 018/137] Button align --- src/registrar/assets/sass/_theme/_buttons.scss | 16 ++++++++++------ src/registrar/assets/sass/_theme/_tables.scss | 4 ---- src/registrar/templates/domain_users.html | 6 +++--- 3 files changed, 13 insertions(+), 13 deletions(-) diff --git a/src/registrar/assets/sass/_theme/_buttons.scss b/src/registrar/assets/sass/_theme/_buttons.scss index c890b7a55..78c06f0f4 100644 --- a/src/registrar/assets/sass/_theme/_buttons.scss +++ b/src/registrar/assets/sass/_theme/_buttons.scss @@ -26,27 +26,31 @@ a.usa-button { text-decoration: none; } -a.usa-button.disabled-link, -a.usa-button--unstyled.disabled-link { +a.usa-button.disabled-link { background-color: #ccc !important; color: #454545 !important } -a.usa-button.disabled-link:hover, -a.usa-button--unstyled.disabled-link { +a.usa-button.disabled-link:hover{ background-color: #ccc !important; cursor: not-allowed !important; color: #454545 !important } -a.usa-button.disabled-link:focus, -a.usa-button--unstyled.disabled-link { +a.usa-button.disabled-link:focus { background-color: #ccc !important; cursor: not-allowed !important; outline: none !important; color: #454545 !important } +a.usa-button--unstyled.disabled-link, +a.usa-button--unstyled.disabled-link:hover, +a.usa-button--unstyled.disabled-link:focus { + cursor: not-allowed !important; + outline: none !important; +} + a.usa-button:not(.usa-button--unstyled, .usa-button--outline) { color: color('white'); } diff --git a/src/registrar/assets/sass/_theme/_tables.scss b/src/registrar/assets/sass/_theme/_tables.scss index 892427f82..6dcc6f3bc 100644 --- a/src/registrar/assets/sass/_theme/_tables.scss +++ b/src/registrar/assets/sass/_theme/_tables.scss @@ -25,10 +25,6 @@ color: color('primary-darker'); padding-bottom: units(2px); } - td.shift-action-button { - padding-right: 0; - transform: translateX(10px); - } } .dotgov-table { diff --git a/src/registrar/templates/domain_users.html b/src/registrar/templates/domain_users.html index 216c21942..e78d88781 100644 --- a/src/registrar/templates/domain_users.html +++ b/src/registrar/templates/domain_users.html @@ -29,7 +29,7 @@ Email Role - Action + Action @@ -39,7 +39,7 @@ {{ permission.user.email }} {{ permission.role|title }} - + {% if can_delete_users %} {{ invitation.created_at|date }} {{ invitation.status|title }} -

    + {% csrf_token %} From ac81ecd11a06e83a543229f1a5ff24be35eab4e7 Mon Sep 17 00:00:00 2001 From: zandercymatics <141044360+zandercymatics@users.noreply.github.com> Date: Thu, 18 Jan 2024 12:30:40 -0700 Subject: [PATCH 019/137] Remove logger --- src/registrar/assets/js/get-gov.js | 1 - 1 file changed, 1 deletion(-) diff --git a/src/registrar/assets/js/get-gov.js b/src/registrar/assets/js/get-gov.js index 23e40858a..ad44f3d44 100644 --- a/src/registrar/assets/js/get-gov.js +++ b/src/registrar/assets/js/get-gov.js @@ -260,7 +260,6 @@ function handleValidationClick(e) { * Removes form errors surrounding a form input */ function removeFormErrors(input){ - console.log("in the function...") // Remove error message let errorMessage = document.getElementById(`${input.id}__error-message`); if (errorMessage) { From 4c5d8b2c55ab24ad3c8e0198630b75605430fcd0 Mon Sep 17 00:00:00 2001 From: zandercymatics <141044360+zandercymatics@users.noreply.github.com> Date: Thu, 18 Jan 2024 12:45:39 -0700 Subject: [PATCH 020/137] Update get-gov.js --- src/registrar/assets/js/get-gov.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/registrar/assets/js/get-gov.js b/src/registrar/assets/js/get-gov.js index ad44f3d44..ee9b7165d 100644 --- a/src/registrar/assets/js/get-gov.js +++ b/src/registrar/assets/js/get-gov.js @@ -264,7 +264,6 @@ function removeFormErrors(input){ let errorMessage = document.getElementById(`${input.id}__error-message`); if (errorMessage) { errorMessage.remove(); - console.log("Error message removed") }else{ return } @@ -274,6 +273,7 @@ function removeFormErrors(input){ input.classList.remove('usa-input--error'); } + // Get the form label let label = document.querySelector(`label[for="${input.id}"]`); if (label) { label.classList.remove('usa-label--error'); From 0a1da49c33e6b43977ed57e0b58629a49078864c Mon Sep 17 00:00:00 2001 From: zandercymatics <141044360+zandercymatics@users.noreply.github.com> Date: Thu, 18 Jan 2024 13:14:13 -0700 Subject: [PATCH 021/137] Logic to remove stale alerts --- src/registrar/assets/js/get-gov.js | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/src/registrar/assets/js/get-gov.js b/src/registrar/assets/js/get-gov.js index ee9b7165d..bbf1791ed 100644 --- a/src/registrar/assets/js/get-gov.js +++ b/src/registrar/assets/js/get-gov.js @@ -236,7 +236,7 @@ function handleValidationClick(e) { const checkAvailabilityInput = document.getElementById(targetId); checkAvailabilityButton.addEventListener('click', function() { - removeFormErrors(checkAvailabilityInput) + removeFormErrors(checkAvailabilityInput, true); } ); } @@ -248,7 +248,7 @@ function handleValidationClick(e) { // Only apply this logic to alternate domains input if (domainInput.classList.contains('alternate-domain-input')){ domainInput.addEventListener('input', function() { - removeFormErrors(domainInput); + removeFormErrors(domainInput, true); } ); } @@ -259,7 +259,7 @@ function handleValidationClick(e) { /** * Removes form errors surrounding a form input */ -function removeFormErrors(input){ +function removeFormErrors(input, removeStaleAlerts=false){ // Remove error message let errorMessage = document.getElementById(`${input.id}__error-message`); if (errorMessage) { @@ -284,6 +284,16 @@ function removeFormErrors(input){ parentDiv.classList.remove('usa-form-group--error'); } } + + if (removeStaleAlerts){ + let staleAlerts = document.getElementsByClassName("usa-alert--error") + for (let alert of staleAlerts){ + // Don't remove the error associated with the input + if (alert.id !== `${input.id}--toast`) { + alert.remove() + } + } + } } /** From a9253b6689098dbe29723104feafe3d3dcdfeed7 Mon Sep 17 00:00:00 2001 From: zandercymatics <141044360+zandercymatics@users.noreply.github.com> Date: Thu, 18 Jan 2024 13:30:23 -0700 Subject: [PATCH 022/137] Update get-gov.js --- src/registrar/assets/js/get-gov.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/registrar/assets/js/get-gov.js b/src/registrar/assets/js/get-gov.js index bbf1791ed..e2e116569 100644 --- a/src/registrar/assets/js/get-gov.js +++ b/src/registrar/assets/js/get-gov.js @@ -286,7 +286,7 @@ function removeFormErrors(input, removeStaleAlerts=false){ } if (removeStaleAlerts){ - let staleAlerts = document.getElementsByClassName("usa-alert--error") + let staleAlerts = Array.from(document.getElementsByClassName("usa-alert--error")) for (let alert of staleAlerts){ // Don't remove the error associated with the input if (alert.id !== `${input.id}--toast`) { From 3d7c651c72b8ff04abf85b0dedcb22ae5ca45690 Mon Sep 17 00:00:00 2001 From: zandercymatics <141044360+zandercymatics@users.noreply.github.com> Date: Thu, 18 Jan 2024 13:31:18 -0700 Subject: [PATCH 023/137] Use querySelectorAll --- src/registrar/assets/js/get-gov.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/registrar/assets/js/get-gov.js b/src/registrar/assets/js/get-gov.js index e2e116569..4a1ce005f 100644 --- a/src/registrar/assets/js/get-gov.js +++ b/src/registrar/assets/js/get-gov.js @@ -286,7 +286,7 @@ function removeFormErrors(input, removeStaleAlerts=false){ } if (removeStaleAlerts){ - let staleAlerts = Array.from(document.getElementsByClassName("usa-alert--error")) + let staleAlerts = document.querySelectorAll(".usa-alert--error") for (let alert of staleAlerts){ // Don't remove the error associated with the input if (alert.id !== `${input.id}--toast`) { From 234af2501fe803958a00859a01846fc795074f46 Mon Sep 17 00:00:00 2001 From: zandercymatics <141044360+zandercymatics@users.noreply.github.com> Date: Thu, 18 Jan 2024 15:01:49 -0700 Subject: [PATCH 024/137] Unit test --- src/registrar/tests/test_views.py | 70 +++++++++++++++++++++++++++++++ 1 file changed, 70 insertions(+) diff --git a/src/registrar/tests/test_views.py b/src/registrar/tests/test_views.py index 8f812b815..0b73f7bef 100644 --- a/src/registrar/tests/test_views.py +++ b/src/registrar/tests/test_views.py @@ -1443,6 +1443,76 @@ class TestDomainManagers(TestDomainOverview): response = self.client.get(reverse("domain-users-add", kwargs={"pk": self.domain.id})) self.assertContains(response, "Add a domain manager") + def test_domain_delete_link(self): + """Tests if the user delete link works""" + + # Add additional users + dummy_user_1 = User.objects.create( + username="macncheese", + email="cheese@igorville.com", + ) + dummy_user_2 = User.objects.create( + username="pastapizza", + email="pasta@igorville.com", + ) + + role_1 = UserDomainRole.objects.create( + user=dummy_user_1, domain=self.domain, role=UserDomainRole.Roles.MANAGER + ) + role_2 = UserDomainRole.objects.create( + user=dummy_user_2, domain=self.domain, role=UserDomainRole.Roles.MANAGER + ) + + response = self.client.get(reverse("domain-users", kwargs={"pk": self.domain.id})) + + # Make sure we're on the right page + self.assertContains(response, "Domain managers") + + # Make sure the desired user exists + self.assertContains(response, "cheese@igorville.com") + + # Delete dummy_user_1 + response = self.client.post( + reverse( + "domain-user-delete", + kwargs={ + "pk": self.domain.id, + "user_pk": dummy_user_1.id + } + ), + follow=True + ) + + # Grab the displayed messages + messages = list(response.context["messages"]) + self.assertEqual(len(messages), 1) + + # Ensure the error we recieve is in line with what we expect + message = messages[0] + self.assertEqual(message.message, "Removed cheese@igorville.com as a manager for this domain.") + self.assertEqual(message.tags, "success") + + # Check that role_1 deleted in the DB after the post + deleted_user_exists = UserDomainRole.objects.filter(id=role_1.id).exists() + self.assertFalse(deleted_user_exists) + + # Ensure that the current user wasn't deleted + current_user_exists = UserDomainRole.objects.filter(id=self.user.id).exists() + self.assertTrue(current_user_exists) + + # Ensure that the other userdomainrole was not deleted + role_2_exists = UserDomainRole.objects.filter(id=role_2.id).exists() + self.assertTrue(role_2_exists) + + # Check that the view no longer displays the deleted user + # TODO - why is this not working? + # self.assertNotContains(response, "cheese@igorville.com") + + @skip("TODO") + def test_domain_delete_self_redirects_home(self): + """Tests if deleting yourself redirects to home""" + raise + @boto3_mocking.patching def test_domain_user_add_form(self): """Adding an existing user works.""" From 474e70d1bd30398923d7930c9153f851e20842c8 Mon Sep 17 00:00:00 2001 From: zandercymatics <141044360+zandercymatics@users.noreply.github.com> Date: Thu, 18 Jan 2024 15:43:42 -0700 Subject: [PATCH 025/137] Linting on test case, stylistic changes --- src/registrar/templates/domain_users.html | 6 +++--- src/registrar/tests/test_views.py | 21 +++++---------------- 2 files changed, 8 insertions(+), 19 deletions(-) diff --git a/src/registrar/templates/domain_users.html b/src/registrar/templates/domain_users.html index e78d88781..fa94c5f51 100644 --- a/src/registrar/templates/domain_users.html +++ b/src/registrar/templates/domain_users.html @@ -29,7 +29,7 @@ Email Role - Action + Action @@ -137,8 +137,8 @@ {{ invitation.created_at|date }} {{ invitation.status|title }} -
    - {% csrf_token %} + + {% csrf_token %}
    diff --git a/src/registrar/tests/test_views.py b/src/registrar/tests/test_views.py index 0b73f7bef..f022ec09c 100644 --- a/src/registrar/tests/test_views.py +++ b/src/registrar/tests/test_views.py @@ -1456,31 +1456,20 @@ class TestDomainManagers(TestDomainOverview): email="pasta@igorville.com", ) - role_1 = UserDomainRole.objects.create( - user=dummy_user_1, domain=self.domain, role=UserDomainRole.Roles.MANAGER - ) - role_2 = UserDomainRole.objects.create( - user=dummy_user_2, domain=self.domain, role=UserDomainRole.Roles.MANAGER - ) + role_1 = UserDomainRole.objects.create(user=dummy_user_1, domain=self.domain, role=UserDomainRole.Roles.MANAGER) + role_2 = UserDomainRole.objects.create(user=dummy_user_2, domain=self.domain, role=UserDomainRole.Roles.MANAGER) response = self.client.get(reverse("domain-users", kwargs={"pk": self.domain.id})) # Make sure we're on the right page self.assertContains(response, "Domain managers") - + # Make sure the desired user exists self.assertContains(response, "cheese@igorville.com") # Delete dummy_user_1 response = self.client.post( - reverse( - "domain-user-delete", - kwargs={ - "pk": self.domain.id, - "user_pk": dummy_user_1.id - } - ), - follow=True + reverse("domain-user-delete", kwargs={"pk": self.domain.id, "user_pk": dummy_user_1.id}), follow=True ) # Grab the displayed messages @@ -1497,7 +1486,7 @@ class TestDomainManagers(TestDomainOverview): self.assertFalse(deleted_user_exists) # Ensure that the current user wasn't deleted - current_user_exists = UserDomainRole.objects.filter(id=self.user.id).exists() + current_user_exists = UserDomainRole.objects.filter(user=self.user.id).exists() self.assertTrue(current_user_exists) # Ensure that the other userdomainrole was not deleted From b23f361a0843e5ac9d563e02e843420be84b9038 Mon Sep 17 00:00:00 2001 From: zandercymatics <141044360+zandercymatics@users.noreply.github.com> Date: Thu, 18 Jan 2024 15:53:59 -0700 Subject: [PATCH 026/137] Update permission_views.py --- src/registrar/views/utility/permission_views.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/registrar/views/utility/permission_views.py b/src/registrar/views/utility/permission_views.py index 8c414f6ad..762612128 100644 --- a/src/registrar/views/utility/permission_views.py +++ b/src/registrar/views/utility/permission_views.py @@ -158,5 +158,8 @@ class UserDomainRolePermissionDeleteView(UserDomainRolePermissionView, DeleteVie # DetailView property for what model this is viewing model = UserDomainRole + # workaround for type mismatch in DeleteView + object: UserDomainRole + # variable name in template context for the model object context_object_name = "userdomainrole" From ef5617cca2e9ca7690307696d7262219313223b1 Mon Sep 17 00:00:00 2001 From: Rebecca Hsieh Date: Thu, 18 Jan 2024 17:11:12 -0800 Subject: [PATCH 027/137] Add button and wording and update styling --- .../templates/application_dotgov_domain.html | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/registrar/templates/application_dotgov_domain.html b/src/registrar/templates/application_dotgov_domain.html index 1838f33f4..22b4093c2 100644 --- a/src/registrar/templates/application_dotgov_domain.html +++ b/src/registrar/templates/application_dotgov_domain.html @@ -50,7 +50,7 @@ @@ -83,6 +83,17 @@ Add another alternative - +
    + + + +

    If you’re not sure this is the domain you want, that’s ok. You can change the domain later.

    + + {% endblock %} From 83c34ceaf07c12a82de05edb32ea110a64a96edb Mon Sep 17 00:00:00 2001 From: David Kennedy Date: Thu, 18 Jan 2024 21:22:34 -0500 Subject: [PATCH 028/137] added related objects to contact object change_view in django admin --- src/registrar/admin.py | 40 +++++++++++++++++++ .../django/admin/contact_change_form.html | 24 +++++++++++ src/registrar/templatetags/custom_filters.py | 5 +++ 3 files changed, 69 insertions(+) create mode 100644 src/registrar/templates/django/admin/contact_change_form.html diff --git a/src/registrar/admin.py b/src/registrar/admin.py index 8d3b1d29f..6c2c2e1a6 100644 --- a/src/registrar/admin.py +++ b/src/registrar/admin.py @@ -415,6 +415,7 @@ class ContactAdmin(ListHeaderAdmin): "contact", "email", ] + change_form_template = "django/admin/contact_change_form.html" # We name the custom prop 'contact' because linter # is not allowing a short_description attr on it @@ -452,6 +453,45 @@ class ContactAdmin(ListHeaderAdmin): readonly_fields.extend([field for field in self.analyst_readonly_fields]) return readonly_fields # Read-only fields for analysts + def change_view(self, request, object_id, form_url='', extra_context=None): + """Extend the change_view for Contact objects in django admin. + Customize to display related objects to the Contact. These will be passed + through the extra_context to the template for display to the user.""" + extra_context = extra_context or {} + + # Fetch the Contact instance + contact = models.Contact.objects.get(pk=object_id) + + # initialize related_objects array + related_objects = [] + # for all defined fields in the model + for related_field in contact._meta.get_fields(): + # if the field is a relation to another object + if related_field.is_relation: + # Check if the related field is not None + related_manager = getattr(contact, related_field.name) + if related_manager is not None: + # Check if it's a ManyToManyField or a reverse ForeignKey/OneToOneField + # Do this by checking for a method on the related_manager + if hasattr(related_manager, 'get_queryset'): + queryset = related_manager.get_queryset() + else: + queryset = related_manager.all() + + for obj in queryset: + # for each object, build the edit url in this view and add as tuple + # to the related_objects array + app_label = obj._meta.app_label + model_name = obj._meta.model_name + obj_id = obj.id + change_url = reverse('admin:%s_%s_change' % (app_label, model_name), args=[obj_id]) + related_objects.append((change_url, obj)) + + # set the related_objects array in extra_context + extra_context['related_objects'] = related_objects + + return super().change_view(request, object_id, form_url, extra_context=extra_context) + class WebsiteAdmin(ListHeaderAdmin): """Custom website admin class.""" diff --git a/src/registrar/templates/django/admin/contact_change_form.html b/src/registrar/templates/django/admin/contact_change_form.html new file mode 100644 index 000000000..e3952a1ac --- /dev/null +++ b/src/registrar/templates/django/admin/contact_change_form.html @@ -0,0 +1,24 @@ +{% extends 'admin/change_form.html' %} +{% load custom_filters %} + +{% block content %} + + {% if related_objects %} +
    +

    Related Objects:

    +
    +
    + {% endif %} + + {{ block.super }} + +{% endblock %} \ No newline at end of file diff --git a/src/registrar/templatetags/custom_filters.py b/src/registrar/templatetags/custom_filters.py index de2051989..5ac290b8b 100644 --- a/src/registrar/templatetags/custom_filters.py +++ b/src/registrar/templatetags/custom_filters.py @@ -7,6 +7,11 @@ register = template.Library() logger = logging.getLogger(__name__) +@register.filter +def class_name(value): + return value.__class__.__name__ + + @register.filter(name="extract_value") def extract_value(html_input): match = re.search(r'value="([^"]*)"', html_input) From 96a13040bf416edfafef32e9059044b50a863ede Mon Sep 17 00:00:00 2001 From: David Kennedy Date: Fri, 19 Jan 2024 06:47:01 -0500 Subject: [PATCH 029/137] updated application review page and application summary in emails --- src/registrar/templates/application_review.html | 15 ++++++++++----- .../emails/includes/application_summary.txt | 5 +++-- 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/src/registrar/templates/application_review.html b/src/registrar/templates/application_review.html index 974830e91..dd2507d1b 100644 --- a/src/registrar/templates/application_review.html +++ b/src/registrar/templates/application_review.html @@ -78,11 +78,16 @@
    • {{ application.requested_domain.name|default:"Incomplete" }}
    -
      - {% for site in application.alternative_domains.all %} -
    • {{ site.website }}
    • - {% endfor %} -
    + {% if application.alternative_domains.all %} +
    +

    Alternative domains

    +
      + {% for site in application.alternative_domains.all %} +
    • {{ site.website }}
    • + {% endfor %} +
    +
    + {% endif %} {% endif %} {% if step == Step.PURPOSE %} {{ application.purpose|default:"Incomplete" }} diff --git a/src/registrar/templates/emails/includes/application_summary.txt b/src/registrar/templates/emails/includes/application_summary.txt index c628e1074..fda62b63a 100644 --- a/src/registrar/templates/emails/includes/application_summary.txt +++ b/src/registrar/templates/emails/includes/application_summary.txt @@ -21,9 +21,10 @@ Current website for your organization: {% for site in application.current_websit {% spaceless %}{{ site.website }}{% endspaceless %} {% endfor %}{% endif %} .gov domain: -{{ application.requested_domain.name }} +{{ application.requested_domain.name }}{% if application.alternative_domains.all %} +Alternative domains: {% for site in application.alternative_domains.all %}{% spaceless %}{{ site.website }}{% endspaceless %} -{% endfor %} +{% endfor %}{% endif %} Purpose of your domain: {{ application.purpose }} From 71ac6d8a9bdaa7353b10bc20ab79d1a217dcad6c Mon Sep 17 00:00:00 2001 From: David Kennedy Date: Fri, 19 Jan 2024 07:37:18 -0500 Subject: [PATCH 030/137] proper spacing in email --- src/registrar/templates/emails/includes/application_summary.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/src/registrar/templates/emails/includes/application_summary.txt b/src/registrar/templates/emails/includes/application_summary.txt index fda62b63a..770bf0eef 100644 --- a/src/registrar/templates/emails/includes/application_summary.txt +++ b/src/registrar/templates/emails/includes/application_summary.txt @@ -22,6 +22,7 @@ Current website for your organization: {% for site in application.current_websit {% endfor %}{% endif %} .gov domain: {{ application.requested_domain.name }}{% if application.alternative_domains.all %} + Alternative domains: {% for site in application.alternative_domains.all %}{% spaceless %}{{ site.website }}{% endspaceless %} {% endfor %}{% endif %} From 15569e08f7c87a2c155d70b132081b1ccafa300b Mon Sep 17 00:00:00 2001 From: David Kennedy Date: Fri, 19 Jan 2024 07:59:08 -0500 Subject: [PATCH 031/137] further fixed spacing in emails, and corrected unit tests --- .../templates/emails/includes/application_summary.txt | 4 ++-- src/registrar/tests/test_emails.py | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/registrar/templates/emails/includes/application_summary.txt b/src/registrar/templates/emails/includes/application_summary.txt index 770bf0eef..f6cc80dfa 100644 --- a/src/registrar/templates/emails/includes/application_summary.txt +++ b/src/registrar/templates/emails/includes/application_summary.txt @@ -21,8 +21,8 @@ Current website for your organization: {% for site in application.current_websit {% spaceless %}{{ site.website }}{% endspaceless %} {% endfor %}{% endif %} .gov domain: -{{ application.requested_domain.name }}{% if application.alternative_domains.all %} - +{{ application.requested_domain.name }} +{% if application.alternative_domains.all %} Alternative domains: {% for site in application.alternative_domains.all %}{% spaceless %}{{ site.website }}{% endspaceless %} {% endfor %}{% endif %} diff --git a/src/registrar/tests/test_emails.py b/src/registrar/tests/test_emails.py index 61c950255..c6039da93 100644 --- a/src/registrar/tests/test_emails.py +++ b/src/registrar/tests/test_emails.py @@ -117,7 +117,7 @@ class TestEmails(TestCase): body = kwargs["Content"]["Simple"]["Body"]["Text"]["Data"] self.assertIn("city1.gov", body) # spacing should be right between adjacent elements - self.assertRegex(body, r"city.gov\ncity1.gov\n\nPurpose of your domain:") + self.assertRegex(body, r"city.gov\n\nAlternative domains:\ncity1.gov\n\nPurpose of your domain:") @boto3_mocking.patching def test_submission_confirmation_no_alternative_govdomain_spacing(self): From cbd19b65fe73165e1e14794ecccca611faad7f57 Mon Sep 17 00:00:00 2001 From: David Kennedy Date: Fri, 19 Jan 2024 11:33:45 -0500 Subject: [PATCH 032/137] passing related objects through messages rather than through extra_context --- src/registrar/admin.py | 23 +++++++++++------- .../django/admin/contact_change_form.html | 24 ------------------- src/registrar/templatetags/custom_filters.py | 5 ---- 3 files changed, 14 insertions(+), 38 deletions(-) delete mode 100644 src/registrar/templates/django/admin/contact_change_form.html diff --git a/src/registrar/admin.py b/src/registrar/admin.py index 6c2c2e1a6..b2cc8144b 100644 --- a/src/registrar/admin.py +++ b/src/registrar/admin.py @@ -20,6 +20,7 @@ from . import models from auditlog.models import LogEntry # type: ignore from auditlog.admin import LogEntryAdmin # type: ignore from django_fsm import TransitionNotAllowed # type: ignore +from django.utils.safestring import mark_safe logger = logging.getLogger(__name__) @@ -415,7 +416,6 @@ class ContactAdmin(ListHeaderAdmin): "contact", "email", ] - change_form_template = "django/admin/contact_change_form.html" # We name the custom prop 'contact' because linter # is not allowing a short_description attr on it @@ -456,8 +456,7 @@ class ContactAdmin(ListHeaderAdmin): def change_view(self, request, object_id, form_url='', extra_context=None): """Extend the change_view for Contact objects in django admin. Customize to display related objects to the Contact. These will be passed - through the extra_context to the template for display to the user.""" - extra_context = extra_context or {} + through the messages construct to the template for display to the user.""" # Fetch the Contact instance contact = models.Contact.objects.get(pk=object_id) @@ -471,12 +470,14 @@ class ContactAdmin(ListHeaderAdmin): # Check if the related field is not None related_manager = getattr(contact, related_field.name) if related_manager is not None: - # Check if it's a ManyToManyField or a reverse ForeignKey/OneToOneField - # Do this by checking for a method on the related_manager + # Check if it's a ManyToManyField/reverse ForeignKey or a OneToOneField + # Do this by checking for get_queryset method on the related_manager if hasattr(related_manager, 'get_queryset'): + # Handles ManyToManyRel and ManyToOneRel queryset = related_manager.get_queryset() else: - queryset = related_manager.all() + # Handles OneToOne rels, ie. User + queryset = [related_manager] for obj in queryset: # for each object, build the edit url in this view and add as tuple @@ -487,9 +488,13 @@ class ContactAdmin(ListHeaderAdmin): change_url = reverse('admin:%s_%s_change' % (app_label, model_name), args=[obj_id]) related_objects.append((change_url, obj)) - # set the related_objects array in extra_context - extra_context['related_objects'] = related_objects - + if related_objects: + message = f"

    Related Objects:

      " + for url, obj in related_objects: + message += f"
    • {obj.__class__.__name__}: {obj}
    • " + message += "
    " + message_html = mark_safe(message) + messages.warning(request, message_html,) return super().change_view(request, object_id, form_url, extra_context=extra_context) diff --git a/src/registrar/templates/django/admin/contact_change_form.html b/src/registrar/templates/django/admin/contact_change_form.html deleted file mode 100644 index e3952a1ac..000000000 --- a/src/registrar/templates/django/admin/contact_change_form.html +++ /dev/null @@ -1,24 +0,0 @@ -{% extends 'admin/change_form.html' %} -{% load custom_filters %} - -{% block content %} - - {% if related_objects %} -
    -

    Related Objects:

    -
      - {% for url, obj in related_objects %} -
    • - {{ obj|class_name }}: - - {{ obj }} - -
    • - {% endfor %} -
    -
    - {% endif %} - - {{ block.super }} - -{% endblock %} \ No newline at end of file diff --git a/src/registrar/templatetags/custom_filters.py b/src/registrar/templatetags/custom_filters.py index 5ac290b8b..de2051989 100644 --- a/src/registrar/templatetags/custom_filters.py +++ b/src/registrar/templatetags/custom_filters.py @@ -7,11 +7,6 @@ register = template.Library() logger = logging.getLogger(__name__) -@register.filter -def class_name(value): - return value.__class__.__name__ - - @register.filter(name="extract_value") def extract_value(html_input): match = re.search(r'value="([^"]*)"', html_input) From 90b4a642f0ccdeaad14ea396b7b80fb3f766d499 Mon Sep 17 00:00:00 2001 From: Rachid Mrad Date: Fri, 19 Jan 2024 14:16:12 -0500 Subject: [PATCH 033/137] Change the structure of the alerts to conform with DjA's conventions --- src/registrar/admin.py | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/src/registrar/admin.py b/src/registrar/admin.py index b2cc8144b..3dc789986 100644 --- a/src/registrar/admin.py +++ b/src/registrar/admin.py @@ -487,14 +487,13 @@ class ContactAdmin(ListHeaderAdmin): obj_id = obj.id change_url = reverse('admin:%s_%s_change' % (app_label, model_name), args=[obj_id]) related_objects.append((change_url, obj)) - + if related_objects: - message = f"

    Related Objects:

      " for url, obj in related_objects: - message += f"
    • {obj.__class__.__name__}: {obj}
    • " - message += "
    " - message_html = mark_safe(message) - messages.warning(request, message_html,) + message = f"Joined to {obj.__class__.__name__}: {obj}" + message_html = mark_safe(message) + messages.warning(request, message_html,) + return super().change_view(request, object_id, form_url, extra_context=extra_context) From 69adb0db4843f38a98ddd10f776e6a5996655eb1 Mon Sep 17 00:00:00 2001 From: David Kennedy Date: Fri, 19 Jan 2024 14:41:17 -0500 Subject: [PATCH 034/137] linting --- src/registrar/admin.py | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/src/registrar/admin.py b/src/registrar/admin.py index 3dc789986..57836ca9f 100644 --- a/src/registrar/admin.py +++ b/src/registrar/admin.py @@ -453,7 +453,7 @@ class ContactAdmin(ListHeaderAdmin): readonly_fields.extend([field for field in self.analyst_readonly_fields]) return readonly_fields # Read-only fields for analysts - def change_view(self, request, object_id, form_url='', extra_context=None): + def change_view(self, request, object_id, form_url="", extra_context=None): """Extend the change_view for Contact objects in django admin. Customize to display related objects to the Contact. These will be passed through the messages construct to the template for display to the user.""" @@ -472,7 +472,7 @@ class ContactAdmin(ListHeaderAdmin): if related_manager is not None: # Check if it's a ManyToManyField/reverse ForeignKey or a OneToOneField # Do this by checking for get_queryset method on the related_manager - if hasattr(related_manager, 'get_queryset'): + if hasattr(related_manager, "get_queryset"): # Handles ManyToManyRel and ManyToOneRel queryset = related_manager.get_queryset() else: @@ -485,15 +485,18 @@ class ContactAdmin(ListHeaderAdmin): app_label = obj._meta.app_label model_name = obj._meta.model_name obj_id = obj.id - change_url = reverse('admin:%s_%s_change' % (app_label, model_name), args=[obj_id]) + change_url = reverse("admin:%s_%s_change" % (app_label, model_name), args=[obj_id]) related_objects.append((change_url, obj)) - + if related_objects: for url, obj in related_objects: message = f"Joined to {obj.__class__.__name__}: {obj}" message_html = mark_safe(message) - messages.warning(request, message_html,) - + messages.warning( + request, + message_html, + ) + return super().change_view(request, object_id, form_url, extra_context=extra_context) From ae8220587ea9cdf2333cefa11c429827d023a2a5 Mon Sep 17 00:00:00 2001 From: Erin <121973038+erinysong@users.noreply.github.com> Date: Fri, 19 Jan 2024 11:48:53 -0800 Subject: [PATCH 035/137] Change submit button types on domain availability --- src/registrar/templates/application_dotgov_domain.html | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/registrar/templates/application_dotgov_domain.html b/src/registrar/templates/application_dotgov_domain.html index 22b4093c2..b1b952475 100644 --- a/src/registrar/templates/application_dotgov_domain.html +++ b/src/registrar/templates/application_dotgov_domain.html @@ -77,7 +77,7 @@ {% endwith %} {% endwith %} - From bcbd7927b3995e8b6c25c97fa9443b98d71e5a22 Mon Sep 17 00:00:00 2001 From: David Kennedy Date: Fri, 19 Jan 2024 14:59:52 -0500 Subject: [PATCH 036/137] more linting to account for mark_safe html --- src/registrar/admin.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/registrar/admin.py b/src/registrar/admin.py index 57836ca9f..033d13c2d 100644 --- a/src/registrar/admin.py +++ b/src/registrar/admin.py @@ -21,6 +21,7 @@ from auditlog.models import LogEntry # type: ignore from auditlog.admin import LogEntryAdmin # type: ignore from django_fsm import TransitionNotAllowed # type: ignore from django.utils.safestring import mark_safe +from django.utils.html import escape logger = logging.getLogger(__name__) @@ -490,8 +491,11 @@ class ContactAdmin(ListHeaderAdmin): if related_objects: for url, obj in related_objects: - message = f"Joined to {obj.__class__.__name__}: {obj}" - message_html = mark_safe(message) + escaped_obj = escape(obj) + message = f"Joined to {obj.__class__.__name__}: {escaped_obj}" + # message_html is considered safe html. It is generated from a finite list of strings + # which are generated from django objects. And a django object, which is escaped + message_html = mark_safe(message) # nosec messages.warning( request, message_html, From 816cbe23dd6e6b65e8edae4dd129049971fc775d Mon Sep 17 00:00:00 2001 From: zandercymatics <141044360+zandercymatics@users.noreply.github.com> Date: Mon, 22 Jan 2024 08:06:33 -0700 Subject: [PATCH 037/137] Add unit tests --- src/registrar/templates/domain_users.html | 8 ++-- src/registrar/tests/test_views.py | 56 +++++++++++++++++++++-- 2 files changed, 57 insertions(+), 7 deletions(-) diff --git a/src/registrar/templates/domain_users.html b/src/registrar/templates/domain_users.html index fa94c5f51..e7659e409 100644 --- a/src/registrar/templates/domain_users.html +++ b/src/registrar/templates/domain_users.html @@ -28,7 +28,7 @@ Email - Role + Role Action @@ -125,8 +125,8 @@ Email Date created - Status - Action + Status + Action @@ -137,7 +137,7 @@ {{ invitation.created_at|date }} {{ invitation.status|title }} -
    + {% csrf_token %}
    diff --git a/src/registrar/tests/test_views.py b/src/registrar/tests/test_views.py index bac76b5e2..d692fd3dc 100644 --- a/src/registrar/tests/test_views.py +++ b/src/registrar/tests/test_views.py @@ -2543,6 +2543,7 @@ class TestDomainManagers(TestDomainOverview): super().tearDown() self.user.is_staff = False self.user.save() + User.objects.all().delete() def test_domain_managers(self): response = self.client.get(reverse("domain-users", kwargs={"pk": self.domain.id})) @@ -2609,13 +2610,62 @@ class TestDomainManagers(TestDomainOverview): self.assertTrue(role_2_exists) # Check that the view no longer displays the deleted user - # TODO - why is this not working? + # why is this not working? Its not in the response when printed? # self.assertNotContains(response, "cheese@igorville.com") - @skip("TODO") def test_domain_delete_self_redirects_home(self): """Tests if deleting yourself redirects to home""" - raise + # Add additional users + dummy_user_1 = User.objects.create( + username="macncheese", + email="cheese@igorville.com", + ) + dummy_user_2 = User.objects.create( + username="pastapizza", + email="pasta@igorville.com", + ) + + role_1 = UserDomainRole.objects.create(user=dummy_user_1, domain=self.domain, role=UserDomainRole.Roles.MANAGER) + role_2 = UserDomainRole.objects.create(user=dummy_user_2, domain=self.domain, role=UserDomainRole.Roles.MANAGER) + + response = self.client.get(reverse("domain-users", kwargs={"pk": self.domain.id})) + + # Make sure we're on the right page + self.assertContains(response, "Domain managers") + + # Make sure the desired user exists + self.assertContains(response, "info@example.com") + + # Make sure more than one UserDomainRole exists on this object + self.assertContains(response, "cheese@igorville.com") + + # Delete the current user + response = self.client.post( + reverse("domain-user-delete", kwargs={"pk": self.domain.id, "user_pk": self.user.id}), follow=True + ) + + # Check if we've been redirected to the home page + self.assertContains(response, "Manage your domains") + + # Grab the displayed messages + messages = list(response.context["messages"]) + self.assertEqual(len(messages), 1) + + # Ensure the error we recieve is in line with what we expect + message = messages[0] + self.assertEqual(message.message, "You are no longer managing the domain igorville.gov") + self.assertEqual(message.tags, "success") + + # Ensure that the current user was deleted + current_user_exists = UserDomainRole.objects.filter(user=self.user.id).exists() + self.assertFalse(current_user_exists) + + # Ensure that the other userdomainroles are not deleted + role_1_exists = UserDomainRole.objects.filter(id=role_1.id).exists() + self.assertTrue(role_1_exists) + + role_2_exists = UserDomainRole.objects.filter(id=role_2.id).exists() + self.assertTrue(role_2_exists) @boto3_mocking.patching def test_domain_user_add_form(self): From b334fba42190af6aa19a17cb5235b3b35eae9e93 Mon Sep 17 00:00:00 2001 From: zandercymatics <141044360+zandercymatics@users.noreply.github.com> Date: Mon, 22 Jan 2024 08:15:30 -0700 Subject: [PATCH 038/137] Fix unit test --- src/registrar/tests/test_views.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/registrar/tests/test_views.py b/src/registrar/tests/test_views.py index d692fd3dc..3cb9a7792 100644 --- a/src/registrar/tests/test_views.py +++ b/src/registrar/tests/test_views.py @@ -2653,7 +2653,7 @@ class TestDomainManagers(TestDomainOverview): # Ensure the error we recieve is in line with what we expect message = messages[0] - self.assertEqual(message.message, "You are no longer managing the domain igorville.gov") + self.assertEqual(message.message, "You are no longer managing the domain igorville.gov.") self.assertEqual(message.tags, "success") # Ensure that the current user was deleted From 4e667ea54640c37fad7934e0d3f467884b428ebd Mon Sep 17 00:00:00 2001 From: zandercymatics <141044360+zandercymatics@users.noreply.github.com> Date: Mon, 22 Jan 2024 12:09:37 -0700 Subject: [PATCH 039/137] Minor styling change --- src/registrar/templates/domain_users.html | 2 +- src/registrar/templates/includes/form_messages.html | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/registrar/templates/domain_users.html b/src/registrar/templates/domain_users.html index e7659e409..cfcea717c 100644 --- a/src/registrar/templates/domain_users.html +++ b/src/registrar/templates/domain_users.html @@ -83,7 +83,7 @@ {% else %}
    - {{ message }} + {{ message }}
    From 421c2bd2ead62d4e7ec42ab95f24faf56c487fe3 Mon Sep 17 00:00:00 2001 From: zandercymatics <141044360+zandercymatics@users.noreply.github.com> Date: Mon, 22 Jan 2024 12:34:43 -0700 Subject: [PATCH 040/137] Remove redundant filter --- src/registrar/models/domain.py | 30 +++++++++++++++++++---------- src/registrar/utility/csv_export.py | 14 +++++--------- 2 files changed, 25 insertions(+), 19 deletions(-) diff --git a/src/registrar/models/domain.py b/src/registrar/models/domain.py index 1a581a4ec..3d64f8873 100644 --- a/src/registrar/models/domain.py +++ b/src/registrar/models/domain.py @@ -909,11 +909,22 @@ class Domain(TimeStampedModel, DomainHelper): """Time to renew. Not implemented.""" raise NotImplementedError() - def get_security_email(self): - logger.info("get_security_email-> getting the contact ") - secContact = self.security_contact - if secContact is not None: - return secContact.email + def get_security_email(self, skip_epp_call=False): + logger.info("get_security_email-> getting the contact") + + # If specified, skip the epp call outright. + # Otherwise, proceed as normal. + if skip_epp_call: + logger.info("get_security_email-> skipping epp call") + security = PublicContact.ContactTypeChoices.SECURITY + security_contact = self.generic_contact_getter(security, skip_epp_call) + else: + security_contact = self.security_contact + + # If we get a valid value for security_contact, pull its email + # Otherwise, just return nothing + if security_contact is not None and isinstance(security_contact, PublicContact): + return security_contact.email else: return None @@ -1110,7 +1121,7 @@ class Domain(TimeStampedModel, DomainHelper): ) raise error - def generic_contact_getter(self, contact_type_choice: PublicContact.ContactTypeChoices) -> PublicContact | None: + def generic_contact_getter(self, contact_type_choice: PublicContact.ContactTypeChoices, skip_epp_call=False) -> PublicContact | None: """Retrieves the desired PublicContact from the registry. This abstracts the caching and EPP retrieval for all contact items and thus may result in EPP calls being sent. @@ -1121,7 +1132,6 @@ class Domain(TimeStampedModel, DomainHelper): If you wanted to setup getter logic for Security, you would call: cache_contact_helper(PublicContact.ContactTypeChoices.SECURITY), or cache_contact_helper("security"). - """ # registrant_contact(s) are an edge case. They exist on # the "registrant" property as opposed to contacts. @@ -1131,7 +1141,7 @@ class Domain(TimeStampedModel, DomainHelper): try: # Grab from cache - contacts = self._get_property(desired_property) + contacts = self._get_property(desired_property, skip_epp_call) except KeyError as error: # if contact type is security, attempt to retrieve registry id # for the security contact from domain.security_contact_registry_id @@ -1866,9 +1876,9 @@ class Domain(TimeStampedModel, DomainHelper): """Remove cache data when updates are made.""" self._cache = {} - def _get_property(self, property): + def _get_property(self, property, skip_epp_call=False): """Get some piece of info about a domain.""" - if property not in self._cache: + if property not in self._cache and not skip_epp_call: self._fetch_cache( fetch_hosts=(property == "hosts"), fetch_contacts=(property == "contacts"), diff --git a/src/registrar/utility/csv_export.py b/src/registrar/utility/csv_export.py index 3924c03c4..1e5ae148f 100644 --- a/src/registrar/utility/csv_export.py +++ b/src/registrar/utility/csv_export.py @@ -24,9 +24,7 @@ def get_domain_infos(filter_condition, sort_fields): return domain_infos -def write_row(writer, columns, domain_info): - security_contacts = domain_info.domain.contacts.filter(contact_type=PublicContact.ContactTypeChoices.SECURITY) - +def write_row(writer, columns, domain_info: DomainInformation): # For linter ao = " " if domain_info.authorizing_official: @@ -34,9 +32,9 @@ def write_row(writer, columns, domain_info): last_name = domain_info.authorizing_official.last_name or "" ao = first_name + " " + last_name - security_email = " " - if security_contacts: - security_email = security_contacts[0].email + security_email = domain_info.domain.get_security_email(skip_epp_call=True) + if security_email is None: + security_email = " " invalid_emails = {"registrar@dotgov.gov", "dotgov@cisa.dhs.gov"} # These are default emails that should not be displayed in the csv report @@ -78,9 +76,7 @@ def write_body( """ # Get the domainInfos - domain_infos = get_domain_infos(filter_condition, sort_fields) - - all_domain_infos = list(domain_infos) + all_domain_infos = get_domain_infos(filter_condition, sort_fields) # Write rows to CSV for domain_info in all_domain_infos: From eb5ae025f8a58d217706ae42dd6127f4a8159989 Mon Sep 17 00:00:00 2001 From: zandercymatics <141044360+zandercymatics@users.noreply.github.com> Date: Mon, 22 Jan 2024 13:21:31 -0700 Subject: [PATCH 041/137] Additional improvements --- src/registrar/utility/csv_export.py | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/src/registrar/utility/csv_export.py b/src/registrar/utility/csv_export.py index 1e5ae148f..10fab2628 100644 --- a/src/registrar/utility/csv_export.py +++ b/src/registrar/utility/csv_export.py @@ -3,7 +3,6 @@ import logging from datetime import datetime from registrar.models.domain import Domain from registrar.models.domain_information import DomainInformation -from registrar.models.public_contact import PublicContact from django.db.models import Value from django.db.models.functions import Coalesce from django.utils import timezone @@ -24,29 +23,32 @@ def get_domain_infos(filter_condition, sort_fields): return domain_infos -def write_row(writer, columns, domain_info: DomainInformation): +def write_row(writer, columns, domain_info: DomainInformation, skip_epp_call=True): # For linter ao = " " if domain_info.authorizing_official: first_name = domain_info.authorizing_official.first_name or "" last_name = domain_info.authorizing_official.last_name or "" - ao = first_name + " " + last_name + ao = f"{first_name} {last_name}" - security_email = domain_info.domain.get_security_email(skip_epp_call=True) + security_email = domain_info.domain.get_security_email(skip_epp_call) if security_email is None: security_email = " " invalid_emails = {"registrar@dotgov.gov", "dotgov@cisa.dhs.gov"} # These are default emails that should not be displayed in the csv report - if security_email is not None and security_email.lower() in invalid_emails: + if security_email.lower() in invalid_emails: security_email = "(blank)" + if domain_info.federal_type: + domain_type = f"{domain_info.get_organization_type_display()} - {domain_info.get_federal_type_display()}" + else: + domain_type = domain_info.get_organization_type_display() + # create a dictionary of fields which can be included in output FIELDS = { "Domain name": domain_info.domain.name, - "Domain type": domain_info.get_organization_type_display() + " - " + domain_info.get_federal_type_display() - if domain_info.federal_type - else domain_info.get_organization_type_display(), + "Domain type": domain_type, "Agency": domain_info.federal_agency, "Organization name": domain_info.organization_name, "City": domain_info.city, @@ -61,7 +63,8 @@ def write_row(writer, columns, domain_info: DomainInformation): "Deleted": domain_info.domain.deleted, } - writer.writerow([FIELDS.get(column, "") for column in columns]) + row = [FIELDS.get(column, "") for column in columns] + writer.writerow(row) def write_body( From 63b31a4764041b6475a72e9ff4f7b8ee7638d88d Mon Sep 17 00:00:00 2001 From: zandercymatics <141044360+zandercymatics@users.noreply.github.com> Date: Mon, 22 Jan 2024 14:27:22 -0700 Subject: [PATCH 042/137] Additional performance improvements --- src/registrar/utility/csv_export.py | 75 ++++++++++++++++++++--------- 1 file changed, 52 insertions(+), 23 deletions(-) diff --git a/src/registrar/utility/csv_export.py b/src/registrar/utility/csv_export.py index 10fab2628..cf2e1484f 100644 --- a/src/registrar/utility/csv_export.py +++ b/src/registrar/utility/csv_export.py @@ -6,6 +6,11 @@ from registrar.models.domain_information import DomainInformation from django.db.models import Value from django.db.models.functions import Coalesce from django.utils import timezone +from django.core.paginator import Paginator +import time +from django.db.models import F, Value, CharField +from django.db.models.functions import Concat, Coalesce + logger = logging.getLogger(__name__) @@ -20,20 +25,35 @@ def write_header(writer, columns): def get_domain_infos(filter_condition, sort_fields): domain_infos = DomainInformation.objects.filter(**filter_condition).order_by(*sort_fields) - return domain_infos + + # Do a mass concat of the first and last name fields for authorizing_official. + # The old operation was computationally heavy for some reason, so if we precompute + # this here, it is vastly more efficient. + domain_infos_cleaned = domain_infos.annotate( + ao=Concat( + Coalesce(F('authorizing_official__first_name'), Value('')), + Value(' '), + Coalesce(F('authorizing_official__last_name'), Value('')), + output_field=CharField(), + ) + ) + return domain_infos_cleaned -def write_row(writer, columns, domain_info: DomainInformation, skip_epp_call=True): - # For linter - ao = " " - if domain_info.authorizing_official: - first_name = domain_info.authorizing_official.first_name or "" - last_name = domain_info.authorizing_official.last_name or "" - ao = f"{first_name} {last_name}" +def parse_row(columns, domain_info: DomainInformation, skip_epp_call=True): + """Given a set of columns, generate a new row from cleaned column data""" - security_email = domain_info.domain.get_security_email(skip_epp_call) + domain = domain_info.domain + + start_time = time.time() + # TODO - speed up + security_email = domain.security_contact_registry_id if security_email is None: - security_email = " " + cached_sec_email = domain.get_security_email(skip_epp_call) + security_email = cached_sec_email if cached_sec_email is not None else " " + + end_time = time.time() + print(f"parse security email operation took {end_time - start_time} seconds") invalid_emails = {"registrar@dotgov.gov", "dotgov@cisa.dhs.gov"} # These are default emails that should not be displayed in the csv report @@ -47,25 +67,24 @@ def write_row(writer, columns, domain_info: DomainInformation, skip_epp_call=Tru # create a dictionary of fields which can be included in output FIELDS = { - "Domain name": domain_info.domain.name, + "Domain name": domain.name, "Domain type": domain_type, "Agency": domain_info.federal_agency, "Organization name": domain_info.organization_name, "City": domain_info.city, "State": domain_info.state_territory, - "AO": ao, + "AO": domain_info.ao, "AO email": domain_info.authorizing_official.email if domain_info.authorizing_official else " ", "Security contact email": security_email, - "Status": domain_info.domain.get_state_display(), - "Expiration date": domain_info.domain.expiration_date, - "Created at": domain_info.domain.created_at, - "First ready": domain_info.domain.first_ready, - "Deleted": domain_info.domain.deleted, + "Status": domain.get_state_display(), + "Expiration date": domain.expiration_date, + "Created at": domain.created_at, + "First ready": domain.first_ready, + "Deleted": domain.deleted, } row = [FIELDS.get(column, "") for column in columns] - writer.writerow(row) - + return row def write_body( writer, @@ -81,9 +100,19 @@ def write_body( # Get the domainInfos all_domain_infos = get_domain_infos(filter_condition, sort_fields) - # Write rows to CSV - for domain_info in all_domain_infos: - write_row(writer, columns, domain_info) + # Reduce the memory overhead when performing the write operation + paginator = Paginator(all_domain_infos, 1000) + for page_num in paginator.page_range: + page = paginator.page(page_num) + rows = [] + start_time = time.time() + for domain_info in page.object_list: + row = parse_row(columns, domain_info) + rows.append(row) + + end_time = time.time() + print(f"new parse Operation took {end_time - start_time} seconds") + writer.writerows(rows) def export_data_type_to_csv(csv_file): @@ -150,7 +179,7 @@ def export_data_full_to_csv(csv_file): Domain.State.ON_HOLD, ], } - write_header(writer, columns) + write_header(writer, columns) write_body(writer, columns, sort_fields, filter_condition) From 7bd1356858c292ab53d894d65edca06bd3e22733 Mon Sep 17 00:00:00 2001 From: zandercymatics <141044360+zandercymatics@users.noreply.github.com> Date: Mon, 22 Jan 2024 15:02:45 -0700 Subject: [PATCH 043/137] Additional optimizations --- src/registrar/utility/csv_export.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/registrar/utility/csv_export.py b/src/registrar/utility/csv_export.py index cf2e1484f..5d3b7a46d 100644 --- a/src/registrar/utility/csv_export.py +++ b/src/registrar/utility/csv_export.py @@ -24,7 +24,9 @@ def write_header(writer, columns): def get_domain_infos(filter_condition, sort_fields): - domain_infos = DomainInformation.objects.filter(**filter_condition).order_by(*sort_fields) + domain_infos = DomainInformation.objects.select_related( + 'domain', 'authorizing_official' + ).filter(**filter_condition).order_by(*sort_fields) # Do a mass concat of the first and last name fields for authorizing_official. # The old operation was computationally heavy for some reason, so if we precompute @@ -46,7 +48,6 @@ def parse_row(columns, domain_info: DomainInformation, skip_epp_call=True): domain = domain_info.domain start_time = time.time() - # TODO - speed up security_email = domain.security_contact_registry_id if security_email is None: cached_sec_email = domain.get_security_email(skip_epp_call) @@ -82,8 +83,10 @@ def parse_row(columns, domain_info: DomainInformation, skip_epp_call=True): "First ready": domain.first_ready, "Deleted": domain.deleted, } - + start_time = time.time() row = [FIELDS.get(column, "") for column in columns] + end_time = time.time() + print(f"parse some cols operation took {end_time - start_time} seconds") return row def write_body( @@ -101,6 +104,7 @@ def write_body( all_domain_infos = get_domain_infos(filter_condition, sort_fields) # Reduce the memory overhead when performing the write operation + a1_start_time = time.time() paginator = Paginator(all_domain_infos, 1000) for page_num in paginator.page_range: page = paginator.page(page_num) @@ -114,6 +118,8 @@ def write_body( print(f"new parse Operation took {end_time - start_time} seconds") writer.writerows(rows) + a1_end_time = time.time() + print(f"parse all stuff operation took {a1_end_time - a1_start_time} seconds") def export_data_type_to_csv(csv_file): """All domains report with extra columns""" From c8513bbfdcd8c8a9ef7e17811ae5f5aa8a49ffe9 Mon Sep 17 00:00:00 2001 From: David Kennedy Date: Mon, 22 Jan 2024 17:09:13 -0500 Subject: [PATCH 044/137] updated email output for application submission, and updated associated tests --- .../emails/includes/application_summary.txt | 19 +++++++++++++++++-- src/registrar/tests/test_emails.py | 3 ++- 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/src/registrar/templates/emails/includes/application_summary.txt b/src/registrar/templates/emails/includes/application_summary.txt index 215564feb..2c3564ad7 100644 --- a/src/registrar/templates/emails/includes/application_summary.txt +++ b/src/registrar/templates/emails/includes/application_summary.txt @@ -2,7 +2,19 @@ SUMMARY OF YOUR DOMAIN REQUEST Type of organization: {{ application.get_organization_type_display }} - +{% if application.show_organization_federal %} +Federal government branch: +{{ application.get_federal_type_display }} +{% elif application.show_tribal_government %} +Tribal government: +{{ application.tribe_name|default:"Incomplete" }}{% if application.federally_recognized_tribe %} +Federally-recognized tribe +{% endif %}{% if application.state_recognized_tribe %} +State-recognized tribe +{% endif %}{% endif %}{% if application.show_organization_election %} +Election office: +{{ application.is_election_board|yesno:"Yes,No,Incomplete" }} +{% endif %} Organization name and mailing address: {% spaceless %}{{ application.organization_name }} {{ application.address_line1 }}{% if application.address_line2 %} @@ -35,7 +47,10 @@ Your contact information: Other employees from your organization: {% for other in application.other_contacts.all %} {% spaceless %}{% include "emails/includes/contact.txt" with contact=other %}{% endspaceless %} -{% endfor %}{% endif %}{% if application.anything_else %} +{% endfor %}{% else %} +No other employees from your organization? +{{ application.no_other_contacts_rationale }} +{% endif %}{% if application.anything_else %} Anything else? {{ application.anything_else }} {% endif %} \ No newline at end of file diff --git a/src/registrar/tests/test_emails.py b/src/registrar/tests/test_emails.py index ae84980ff..d21358402 100644 --- a/src/registrar/tests/test_emails.py +++ b/src/registrar/tests/test_emails.py @@ -104,7 +104,8 @@ class TestEmails(TestCase): body = kwargs["Content"]["Simple"]["Body"]["Text"]["Data"] self.assertNotIn("Other employees from your organization:", body) # spacing should be right between adjacent elements - self.assertRegex(body, r"5556\n\nAnything else") + self.assertRegex(body, r"5556\n\nNo other employees") + self.assertRegex(body, r"None\n\nAnything else") @boto3_mocking.patching def test_submission_confirmation_alternative_govdomain_spacing(self): From 3838be3960c004d33ea0c28050e7d05fc8df88d0 Mon Sep 17 00:00:00 2001 From: zandercymatics <141044360+zandercymatics@users.noreply.github.com> Date: Mon, 22 Jan 2024 15:09:50 -0700 Subject: [PATCH 045/137] Linting --- src/registrar/utility/csv_export.py | 33 +++++++++++------------------ 1 file changed, 12 insertions(+), 21 deletions(-) diff --git a/src/registrar/utility/csv_export.py b/src/registrar/utility/csv_export.py index 5d3b7a46d..3b671c9cc 100644 --- a/src/registrar/utility/csv_export.py +++ b/src/registrar/utility/csv_export.py @@ -7,7 +7,6 @@ from django.db.models import Value from django.db.models.functions import Coalesce from django.utils import timezone from django.core.paginator import Paginator -import time from django.db.models import F, Value, CharField from django.db.models.functions import Concat, Coalesce @@ -24,18 +23,20 @@ def write_header(writer, columns): def get_domain_infos(filter_condition, sort_fields): - domain_infos = DomainInformation.objects.select_related( - 'domain', 'authorizing_official' - ).filter(**filter_condition).order_by(*sort_fields) + domain_infos = ( + DomainInformation.objects.select_related("domain", "authorizing_official") + .filter(**filter_condition) + .order_by(*sort_fields) + ) # Do a mass concat of the first and last name fields for authorizing_official. # The old operation was computationally heavy for some reason, so if we precompute # this here, it is vastly more efficient. domain_infos_cleaned = domain_infos.annotate( ao=Concat( - Coalesce(F('authorizing_official__first_name'), Value('')), - Value(' '), - Coalesce(F('authorizing_official__last_name'), Value('')), + Coalesce(F("authorizing_official__first_name"), Value("")), + Value(" "), + Coalesce(F("authorizing_official__last_name"), Value("")), output_field=CharField(), ) ) @@ -47,15 +48,11 @@ def parse_row(columns, domain_info: DomainInformation, skip_epp_call=True): domain = domain_info.domain - start_time = time.time() security_email = domain.security_contact_registry_id if security_email is None: cached_sec_email = domain.get_security_email(skip_epp_call) security_email = cached_sec_email if cached_sec_email is not None else " " - end_time = time.time() - print(f"parse security email operation took {end_time - start_time} seconds") - invalid_emails = {"registrar@dotgov.gov", "dotgov@cisa.dhs.gov"} # These are default emails that should not be displayed in the csv report if security_email.lower() in invalid_emails: @@ -83,12 +80,11 @@ def parse_row(columns, domain_info: DomainInformation, skip_epp_call=True): "First ready": domain.first_ready, "Deleted": domain.deleted, } - start_time = time.time() + row = [FIELDS.get(column, "") for column in columns] - end_time = time.time() - print(f"parse some cols operation took {end_time - start_time} seconds") return row + def write_body( writer, columns, @@ -109,17 +105,12 @@ def write_body( for page_num in paginator.page_range: page = paginator.page(page_num) rows = [] - start_time = time.time() for domain_info in page.object_list: row = parse_row(columns, domain_info) rows.append(row) - - end_time = time.time() - print(f"new parse Operation took {end_time - start_time} seconds") + writer.writerows(rows) - a1_end_time = time.time() - print(f"parse all stuff operation took {a1_end_time - a1_start_time} seconds") def export_data_type_to_csv(csv_file): """All domains report with extra columns""" @@ -185,7 +176,7 @@ def export_data_full_to_csv(csv_file): Domain.State.ON_HOLD, ], } - write_header(writer, columns) + write_header(writer, columns) write_body(writer, columns, sort_fields, filter_condition) From 59486a922d24d7aa69bd000ad58c96b90567fbd4 Mon Sep 17 00:00:00 2001 From: zandercymatics <141044360+zandercymatics@users.noreply.github.com> Date: Mon, 22 Jan 2024 15:19:28 -0700 Subject: [PATCH 046/137] Remove accidental inclusion --- src/registrar/utility/csv_export.py | 1 - 1 file changed, 1 deletion(-) diff --git a/src/registrar/utility/csv_export.py b/src/registrar/utility/csv_export.py index 3b671c9cc..c94f05131 100644 --- a/src/registrar/utility/csv_export.py +++ b/src/registrar/utility/csv_export.py @@ -100,7 +100,6 @@ def write_body( all_domain_infos = get_domain_infos(filter_condition, sort_fields) # Reduce the memory overhead when performing the write operation - a1_start_time = time.time() paginator = Paginator(all_domain_infos, 1000) for page_num in paginator.page_range: page = paginator.page(page_num) From ec7c2244402e59f311272b62a62557da262f17a2 Mon Sep 17 00:00:00 2001 From: zandercymatics <141044360+zandercymatics@users.noreply.github.com> Date: Mon, 22 Jan 2024 15:30:28 -0700 Subject: [PATCH 047/137] Fix bug --- src/registrar/utility/csv_export.py | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/registrar/utility/csv_export.py b/src/registrar/utility/csv_export.py index c94f05131..a65fc283c 100644 --- a/src/registrar/utility/csv_export.py +++ b/src/registrar/utility/csv_export.py @@ -48,10 +48,8 @@ def parse_row(columns, domain_info: DomainInformation, skip_epp_call=True): domain = domain_info.domain - security_email = domain.security_contact_registry_id - if security_email is None: - cached_sec_email = domain.get_security_email(skip_epp_call) - security_email = cached_sec_email if cached_sec_email is not None else " " + cached_sec_email = domain.get_security_email(skip_epp_call) + security_email = cached_sec_email if cached_sec_email is not None else " " invalid_emails = {"registrar@dotgov.gov", "dotgov@cisa.dhs.gov"} # These are default emails that should not be displayed in the csv report From f21287c0c74158199f972dc07c2c37f8ec4e4b60 Mon Sep 17 00:00:00 2001 From: zandercymatics <141044360+zandercymatics@users.noreply.github.com> Date: Mon, 22 Jan 2024 15:54:00 -0700 Subject: [PATCH 048/137] Linting --- src/registrar/models/domain.py | 4 +++- src/registrar/utility/csv_export.py | 1 - 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/registrar/models/domain.py b/src/registrar/models/domain.py index 3d64f8873..0cbe8c071 100644 --- a/src/registrar/models/domain.py +++ b/src/registrar/models/domain.py @@ -1121,7 +1121,9 @@ class Domain(TimeStampedModel, DomainHelper): ) raise error - def generic_contact_getter(self, contact_type_choice: PublicContact.ContactTypeChoices, skip_epp_call=False) -> PublicContact | None: + def generic_contact_getter( + self, contact_type_choice: PublicContact.ContactTypeChoices, skip_epp_call=False + ) -> PublicContact | None: """Retrieves the desired PublicContact from the registry. This abstracts the caching and EPP retrieval for all contact items and thus may result in EPP calls being sent. diff --git a/src/registrar/utility/csv_export.py b/src/registrar/utility/csv_export.py index a65fc283c..e513dc3d3 100644 --- a/src/registrar/utility/csv_export.py +++ b/src/registrar/utility/csv_export.py @@ -3,7 +3,6 @@ import logging from datetime import datetime from registrar.models.domain import Domain from registrar.models.domain_information import DomainInformation -from django.db.models import Value from django.db.models.functions import Coalesce from django.utils import timezone from django.core.paginator import Paginator From ac6d46b9f8c1cde61b77721ba8660b7cb7ad09ad Mon Sep 17 00:00:00 2001 From: Rachid Mrad Date: Mon, 22 Jan 2024 19:36:02 -0500 Subject: [PATCH 049/137] IMplement add form for alternative domains --- src/registrar/assets/js/get-gov.js | 63 ++++++++++++++++--- src/registrar/forms/application_wizard.py | 2 +- .../templates/application_dotgov_domain.html | 26 ++++---- 3 files changed, 68 insertions(+), 23 deletions(-) diff --git a/src/registrar/assets/js/get-gov.js b/src/registrar/assets/js/get-gov.js index 3995e975c..fc6cfbe61 100644 --- a/src/registrar/assets/js/get-gov.js +++ b/src/registrar/assets/js/get-gov.js @@ -48,6 +48,7 @@ function createLiveRegion(id) { /** Announces changes to assistive technology users. */ function announce(id, text) { + console.log('announce: ' + text) let liveRegion = document.getElementById(id + "-live-region"); if (!liveRegion) liveRegion = createLiveRegion(id); liveRegion.innerHTML = text; @@ -86,6 +87,7 @@ function fetchJSON(endpoint, callback, url="/api/v1/") { /** Modifies CSS and HTML when an input is valid/invalid. */ function toggleInputValidity(el, valid, msg=DEFAULT_ERROR) { + console.log('toggleInputValidity: ' + valid) if (valid) { el.setCustomValidity(""); el.removeAttribute("aria-invalid"); @@ -100,6 +102,7 @@ function toggleInputValidity(el, valid, msg=DEFAULT_ERROR) { /** Display (or hide) a message beneath an element. */ function inlineToast(el, id, style, msg) { + console.log('inine toast creates alerts') if (!el.id && !id) { console.error("Elements must have an `id` to show an inline toast."); return; @@ -130,8 +133,10 @@ function inlineToast(el, id, style, msg) { } } -function _checkDomainAvailability(el) { +function checkDomainAvailability(el) { + console.log('checkDomainAvailability: ' + el.value) const callback = (response) => { + console.log('inside callback') toggleInputValidity(el, (response && response.available), msg=response.message); announce(el.id, response.message); @@ -142,6 +147,7 @@ function _checkDomainAvailability(el) { // use of `parentElement` due to .gov inputs being wrapped in www/.gov decoration inlineToast(el.parentElement, el.id, SUCCESS, response.message); } else if (ignore_blank && response.code == "required"){ + console.log('ignore_blank && response.code == "required"') // Visually remove the error error = "usa-input--error" if (el.classList.contains(error)){ @@ -155,7 +161,7 @@ function _checkDomainAvailability(el) { } /** Call the API to see if the domain is good. */ -const checkDomainAvailability = debounce(_checkDomainAvailability); +// const checkDomainAvailability = debounce(_checkDomainAvailability); /** Hides the toast message and clears the aira live region. */ function clearDomainAvailability(el) { @@ -167,6 +173,7 @@ function clearDomainAvailability(el) { /** Runs all the validators associated with this element. */ function runValidators(el) { + console.log(el.getAttribute("id")) const attribute = el.getAttribute("validate") || ""; if (!attribute.length) return; const validators = attribute.split(" "); @@ -207,12 +214,37 @@ function handleInputValidation(e) { /** On button click, handles running any associated validators. */ function handleValidationClick(e) { + console.log('validating dotgov domain') + const attribute = e.target.getAttribute("validate-for") || ""; if (!attribute.length) return; - const input = document.getElementById(attribute); + + const input = document.getElementById(attribute); // You might need to define 'attribute' runValidators(input); } + +function handleFormsetValidationClick(e) { + // Check availability for alternative domains + + console.log('validating alternative domains') + + const alternativeDomainsAvailability = document.getElementById('check-availability-for-alternative-domains'); + + // Collect input IDs from the repeatable forms + let inputIds = Array.from(document.querySelectorAll('.repeatable-form input')).map(input => input.id); + + // Run validators for each input + inputIds.forEach(inputId => { + const input = document.getElementById(inputId); + runValidators(input); + }); + + // Set the validate-for attribute on the button with the collected input IDs + // Not needed for functionality but nice for accessibility + alternativeDomainsAvailability.setAttribute('validate-for', inputIds.join(', ')); +} + // <<>><<>><<>><<>><<>><<>><<>><<>><<>><<>><<>><<>><<>><<>><<>> // Initialization code. @@ -232,9 +264,16 @@ function handleValidationClick(e) { for(const input of needsValidation) { input.addEventListener('input', handleInputValidation); } + const dotgovDomainsAvailability = document.getElementById('check-availability-for-dotgov-domain'); + const alternativeDomainsAvailability = document.getElementById('check-availability-for-alternative-domains'); const activatesValidation = document.querySelectorAll('[validate-for]'); for(const button of activatesValidation) { - button.addEventListener('click', handleValidationClick); + if (alternativeDomainsAvailability) { + alternativeDomainsAvailability.addEventListener('click', handleFormsetValidationClick); + dotgovDomainsAvailability.addEventListener('click', handleValidationClick); + } else { + button.addEventListener('click', handleValidationClick); + } } })(); @@ -453,6 +492,7 @@ function hideDeletedForms() { let isNameserversForm = document.querySelector(".nameservers-form"); let isOtherContactsForm = document.querySelector(".other-contacts-form"); let isDsDataForm = document.querySelector(".ds-data-form"); + let isDotgovDomain = document.querySelector(".dotgov-domain-form"); // The Nameservers formset features 2 required and 11 optionals if (isNameserversForm) { cloneIndex = 2; @@ -465,6 +505,8 @@ function hideDeletedForms() { formLabel = "Organization contact"; container = document.querySelector("#other-employees"); formIdentifier = "other_contacts" + } else if (isDotgovDomain) { + formIdentifier = "dotgov_domain" } let totalForms = document.querySelector(`#id_${formIdentifier}-TOTAL_FORMS`); @@ -539,6 +581,7 @@ function hideDeletedForms() { // Reset the values of each input to blank inputs.forEach((input) => { input.classList.remove("usa-input--error"); + input.classList.remove("usa-input--success"); if (input.type === "text" || input.type === "number" || input.type === "password" || input.type === "email" || input.type === "tel") { input.value = ""; // Set the value to an empty string @@ -551,22 +594,25 @@ function hideDeletedForms() { let selects = newForm.querySelectorAll("select"); selects.forEach((select) => { select.classList.remove("usa-input--error"); + select.classList.remove("usa-input--success"); select.selectedIndex = 0; // Set the value to an empty string }); let labels = newForm.querySelectorAll("label"); labels.forEach((label) => { label.classList.remove("usa-label--error"); + label.classList.remove("usa-label--success"); }); let usaFormGroups = newForm.querySelectorAll(".usa-form-group"); usaFormGroups.forEach((usaFormGroup) => { usaFormGroup.classList.remove("usa-form-group--error"); + usaFormGroup.classList.remove("usa-form-group--success"); }); - // Remove any existing error messages - let usaErrorMessages = newForm.querySelectorAll(".usa-error-message"); - usaErrorMessages.forEach((usaErrorMessage) => { + // Remove any existing error and success messages + let usaMessages = newForm.querySelectorAll(".usa-error-message, .usa-alert"); + usaMessages.forEach((usaErrorMessage) => { let parentDiv = usaErrorMessage.closest('div'); if (parentDiv) { parentDiv.remove(); // Remove the parent div if it exists @@ -577,7 +623,8 @@ function hideDeletedForms() { // Attach click event listener on the delete buttons of the new form let newDeleteButton = newForm.querySelector(".delete-record"); - prepareNewDeleteButton(newDeleteButton, formLabel); + if (newDeleteButton) + prepareNewDeleteButton(newDeleteButton, formLabel); // Disable the add more button if we have 13 forms if (isNameserversForm && formNum == 13) { diff --git a/src/registrar/forms/application_wizard.py b/src/registrar/forms/application_wizard.py index ae6188133..284705a9a 100644 --- a/src/registrar/forms/application_wizard.py +++ b/src/registrar/forms/application_wizard.py @@ -420,7 +420,7 @@ class AlternativeDomainForm(RegistrarForm): alternative_domain = forms.CharField( required=False, - label="", + label="Alternative domain", ) diff --git a/src/registrar/templates/application_dotgov_domain.html b/src/registrar/templates/application_dotgov_domain.html index b1b952475..74c6dce06 100644 --- a/src/registrar/templates/application_dotgov_domain.html +++ b/src/registrar/templates/application_dotgov_domain.html @@ -48,7 +48,7 @@ {% endwith %} {% endwith %}

    If you’re not sure this is the domain you want, that’s ok. You can change the domain later.

    From 8405600cef8a015cb4eec17b139d79e9cc8f3dd2 Mon Sep 17 00:00:00 2001 From: zandercymatics <141044360+zandercymatics@users.noreply.github.com> Date: Tue, 23 Jan 2024 11:03:01 -0700 Subject: [PATCH 050/137] Linting --- src/registrar/utility/csv_export.py | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/src/registrar/utility/csv_export.py b/src/registrar/utility/csv_export.py index e513dc3d3..68dc126db 100644 --- a/src/registrar/utility/csv_export.py +++ b/src/registrar/utility/csv_export.py @@ -3,7 +3,6 @@ import logging from datetime import datetime from registrar.models.domain import Domain from registrar.models.domain_information import DomainInformation -from django.db.models.functions import Coalesce from django.utils import timezone from django.core.paginator import Paginator from django.db.models import F, Value, CharField @@ -45,7 +44,11 @@ def get_domain_infos(filter_condition, sort_fields): def parse_row(columns, domain_info: DomainInformation, skip_epp_call=True): """Given a set of columns, generate a new row from cleaned column data""" - domain = domain_info.domain + # Domain should never be none when parsing this information + if domain_info.domain is None: + raise ValueError("Domain is none") + + domain = domain_info.domain # type: ignore cached_sec_email = domain.get_security_email(skip_epp_call) security_email = cached_sec_email if cached_sec_email is not None else " " @@ -68,7 +71,7 @@ def parse_row(columns, domain_info: DomainInformation, skip_epp_call=True): "Organization name": domain_info.organization_name, "City": domain_info.city, "State": domain_info.state_territory, - "AO": domain_info.ao, + "AO": domain_info.ao, # type: ignore "AO email": domain_info.authorizing_official.email if domain_info.authorizing_official else " ", "Security contact email": security_email, "Status": domain.get_state_display(), @@ -102,8 +105,14 @@ def write_body( page = paginator.page(page_num) rows = [] for domain_info in page.object_list: - row = parse_row(columns, domain_info) - rows.append(row) + try: + row = parse_row(columns, domain_info) + rows.append(row) + except ValueError: + # This should not happen. If it does, just skip this row. + # It indicates that DomainInformation.domain is None. + logger.error("csv_export -> Error when parsing row, domain was None") + continue writer.writerows(rows) From 259d713ed61fb83f6c30d2000dcad07546fb91f8 Mon Sep 17 00:00:00 2001 From: Rebecca Hsieh Date: Tue, 23 Jan 2024 10:34:23 -0800 Subject: [PATCH 051/137] Swap to INFO setting --- src/registrar/assets/js/get-gov.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/registrar/assets/js/get-gov.js b/src/registrar/assets/js/get-gov.js index fc6cfbe61..f38fc3813 100644 --- a/src/registrar/assets/js/get-gov.js +++ b/src/registrar/assets/js/get-gov.js @@ -143,9 +143,9 @@ function checkDomainAvailability(el) { // Determines if we ignore the field if it is just blank ignore_blank = el.classList.contains("blank-ok") if (el.validity.valid) { - el.classList.add('usa-input--success'); + el.classList.add('usa-input--info'); // use of `parentElement` due to .gov inputs being wrapped in www/.gov decoration - inlineToast(el.parentElement, el.id, SUCCESS, response.message); + inlineToast(el.parentElement, el.id, INFORMATIVE, response.message); } else if (ignore_blank && response.code == "required"){ console.log('ignore_blank && response.code == "required"') // Visually remove the error From a9a256127a63ecbd9cac9583693533b1ef6bd5cb Mon Sep 17 00:00:00 2001 From: David Kennedy Date: Tue, 23 Jan 2024 13:47:47 -0500 Subject: [PATCH 052/137] put all messages in one warning, rather than multiple --- src/registrar/admin.py | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/registrar/admin.py b/src/registrar/admin.py index 033d13c2d..7b196bfa2 100644 --- a/src/registrar/admin.py +++ b/src/registrar/admin.py @@ -490,16 +490,17 @@ class ContactAdmin(ListHeaderAdmin): related_objects.append((change_url, obj)) if related_objects: + message = "" for url, obj in related_objects: escaped_obj = escape(obj) - message = f"Joined to {obj.__class__.__name__}:
    {escaped_obj}" + message += f"Joined to {obj.__class__.__name__}: {escaped_obj}
    " # message_html is considered safe html. It is generated from a finite list of strings # which are generated from django objects. And a django object, which is escaped - message_html = mark_safe(message) # nosec - messages.warning( - request, - message_html, - ) + message_html = mark_safe(message) # nosec + messages.warning( + request, + message_html, + ) return super().change_view(request, object_id, form_url, extra_context=extra_context) From 19c72b18582bd0ef4141c0120cc4ef18ec926cc3 Mon Sep 17 00:00:00 2001 From: David Kennedy Date: Tue, 23 Jan 2024 14:01:36 -0500 Subject: [PATCH 053/137] incremental update to html --- .../templates/application_review.html | 22 +++++++++---------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/src/registrar/templates/application_review.html b/src/registrar/templates/application_review.html index dd2507d1b..057df6380 100644 --- a/src/registrar/templates/application_review.html +++ b/src/registrar/templates/application_review.html @@ -29,10 +29,10 @@ {% if step == Step.ORGANIZATION_TYPE %} {% if application.organization_type is not None %} {% with long_org_type=application.organization_type|get_organization_long_name %} - {{ long_org_type }} +

    {{ long_org_type }}

    {% endwith %} {% else %} - Incomplete +

    Incomplete

    {% endif %} {% endif %} {% if step == Step.TRIBAL_GOVERNMENT %} @@ -41,16 +41,16 @@ {% if application.state_recognized_tribe %}

    State-recognized tribe

    {% endif %} {% endif %} {% if step == Step.ORGANIZATION_FEDERAL %} - {{ application.get_federal_type_display|default:"Incomplete" }} +

    {{ application.get_federal_type_display|default:"Incomplete" }}

    {% endif %} {% if step == Step.ORGANIZATION_ELECTION %} - {{ application.is_election_board|yesno:"Yes,No,Incomplete" }} +

    {{ application.is_election_board|yesno:"Yes,No,Incomplete" }}

    {% endif %} {% if step == Step.ORGANIZATION_CONTACT %} {% if application.organization_name %} {% include "includes/organization_address.html" with organization=application %} {% else %} - Incomplete +

    Incomplete

    {% endif %} {% endif %} {% if step == Step.ABOUT_YOUR_ORGANIZATION %} @@ -62,7 +62,7 @@ {% include "includes/contact.html" with contact=application.authorizing_official %}
    {% else %} - Incomplete +

    Incomplete

    {% endif %} {% endif %} {% if step == Step.CURRENT_SITES %} @@ -90,7 +90,7 @@ {% endif %} {% endif %} {% if step == Step.PURPOSE %} - {{ application.purpose|default:"Incomplete" }} +

    {{ application.purpose|default:"Incomplete" }}

    {% endif %} {% if step == Step.YOUR_CONTACT %} {% if application.submitter %} @@ -98,7 +98,7 @@ {% include "includes/contact.html" with contact=application.submitter %} {% else %} - Incomplete +

    Incomplete

    {% endif %} {% endif %} {% if step == Step.OTHER_CONTACTS %} @@ -110,15 +110,15 @@ {% empty %}

    No other employees from your organization?

    - {{ application.no_other_contacts_rationale|default:"Incomplete" }} +

    {{ application.no_other_contacts_rationale|default:"Incomplete" }}

    {% endfor %} {% endif %} {% if step == Step.ANYTHING_ELSE %} - {{ application.anything_else|default:"No" }} +

    {{ application.anything_else|default:"No" }}

    {% endif %} {% if step == Step.REQUIREMENTS %} - {{ application.is_policy_acknowledged|yesno:"I agree.,I do not agree.,I do not agree." }} +

    {{ application.is_policy_acknowledged|yesno:"I agree.,I do not agree.,I do not agree." }}

    {% endif %} From 8417c773683d7c8fe1c22a34981228ce41533d54 Mon Sep 17 00:00:00 2001 From: zandercymatics <141044360+zandercymatics@users.noreply.github.com> Date: Tue, 23 Jan 2024 13:21:52 -0700 Subject: [PATCH 054/137] Code cleanup --- src/registrar/assets/sass/_theme/_buttons.scss | 6 +++--- src/registrar/templates/dashboard_base.html | 6 +++--- src/registrar/templates/domain_users.html | 12 +++--------- src/registrar/tests/test_views.py | 4 ---- src/registrar/views/application.py | 8 -------- src/registrar/views/domain.py | 8 +++----- 6 files changed, 12 insertions(+), 32 deletions(-) diff --git a/src/registrar/assets/sass/_theme/_buttons.scss b/src/registrar/assets/sass/_theme/_buttons.scss index 78c06f0f4..b168551b5 100644 --- a/src/registrar/assets/sass/_theme/_buttons.scss +++ b/src/registrar/assets/sass/_theme/_buttons.scss @@ -31,7 +31,7 @@ a.usa-button.disabled-link { color: #454545 !important } -a.usa-button.disabled-link:hover{ +a.usa-button.disabled-link:hover { background-color: #ccc !important; cursor: not-allowed !important; color: #454545 !important @@ -47,8 +47,8 @@ a.usa-button.disabled-link:focus { a.usa-button--unstyled.disabled-link, a.usa-button--unstyled.disabled-link:hover, a.usa-button--unstyled.disabled-link:focus { - cursor: not-allowed !important; - outline: none !important; + cursor: not-allowed; + outline: none; } a.usa-button:not(.usa-button--unstyled, .usa-button--outline) { diff --git a/src/registrar/templates/dashboard_base.html b/src/registrar/templates/dashboard_base.html index 46b04570b..6dd2ce8fd 100644 --- a/src/registrar/templates/dashboard_base.html +++ b/src/registrar/templates/dashboard_base.html @@ -11,10 +11,10 @@ {% if messages %} {% endif %} {% endblock %} diff --git a/src/registrar/templates/domain_users.html b/src/registrar/templates/domain_users.html index cfcea717c..e22800677 100644 --- a/src/registrar/templates/domain_users.html +++ b/src/registrar/templates/domain_users.html @@ -92,13 +92,6 @@ {% endif %} - {% comment %} - usa-tooltip disabled-link" - data-position="right" - title="Coming in 2024" - aria-disabled="true" - data-tooltip="true" - {% endcomment %} {% endfor %} @@ -137,8 +130,9 @@ {{ invitation.created_at|date }} {{ invitation.status|title }} -
    - {% csrf_token %} + + + {% csrf_token %}
    diff --git a/src/registrar/tests/test_views.py b/src/registrar/tests/test_views.py index 5a32615a4..b128724a0 100644 --- a/src/registrar/tests/test_views.py +++ b/src/registrar/tests/test_views.py @@ -2740,10 +2740,6 @@ class TestDomainManagers(TestDomainOverview): role_2_exists = UserDomainRole.objects.filter(id=role_2.id).exists() self.assertTrue(role_2_exists) - # Check that the view no longer displays the deleted user - # why is this not working? Its not in the response when printed? - # self.assertNotContains(response, "cheese@igorville.com") - def test_domain_delete_self_redirects_home(self): """Tests if deleting yourself redirects to home""" # Add additional users diff --git a/src/registrar/views/application.py b/src/registrar/views/application.py index 4e7180cd7..031b93dee 100644 --- a/src/registrar/views/application.py +++ b/src/registrar/views/application.py @@ -481,14 +481,6 @@ class DotgovDomain(ApplicationWizard): context["federal_type"] = self.application.federal_type return context - def post(self, request, *args, **kwargs): - """Override for the post method to mark the DraftDomain as complete""" - response = super().post(request, *args, **kwargs) - # Set the DraftDomain to "complete" - self.application.requested_domain.is_incomplete = False - self.application.save() - return response - class Purpose(ApplicationWizard): template_name = "application_purpose.html" diff --git a/src/registrar/views/domain.py b/src/registrar/views/domain.py index bbf3d43a0..08ac0424d 100644 --- a/src/registrar/views/domain.py +++ b/src/registrar/views/domain.py @@ -651,13 +651,14 @@ class DomainUsersView(DomainBaseView): # Determine if the current user can delete managers domain_pk = None can_delete_users = False + if self.kwargs is not None and "pk" in self.kwargs: domain_pk = self.kwargs["pk"] # Prevent the end user from deleting themselves as a manager if they are the # only manager that exists on a domain. can_delete_users = UserDomainRole.objects.filter(domain__id=domain_pk).count() > 1 - context["can_delete_users"] = can_delete_users + context["can_delete_users"] = can_delete_users return context def _add_modal_buttons_to_context(self, context): @@ -689,7 +690,6 @@ class DomainUsersView(DomainBaseView): class_list = classes html_class = f'class="{class_list}"' if class_list else None - modal_button = '' return modal_button @@ -831,7 +831,7 @@ class DomainDeleteUserView(UserDomainRolePermissionDeleteView): if email_or_name is None or email_or_name.strip() == "": email_or_name = self.object.user - # If the user is deleting themselves, return a special message. + # If the user is deleting themselves, return a specific message. # If not, return something more generic. if delete_self: message = f"You are no longer managing the domain {self.object.domain}." @@ -842,14 +842,12 @@ class DomainDeleteUserView(UserDomainRolePermissionDeleteView): def form_valid(self, form): """Delete the specified user on this domain.""" - super().form_valid(form) # Is the user deleting themselves? If so, display a different message delete_self = self.request.user == self.object.user # Add a success message messages.success(self.request, self.get_success_message(delete_self)) - return redirect(self.get_success_url()) def post(self, request, *args, **kwargs): From 37c8c2b05e09be1a0648b06a17cd8ef44d24fd94 Mon Sep 17 00:00:00 2001 From: Rachid Mrad Date: Tue, 23 Jan 2024 15:39:09 -0500 Subject: [PATCH 055/137] refactor application_review to use summary_item --- .../assets/sass/_theme/_register-form.scss | 2 +- .../templates/application_review.html | 239 +++++++++++------- .../templates/includes/summary_item.html | 6 +- 3 files changed, 147 insertions(+), 100 deletions(-) diff --git a/src/registrar/assets/sass/_theme/_register-form.scss b/src/registrar/assets/sass/_theme/_register-form.scss index 6d268d155..8332d17ae 100644 --- a/src/registrar/assets/sass/_theme/_register-form.scss +++ b/src/registrar/assets/sass/_theme/_register-form.scss @@ -12,7 +12,7 @@ margin-top: units(1); } -.register-form-step h3 { +.register-form-step h3:not(.text-base-darker) { color: color('primary-dark'); letter-spacing: $letter-space--xs; margin-top: units(3); diff --git a/src/registrar/templates/application_review.html b/src/registrar/templates/application_review.html index 057df6380..8efd9967d 100644 --- a/src/registrar/templates/application_review.html +++ b/src/registrar/templates/application_review.html @@ -20,113 +20,158 @@ {% block form_fields %} {% for step in steps.all|slice:":-1" %} -
    -
    -
    -
    -
    {{ form_titles|get_item:step }}
    -
    - {% if step == Step.ORGANIZATION_TYPE %} - {% if application.organization_type is not None %} - {% with long_org_type=application.organization_type|get_organization_long_name %} -

    {{ long_org_type }}

    - {% endwith %} - {% else %} -

    Incomplete

    - {% endif %} +
    + + {% if step == Step.ORGANIZATION_TYPE %} + {% namespaced_url 'application' step as application_url %} + {% if application.organization_type is not None %} + {% with title=form_titles|get_item:step value=application.organization_type|get_organization_long_name|default:"Incomplete" %} + {% include "includes/summary_item.html" with title=title value=value heading_level=heading_level editable=True edit_link=application_url %} + {% endwith %} + {% else %} + {% with title=form_titles|get_item:step value="Incomplete" %} + {% include "includes/summary_item.html" with title=title value=value heading_level=heading_level editable=True edit_link=application_url %} + {% endwith %} {% endif %} - {% if step == Step.TRIBAL_GOVERNMENT %} - {{ application.tribe_name|default:"Incomplete" }} - {% if application.federally_recognized_tribe %}

    Federally-recognized tribe

    {% endif %} - {% if application.state_recognized_tribe %}

    State-recognized tribe

    {% endif %} + {% endif %} + + {% if step == Step.TRIBAL_GOVERNMENT %} + {% namespaced_url 'application' step as application_url %} + {% with title=form_titles|get_item:step value=application.tribe_name|default:"Incomplete" %} + {% include "includes/summary_item.html" with title=title value=value heading_level=heading_level editable=True edit_link=application_url %} + {% endwith %} + {% if application.federally_recognized_tribe %}

    Federally-recognized tribe

    {% endif %} + {% if application.state_recognized_tribe %}

    State-recognized tribe

    {% endif %} + {% endif %} + + + {% if step == Step.ORGANIZATION_FEDERAL %} + {% namespaced_url 'application' step as application_url %} + {% with title=form_titles|get_item:step value=application.get_federal_type_display|default:"Incomplete" %} + {% include "includes/summary_item.html" with title=title value=value heading_level=heading_level editable=True edit_link=application_url %} + {% endwith %} + {% endif %} + + {% if step == Step.ORGANIZATION_ELECTION %} + {% namespaced_url 'application' step as application_url %} + {% with title=form_titles|get_item:step value=application.is_election_board|yesno:"Yes,No,Incomplete" %} + {% include "includes/summary_item.html" with title=title value=value heading_level=heading_level editable=True edit_link=application_url %} + {% endwith %} + {% endif %} + + {% if step == Step.ORGANIZATION_CONTACT %} + {% namespaced_url 'application' step as application_url %} + {% if application.organization_name %} + {% with title=form_titles|get_item:step value=application %} + {% include "includes/summary_item.html" with title=title value=value heading_level=heading_level editable=True edit_link=application_url address='true' %} + {% endwith %} + {% else %} + {% with title=form_titles|get_item:step value='Incomplete' %} + {% include "includes/summary_item.html" with title=title value=value heading_level=heading_level editable=True edit_link=application_url %} + {% endwith %} {% endif %} - {% if step == Step.ORGANIZATION_FEDERAL %} -

    {{ application.get_federal_type_display|default:"Incomplete" }}

    + {% endif %} + + {% if step == Step.ABOUT_YOUR_ORGANIZATION %} + {% namespaced_url 'application' step as application_url %} + {% with title=form_titles|get_item:step value=application.about_your_organization|default:"Incomplete" %} + {% include "includes/summary_item.html" with title=title value=value heading_level=heading_level editable=True edit_link=application_url %} + {% endwith %} + {% endif %} + + {% if step == Step.AUTHORIZING_OFFICIAL %} + {% namespaced_url 'application' step as application_url %} + {% if application.authorizing_official is not None %} + {% with title=form_titles|get_item:step value=application.authorizing_official %} + {% include "includes/summary_item.html" with title=title value=value heading_level=heading_level editable=True edit_link=application_url contact='true' %} + {% endwith %} + {% else %} + {% with title=form_titles|get_item:step value="Incomplete" %} + {% include "includes/summary_item.html" with title=title value=value heading_level=heading_level editable=True edit_link=application_url %} + {% endwith %} {% endif %} - {% if step == Step.ORGANIZATION_ELECTION %} -

    {{ application.is_election_board|yesno:"Yes,No,Incomplete" }}

    + {% endif %} + + {% if step == Step.CURRENT_SITES %} + {% namespaced_url 'application' step as application_url %} + {% if application.alternative_domains.all %} + {% with title=form_titles|get_item:step value=application.current_websites.all %} + {% include "includes/summary_item.html" with title=title value=value heading_level=heading_level editable=True edit_link=application_url list='true' %} + {% endwith %} + {% else %} + {% with title=form_titles|get_item:step value='None' %} + {% include "includes/summary_item.html" with title=title value=value heading_level=heading_level editable=True edit_link=application_url %} + {% endwith %} {% endif %} - {% if step == Step.ORGANIZATION_CONTACT %} - {% if application.organization_name %} - {% include "includes/organization_address.html" with organization=application %} - {% else %} -

    Incomplete

    - {% endif %} - {% endif %} - {% if step == Step.ABOUT_YOUR_ORGANIZATION %} -

    {{ application.about_your_organization|default:"Incomplete" }}

    - {% endif %} - {% if step == Step.AUTHORIZING_OFFICIAL %} - {% if application.authorizing_official %} -
    - {% include "includes/contact.html" with contact=application.authorizing_official %} -
    - {% else %} -

    Incomplete

    - {% endif %} - {% endif %} - {% if step == Step.CURRENT_SITES %} -
      - {% for site in application.current_websites.all %} + {% endif %} + + {% if step == Step.DOTGOV_DOMAIN %} + {% namespaced_url 'application' step as application_url %} + {% with title=form_titles|get_item:step value=application.requested_domain.name|default:"Incomplete" %} + {% include "includes/summary_item.html" with title=title value=value heading_level=heading_level editable=True edit_link=application_url %} + {% endwith %} + + {% if application.alternative_domains.all %} +

      Alternative domains

      +
        + {% for site in application.alternative_domains.all %}
      • {{ site.website }}
      • - {% empty %} -
      • None
      • {% endfor %}
      {% endif %} - {% if step == Step.DOTGOV_DOMAIN %} -
        -
      • {{ application.requested_domain.name|default:"Incomplete" }}
      • -
      - {% if application.alternative_domains.all %} -
      -

      Alternative domains

      -
        - {% for site in application.alternative_domains.all %} -
      • {{ site.website }}
      • - {% endfor %} -
      -
      - {% endif %} + {% endif %} + + {% if step == Step.PURPOSE %} + {% namespaced_url 'application' step as application_url %} + {% with title=form_titles|get_item:step value=application.purpose|default:"Incomplete" %} + {% include "includes/summary_item.html" with title=title value=value heading_level=heading_level editable=True edit_link=application_url %} + {% endwith %} + {% endif %} + + {% if step == Step.YOUR_CONTACT %} + {% namespaced_url 'application' step as application_url %} + {% if application.submitter is not None %} + {% with title=form_titles|get_item:step value=application.submitter %} + {% include "includes/summary_item.html" with title=title value=value heading_level=heading_level editable=True edit_link=application_url contact='true' %} + {% endwith %} + {% else %} + {% with title=form_titles|get_item:step value="Incomplete" %} + {% include "includes/summary_item.html" with title=title value=value heading_level=heading_level editable=True edit_link=application_url %} + {% endwith %} {% endif %} - {% if step == Step.PURPOSE %} -

      {{ application.purpose|default:"Incomplete" }}

      + {% endif %} + + {% if step == Step.OTHER_CONTACTS %} + {% namespaced_url 'application' step as application_url %} + {% if application.other_contacts.all %} + {% with title=form_titles|get_item:step value=application.other_contacts.all %} + {% include "includes/summary_item.html" with title=title value=value heading_level=heading_level editable=True edit_link=application_url contact='true' list='true' %} + {% endwith %} + {% else %} + {% with title=form_titles|get_item:step value=application.no_other_contacts_rationale|default:"Incomplete" %} + {% include "includes/summary_item.html" with title=title value=value heading_level=heading_level editable=True edit_link=application_url %} + {% endwith %} {% endif %} - {% if step == Step.YOUR_CONTACT %} - {% if application.submitter %} -
      - {% include "includes/contact.html" with contact=application.submitter %} -
      - {% else %} -

      Incomplete

      - {% endif %} - {% endif %} - {% if step == Step.OTHER_CONTACTS %} - {% for other in application.other_contacts.all %} -
      -

      Contact {{ forloop.counter }}

      - {% include "includes/contact.html" with contact=other %} -
      - {% empty %} -
      -

      No other employees from your organization?

      -

      {{ application.no_other_contacts_rationale|default:"Incomplete" }}

      -
      - {% endfor %} - {% endif %} - {% if step == Step.ANYTHING_ELSE %} -

      {{ application.anything_else|default:"No" }}

      - {% endif %} - {% if step == Step.REQUIREMENTS %} -

      {{ application.is_policy_acknowledged|yesno:"I agree.,I do not agree.,I do not agree." }}

      - {% endif %} -
    -
    - Edit {{ form_titles|get_item:step }} -
    + {% endif %} + + + {% if step == Step.ANYTHING_ELSE %} + {% namespaced_url 'application' step as application_url %} + {% with title=form_titles|get_item:step value=application.anything_else|default:"No" %} + {% include "includes/summary_item.html" with title=title value=value heading_level=heading_level editable=True edit_link=application_url %} + {% endwith %} + {% endif %} + + + {% if step == Step.REQUIREMENTS %} + {% namespaced_url 'application' step as application_url %} + {% with title=form_titles|get_item:step value=application.is_policy_acknowledged|yesno:"I agree.,I do not agree.,I do not agree." %} + {% include "includes/summary_item.html" with title=title value=value heading_level=heading_level editable=True edit_link=application_url %} + {% endwith %} + {% endif %} + + +
    {% endfor %} {% endblock %} diff --git a/src/registrar/templates/includes/summary_item.html b/src/registrar/templates/includes/summary_item.html index 53364d1b2..657f3c29b 100644 --- a/src/registrar/templates/includes/summary_item.html +++ b/src/registrar/templates/includes/summary_item.html @@ -31,8 +31,10 @@
      {% for item in value %}
    • -

      - Contact {{forloop.counter}} +

      + + Contact {{forloop.counter}} +

      {% include "includes/contact.html" with contact=item %}
    • {% empty %} From f1c5e9668ddeb666583707c247e7b2c6ed5384be Mon Sep 17 00:00:00 2001 From: zandercymatics <141044360+zandercymatics@users.noreply.github.com> Date: Tue, 23 Jan 2024 14:23:54 -0700 Subject: [PATCH 056/137] Add back accidental super deletion --- src/registrar/views/domain.py | 3 +++ src/registrar/views/utility/permission_views.py | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/registrar/views/domain.py b/src/registrar/views/domain.py index 08ac0424d..188671f27 100644 --- a/src/registrar/views/domain.py +++ b/src/registrar/views/domain.py @@ -843,6 +843,9 @@ class DomainDeleteUserView(UserDomainRolePermissionDeleteView): def form_valid(self, form): """Delete the specified user on this domain.""" + # Delete the object + super().form_valid(form) + # Is the user deleting themselves? If so, display a different message delete_self = self.request.user == self.object.user diff --git a/src/registrar/views/utility/permission_views.py b/src/registrar/views/utility/permission_views.py index 762612128..a274db0d9 100644 --- a/src/registrar/views/utility/permission_views.py +++ b/src/registrar/views/utility/permission_views.py @@ -150,7 +150,7 @@ class UserDomainRolePermissionView(UserDomainRolePermission, DetailView, abc.ABC class UserDomainRolePermissionDeleteView(UserDomainRolePermissionView, DeleteView, abc.ABC): - """Abstract base view for domain application withdraw function + """Abstract base view for deleting a UserDomainRole. This abstract view cannot be instantiated. Actual views must specify `template_name`. From 33cf59530d1535eee900239d165b9b196f46d2c4 Mon Sep 17 00:00:00 2001 From: zandercymatics <141044360+zandercymatics@users.noreply.github.com> Date: Tue, 23 Jan 2024 14:34:59 -0700 Subject: [PATCH 057/137] Fix unit test Fixed unit test filtering too broadly --- src/registrar/tests/test_views.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/registrar/tests/test_views.py b/src/registrar/tests/test_views.py index b128724a0..9b17357f5 100644 --- a/src/registrar/tests/test_views.py +++ b/src/registrar/tests/test_views.py @@ -2690,7 +2690,7 @@ class TestDomainManagers(TestDomainOverview): response = self.client.get(reverse("domain-users-add", kwargs={"pk": self.domain.id})) self.assertContains(response, "Add a domain manager") - def test_domain_delete_link(self): + def test_domain_user_delete_link(self): """Tests if the user delete link works""" # Add additional users @@ -2733,14 +2733,14 @@ class TestDomainManagers(TestDomainOverview): self.assertFalse(deleted_user_exists) # Ensure that the current user wasn't deleted - current_user_exists = UserDomainRole.objects.filter(user=self.user.id).exists() + current_user_exists = UserDomainRole.objects.filter(user=self.user.id, domain=self.domain).exists() self.assertTrue(current_user_exists) # Ensure that the other userdomainrole was not deleted role_2_exists = UserDomainRole.objects.filter(id=role_2.id).exists() self.assertTrue(role_2_exists) - def test_domain_delete_self_redirects_home(self): + def test_domain_user_delete_self_redirects_home(self): """Tests if deleting yourself redirects to home""" # Add additional users dummy_user_1 = User.objects.create( @@ -2784,7 +2784,7 @@ class TestDomainManagers(TestDomainOverview): self.assertEqual(message.tags, "success") # Ensure that the current user was deleted - current_user_exists = UserDomainRole.objects.filter(user=self.user.id).exists() + current_user_exists = UserDomainRole.objects.filter(user=self.user.id, domain=self.domain).exists() self.assertFalse(current_user_exists) # Ensure that the other userdomainroles are not deleted From 43f96f726f8f6389482e76d4b7f1af7689b2e1e7 Mon Sep 17 00:00:00 2001 From: zandercymatics <141044360+zandercymatics@users.noreply.github.com> Date: Tue, 23 Jan 2024 15:28:39 -0700 Subject: [PATCH 058/137] Add www logic --- src/registrar/models/utility/domain_helper.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/registrar/models/utility/domain_helper.py b/src/registrar/models/utility/domain_helper.py index a808ef803..3267f0c93 100644 --- a/src/registrar/models/utility/domain_helper.py +++ b/src/registrar/models/utility/domain_helper.py @@ -57,6 +57,9 @@ class DomainHelper: # If blank ok is true, just return the domain return domain + if domain.startswith("www."): + domain = domain[4:] + if domain.endswith(".gov"): domain = domain[:-4] From e1081d4cb63c64d24afb68251458413bba88e887 Mon Sep 17 00:00:00 2001 From: zandercymatics <141044360+zandercymatics@users.noreply.github.com> Date: Tue, 23 Jan 2024 15:43:00 -0700 Subject: [PATCH 059/137] Unit test --- src/registrar/tests/test_forms.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/registrar/tests/test_forms.py b/src/registrar/tests/test_forms.py index a8d84ba7b..c9dd3c4f0 100644 --- a/src/registrar/tests/test_forms.py +++ b/src/registrar/tests/test_forms.py @@ -64,6 +64,12 @@ class TestFormValidation(MockEppLib): form = DotGovDomainForm(data={"requested_domain": "top-level-agency"}) self.assertEqual(len(form.errors), 0) + def test_requested_domain_starting_www(self): + """Test a valid domain name with .www at the beginning.""" + form = DotGovDomainForm(data={"requested_domain": "www.top-level-agency"}) + self.assertEqual(len(form.errors), 0) + self.assertEqual(form.cleaned_data["requested_domain"], "top-level-agency") + def test_requested_domain_ending_dotgov(self): """Just a valid domain name with .gov at the end.""" form = DotGovDomainForm(data={"requested_domain": "top-level-agency.gov"}) From 4710de9b15fe4954b0df584c34c542f791fb2f32 Mon Sep 17 00:00:00 2001 From: Rebecca Hsieh Date: Tue, 23 Jan 2024 15:16:04 -0800 Subject: [PATCH 060/137] Allow multifield validation and clean up --- src/registrar/assets/js/get-gov.js | 19 ++++--------------- .../templates/application_dotgov_domain.html | 5 ++--- 2 files changed, 6 insertions(+), 18 deletions(-) diff --git a/src/registrar/assets/js/get-gov.js b/src/registrar/assets/js/get-gov.js index f38fc3813..14e6e45f6 100644 --- a/src/registrar/assets/js/get-gov.js +++ b/src/registrar/assets/js/get-gov.js @@ -48,7 +48,6 @@ function createLiveRegion(id) { /** Announces changes to assistive technology users. */ function announce(id, text) { - console.log('announce: ' + text) let liveRegion = document.getElementById(id + "-live-region"); if (!liveRegion) liveRegion = createLiveRegion(id); liveRegion.innerHTML = text; @@ -87,7 +86,6 @@ function fetchJSON(endpoint, callback, url="/api/v1/") { /** Modifies CSS and HTML when an input is valid/invalid. */ function toggleInputValidity(el, valid, msg=DEFAULT_ERROR) { - console.log('toggleInputValidity: ' + valid) if (valid) { el.setCustomValidity(""); el.removeAttribute("aria-invalid"); @@ -102,7 +100,6 @@ function toggleInputValidity(el, valid, msg=DEFAULT_ERROR) { /** Display (or hide) a message beneath an element. */ function inlineToast(el, id, style, msg) { - console.log('inine toast creates alerts') if (!el.id && !id) { console.error("Elements must have an `id` to show an inline toast."); return; @@ -134,9 +131,7 @@ function inlineToast(el, id, style, msg) { } function checkDomainAvailability(el) { - console.log('checkDomainAvailability: ' + el.value) const callback = (response) => { - console.log('inside callback') toggleInputValidity(el, (response && response.available), msg=response.message); announce(el.id, response.message); @@ -147,7 +142,6 @@ function checkDomainAvailability(el) { // use of `parentElement` due to .gov inputs being wrapped in www/.gov decoration inlineToast(el.parentElement, el.id, INFORMATIVE, response.message); } else if (ignore_blank && response.code == "required"){ - console.log('ignore_blank && response.code == "required"') // Visually remove the error error = "usa-input--error" if (el.classList.contains(error)){ @@ -173,7 +167,6 @@ function clearDomainAvailability(el) { /** Runs all the validators associated with this element. */ function runValidators(el) { - console.log(el.getAttribute("id")) const attribute = el.getAttribute("validate") || ""; if (!attribute.length) return; const validators = attribute.split(" "); @@ -214,8 +207,6 @@ function handleInputValidation(e) { /** On button click, handles running any associated validators. */ function handleValidationClick(e) { - console.log('validating dotgov domain') - const attribute = e.target.getAttribute("validate-for") || ""; if (!attribute.length) return; @@ -226,8 +217,6 @@ function handleValidationClick(e) { function handleFormsetValidationClick(e) { // Check availability for alternative domains - - console.log('validating alternative domains') const alternativeDomainsAvailability = document.getElementById('check-availability-for-alternative-domains'); @@ -264,13 +253,13 @@ function handleFormsetValidationClick(e) { for(const input of needsValidation) { input.addEventListener('input', handleInputValidation); } - const dotgovDomainsAvailability = document.getElementById('check-availability-for-dotgov-domain'); const alternativeDomainsAvailability = document.getElementById('check-availability-for-alternative-domains'); const activatesValidation = document.querySelectorAll('[validate-for]'); + for(const button of activatesValidation) { - if (alternativeDomainsAvailability) { - alternativeDomainsAvailability.addEventListener('click', handleFormsetValidationClick); - dotgovDomainsAvailability.addEventListener('click', handleValidationClick); + // Adds multi-field validation for alternative domains + if (button === alternativeDomainsAvailability) { + button.addEventListener('click', handleFormsetValidationClick); } else { button.addEventListener('click', handleValidationClick); } diff --git a/src/registrar/templates/application_dotgov_domain.html b/src/registrar/templates/application_dotgov_domain.html index 74c6dce06..af5e60751 100644 --- a/src/registrar/templates/application_dotgov_domain.html +++ b/src/registrar/templates/application_dotgov_domain.html @@ -82,15 +82,14 @@ Add another alternative -
      - -

      If you’re not sure this is the domain you want, that’s ok. You can change the domain later.

      +

      If you’re not sure this is the domain you want, that’s ok. You can change the domain later.

      From 4fd674e0b47cd49b0fe764c1785822d1fb7b4d65 Mon Sep 17 00:00:00 2001 From: David Kennedy Date: Tue, 23 Jan 2024 21:50:19 -0500 Subject: [PATCH 061/137] updated subheaders to h3 --- src/registrar/templates/includes/summary_item.html | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/registrar/templates/includes/summary_item.html b/src/registrar/templates/includes/summary_item.html index 657f3c29b..c7b606a8a 100644 --- a/src/registrar/templates/includes/summary_item.html +++ b/src/registrar/templates/includes/summary_item.html @@ -31,11 +31,9 @@
        {% for item in value %}
      • -

        - - Contact {{forloop.counter}} - -

        +

        + Contact {{forloop.counter}} +

        {% include "includes/contact.html" with contact=item %}
      • {% empty %}
      • None
      • From ec100302e8b731592e7006ca01f4395a18456e43 Mon Sep 17 00:00:00 2001 From: David Kennedy Date: Tue, 23 Jan 2024 22:19:52 -0500 Subject: [PATCH 062/137] added federal agency to request review and manage screens as well as submission email --- .../templates/emails/includes/application_summary.txt | 3 ++- src/registrar/templates/includes/organization_address.html | 5 ++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/registrar/templates/emails/includes/application_summary.txt b/src/registrar/templates/emails/includes/application_summary.txt index 2c3564ad7..efed65401 100644 --- a/src/registrar/templates/emails/includes/application_summary.txt +++ b/src/registrar/templates/emails/includes/application_summary.txt @@ -16,7 +16,8 @@ Election office: {{ application.is_election_board|yesno:"Yes,No,Incomplete" }} {% endif %} Organization name and mailing address: -{% spaceless %}{{ application.organization_name }} +{% spaceless %}{{ application.federal_agency }} +{{ application.organization_name }} {{ application.address_line1 }}{% if application.address_line2 %} {{ application.address_line2 }}{% endif %} {{ application.city }}, {{ application.state_territory }} diff --git a/src/registrar/templates/includes/organization_address.html b/src/registrar/templates/includes/organization_address.html index 52f0d437a..d0c62d685 100644 --- a/src/registrar/templates/includes/organization_address.html +++ b/src/registrar/templates/includes/organization_address.html @@ -1,6 +1,9 @@
        + {% if organization.federal_agency %} + {{ organization.federal_agency }} + {% endif %} {% if organization.organization_name %} - {{ organization.organization_name }} +
        {{ organization.organization_name }} {% endif %} {% if organization.address_line1 %}
        {{ organization.address_line1 }} From c2c60cd53094815b94f55e0fb460fed97453ceb9 Mon Sep 17 00:00:00 2001 From: Erin <121973038+erinysong@users.noreply.github.com> Date: Wed, 24 Jan 2024 13:32:49 -0800 Subject: [PATCH 063/137] Restyle availability button --- src/registrar/templates/application_dotgov_domain.html | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/registrar/templates/application_dotgov_domain.html b/src/registrar/templates/application_dotgov_domain.html index 74c6dce06..15f5d2d33 100644 --- a/src/registrar/templates/application_dotgov_domain.html +++ b/src/registrar/templates/application_dotgov_domain.html @@ -82,13 +82,14 @@ Add another alternative -
        - - + >Check availability + +

        If you’re not sure this is the domain you want, that’s ok. You can change the domain later.

        From fd53cc9241c9de14b8a8eca0fce25156a6da8495 Mon Sep 17 00:00:00 2001 From: Rebecca Hsieh Date: Wed, 24 Jan 2024 13:44:56 -0800 Subject: [PATCH 064/137] Shorten tag name --- src/registrar/assets/js/get-gov.js | 4 ++-- src/registrar/templates/application_dotgov_domain.html | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/registrar/assets/js/get-gov.js b/src/registrar/assets/js/get-gov.js index 3c49f6098..16402b056 100644 --- a/src/registrar/assets/js/get-gov.js +++ b/src/registrar/assets/js/get-gov.js @@ -218,7 +218,7 @@ function handleValidationClick(e) { function handleFormsetValidationClick(e) { // Check availability for alternative domains - const alternativeDomainsAvailability = document.getElementById('check-availability-for-alternative-domains'); + const alternativeDomainsAvailability = document.getElementById('check-avail-for-alt-domains'); // Collect input IDs from the repeatable forms let inputIds = Array.from(document.querySelectorAll('.repeatable-form input')).map(input => input.id); @@ -253,7 +253,7 @@ function handleFormsetValidationClick(e) { for(const input of needsValidation) { input.addEventListener('input', handleInputValidation); } - const alternativeDomainsAvailability = document.getElementById('check-availability-for-alternative-domains'); + const alternativeDomainsAvailability = document.getElementById('check-avail-for-alt-domains'); const activatesValidation = document.querySelectorAll('[validate-for]'); for(const button of activatesValidation) { diff --git a/src/registrar/templates/application_dotgov_domain.html b/src/registrar/templates/application_dotgov_domain.html index b6b708e39..3af94941a 100644 --- a/src/registrar/templates/application_dotgov_domain.html +++ b/src/registrar/templates/application_dotgov_domain.html @@ -84,7 +84,7 @@
        From e3fc6082027026c1a72bfc0b52133a024980ef21 Mon Sep 17 00:00:00 2001 From: Rebecca Hsieh Date: Wed, 24 Jan 2024 13:53:45 -0800 Subject: [PATCH 065/137] Remove unused classes and comments --- src/registrar/assets/js/get-gov.js | 2 +- src/registrar/models/domain.py | 13 +++++++------ .../templates/application_dotgov_domain.html | 2 +- 3 files changed, 9 insertions(+), 8 deletions(-) diff --git a/src/registrar/assets/js/get-gov.js b/src/registrar/assets/js/get-gov.js index 16402b056..4a7891fbd 100644 --- a/src/registrar/assets/js/get-gov.js +++ b/src/registrar/assets/js/get-gov.js @@ -210,7 +210,7 @@ function handleValidationClick(e) { const attribute = e.target.getAttribute("validate-for") || ""; if (!attribute.length) return; - const input = document.getElementById(attribute); // You might need to define 'attribute' + const input = document.getElementById(attribute); runValidators(input); } diff --git a/src/registrar/models/domain.py b/src/registrar/models/domain.py index 1a581a4ec..6b5f0d19c 100644 --- a/src/registrar/models/domain.py +++ b/src/registrar/models/domain.py @@ -173,12 +173,13 @@ class Domain(TimeStampedModel, DomainHelper): @classmethod def available(cls, domain: str) -> bool: - """Check if a domain is available.""" - if not cls.string_could_be_domain(domain): - raise ValueError("Not a valid domain: %s" % str(domain)) - domain_name = domain.lower() - req = commands.CheckDomain([domain_name]) - return registry.send(req, cleaned=True).res_data[0].avail + return True + # """Check if a domain is available.""" + # if not cls.string_could_be_domain(domain): + # raise ValueError("Not a valid domain: %s" % str(domain)) + # domain_name = domain.lower() + # req = commands.CheckDomain([domain_name]) + # return registry.send(req, cleaned=True).res_data[0].avail @classmethod def registered(cls, domain: str) -> bool: diff --git a/src/registrar/templates/application_dotgov_domain.html b/src/registrar/templates/application_dotgov_domain.html index 3af94941a..67206b272 100644 --- a/src/registrar/templates/application_dotgov_domain.html +++ b/src/registrar/templates/application_dotgov_domain.html @@ -48,7 +48,6 @@ {% endwith %} {% endwith %}
        From f82ce53345287f8bfafcca8a3b918617ee79c813 Mon Sep 17 00:00:00 2001 From: Rebecca Hsieh Date: Wed, 24 Jan 2024 13:54:40 -0800 Subject: [PATCH 066/137] Add back in EPP availability --- src/registrar/models/domain.py | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/src/registrar/models/domain.py b/src/registrar/models/domain.py index 6b5f0d19c..1a581a4ec 100644 --- a/src/registrar/models/domain.py +++ b/src/registrar/models/domain.py @@ -173,13 +173,12 @@ class Domain(TimeStampedModel, DomainHelper): @classmethod def available(cls, domain: str) -> bool: - return True - # """Check if a domain is available.""" - # if not cls.string_could_be_domain(domain): - # raise ValueError("Not a valid domain: %s" % str(domain)) - # domain_name = domain.lower() - # req = commands.CheckDomain([domain_name]) - # return registry.send(req, cleaned=True).res_data[0].avail + """Check if a domain is available.""" + if not cls.string_could_be_domain(domain): + raise ValueError("Not a valid domain: %s" % str(domain)) + domain_name = domain.lower() + req = commands.CheckDomain([domain_name]) + return registry.send(req, cleaned=True).res_data[0].avail @classmethod def registered(cls, domain: str) -> bool: From 974c5f5a9eb09a4bd4d71d2bc6d23fb85dfd865d Mon Sep 17 00:00:00 2001 From: Rebecca Hsieh Date: Thu, 25 Jan 2024 09:40:14 -0800 Subject: [PATCH 067/137] Remove unused debounce --- src/registrar/assets/js/get-gov.js | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/registrar/assets/js/get-gov.js b/src/registrar/assets/js/get-gov.js index 4a7891fbd..e8e5e57e5 100644 --- a/src/registrar/assets/js/get-gov.js +++ b/src/registrar/assets/js/get-gov.js @@ -154,9 +154,6 @@ function checkDomainAvailability(el) { fetchJSON(`available/?domain=${el.value}`, callback); } -/** Call the API to see if the domain is good. */ -// const checkDomainAvailability = debounce(_checkDomainAvailability); - /** Hides the toast message and clears the aira live region. */ function clearDomainAvailability(el) { el.classList.remove('usa-input--success'); From dac472cab209a9002eacaef51356bd754adbf039 Mon Sep 17 00:00:00 2001 From: Rebecca Hsieh Date: Thu, 25 Jan 2024 09:46:56 -0800 Subject: [PATCH 068/137] Swap back to green error messaging instead of blue informative --- src/registrar/assets/js/get-gov.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/registrar/assets/js/get-gov.js b/src/registrar/assets/js/get-gov.js index e8e5e57e5..69ba50cd4 100644 --- a/src/registrar/assets/js/get-gov.js +++ b/src/registrar/assets/js/get-gov.js @@ -138,9 +138,9 @@ function checkDomainAvailability(el) { // Determines if we ignore the field if it is just blank ignore_blank = el.classList.contains("blank-ok") if (el.validity.valid) { - el.classList.add('usa-input--info'); + el.classList.add('usa-input--success'); // use of `parentElement` due to .gov inputs being wrapped in www/.gov decoration - inlineToast(el.parentElement, el.id, INFORMATIVE, response.message); + inlineToast(el.parentElement, el.id, SUCCESS, response.message); } else if (ignore_blank && response.code == "required"){ // Visually remove the error error = "usa-input--error" From f8dbc03d919c79c65fa80650ac77015dcf4a5669 Mon Sep 17 00:00:00 2001 From: David Kennedy Date: Thu, 25 Jan 2024 13:10:33 -0500 Subject: [PATCH 069/137] fixed display of current web sites --- src/registrar/templates/application_review.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/registrar/templates/application_review.html b/src/registrar/templates/application_review.html index 8efd9967d..451eb2339 100644 --- a/src/registrar/templates/application_review.html +++ b/src/registrar/templates/application_review.html @@ -94,7 +94,7 @@ {% if step == Step.CURRENT_SITES %} {% namespaced_url 'application' step as application_url %} - {% if application.alternative_domains.all %} + {% if application.current_websites.all %} {% with title=form_titles|get_item:step value=application.current_websites.all %} {% include "includes/summary_item.html" with title=title value=value heading_level=heading_level editable=True edit_link=application_url list='true' %} {% endwith %} From 64e3d5a33acbfd34f50c3cca6b8fc6b99d6027aa Mon Sep 17 00:00:00 2001 From: David Kennedy Date: Thu, 25 Jan 2024 13:29:57 -0500 Subject: [PATCH 070/137] updated markup on sumary_item and application_review --- src/registrar/templates/application_review.html | 4 ++-- src/registrar/templates/includes/summary_item.html | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/registrar/templates/application_review.html b/src/registrar/templates/application_review.html index 451eb2339..44bb43275 100644 --- a/src/registrar/templates/application_review.html +++ b/src/registrar/templates/application_review.html @@ -112,8 +112,8 @@ {% endwith %} {% if application.alternative_domains.all %} -

        Alternative domains

        -
          +

          Alternative domains

          +
            {% for site in application.alternative_domains.all %}
          • {{ site.website }}
          • {% endfor %} diff --git a/src/registrar/templates/includes/summary_item.html b/src/registrar/templates/includes/summary_item.html index c7b606a8a..a44989d74 100644 --- a/src/registrar/templates/includes/summary_item.html +++ b/src/registrar/templates/includes/summary_item.html @@ -31,7 +31,7 @@
              {% for item in value %}
            • -

              +

              Contact {{forloop.counter}}

              {% include "includes/contact.html" with contact=item %}
            • @@ -60,7 +60,7 @@

              {{ value | first }}

              {% endif %} {% else %} -
                +
                  {% for item in value %} {% if users %}
                • {{ item.user.email }}
                • From dcbfcf7639dd310a690ca2199de5102e11254e56 Mon Sep 17 00:00:00 2001 From: Rachid Mrad Date: Thu, 25 Jan 2024 13:56:08 -0500 Subject: [PATCH 071/137] Stylistic changes, more semantic definition lists for contacts on review and summary pages --- .../assets/sass/_theme/_register-form.scss | 2 +- .../templates/application_review.html | 2 +- .../templates/includes/summary_item.html | 29 +++++++++++-------- 3 files changed, 19 insertions(+), 14 deletions(-) diff --git a/src/registrar/assets/sass/_theme/_register-form.scss b/src/registrar/assets/sass/_theme/_register-form.scss index 8332d17ae..d78bc512a 100644 --- a/src/registrar/assets/sass/_theme/_register-form.scss +++ b/src/registrar/assets/sass/_theme/_register-form.scss @@ -12,7 +12,7 @@ margin-top: units(1); } -.register-form-step h3:not(.text-base-darker) { +.register-form-step h3:not(.text-base-darkest) { color: color('primary-dark'); letter-spacing: $letter-space--xs; margin-top: units(3); diff --git a/src/registrar/templates/application_review.html b/src/registrar/templates/application_review.html index 44bb43275..b6d37f6e3 100644 --- a/src/registrar/templates/application_review.html +++ b/src/registrar/templates/application_review.html @@ -112,7 +112,7 @@ {% endwith %} {% if application.alternative_domains.all %} -

                  Alternative domains

                  +

                  Alternative domains

                    {% for site in application.alternative_domains.all %}
                  • {{ site.website }}
                  • diff --git a/src/registrar/templates/includes/summary_item.html b/src/registrar/templates/includes/summary_item.html index a44989d74..d2bdae709 100644 --- a/src/registrar/templates/includes/summary_item.html +++ b/src/registrar/templates/includes/summary_item.html @@ -28,17 +28,22 @@ {% if value|length == 1 %} {% include "includes/contact.html" with contact=value|first %} {% else %} -
                      - {% for item in value %} -
                    • -

                      - Contact {{forloop.counter}} -

                      - {% include "includes/contact.html" with contact=item %}
                    • - {% empty %} -
                    • None
                    • - {% endfor %} -
                    + {% if value %} +
                    + {% for item in value %} +
                    + Contact {{forloop.counter}} +
                    +
                    + {% include "includes/contact.html" with contact=item %} +
                    + {% endfor %} +
                    + {% else %} +

                    + None +

                    + {% endif %} {% endif %} {% else %} {% include "includes/contact.html" with contact=value %} @@ -57,7 +62,7 @@ {% endspaceless %}) {% endif %} {% else %} -

                    {{ value | first }}

                    +

                    {{ value | first }}

                    {% endif %} {% else %}
                      From 6c8e1fec5986cbfe5196fe739e48b5dd13cc656b Mon Sep 17 00:00:00 2001 From: Rachid Mrad Date: Thu, 25 Jan 2024 14:37:29 -0500 Subject: [PATCH 072/137] Revise to show ellipsis with numbers, unit tests --- src/registrar/admin.py | 13 +++--- src/registrar/tests/common.py | 18 +++++---- src/registrar/tests/test_admin.py | 67 +++++++++++++++++++++++++++++++ 3 files changed, 85 insertions(+), 13 deletions(-) diff --git a/src/registrar/admin.py b/src/registrar/admin.py index 7b196bfa2..3d71fb710 100644 --- a/src/registrar/admin.py +++ b/src/registrar/admin.py @@ -491,11 +491,14 @@ class ContactAdmin(ListHeaderAdmin): if related_objects: message = "" - for url, obj in related_objects: - escaped_obj = escape(obj) - message += f"Joined to {obj.__class__.__name__}: {escaped_obj}
                      " - # message_html is considered safe html. It is generated from a finite list of strings - # which are generated from django objects. And a django object, which is escaped + for i, (url, obj) in enumerate(related_objects): + if i < 5: + escaped_obj = escape(obj) + message += f"Joined to {obj.__class__.__name__}: {escaped_obj}
                      " + if len(related_objects) > 5: + related_objects_over_five = len(related_objects) - 5 + message += f"And {related_objects_over_five} more..." + message_html = mark_safe(message) # nosec messages.warning( request, diff --git a/src/registrar/tests/common.py b/src/registrar/tests/common.py index 80ec5ef3d..023e5319e 100644 --- a/src/registrar/tests/common.py +++ b/src/registrar/tests/common.py @@ -526,6 +526,7 @@ def completed_application( has_anything_else=True, status=DomainApplication.ApplicationStatus.STARTED, user=False, + submitter=False, name="city.gov", ): """A completed domain application.""" @@ -541,13 +542,14 @@ def completed_application( domain, _ = DraftDomain.objects.get_or_create(name=name) alt, _ = Website.objects.get_or_create(website="city1.gov") current, _ = Website.objects.get_or_create(website="city.com") - you, _ = Contact.objects.get_or_create( - first_name="Testy2", - last_name="Tester2", - title="Admin Tester", - email="mayor@igorville.gov", - phone="(555) 555 5556", - ) + if not submitter: + submitter, _ = Contact.objects.get_or_create( + first_name="Testy2", + last_name="Tester2", + title="Admin Tester", + email="mayor@igorville.gov", + phone="(555) 555 5556", + ) other, _ = Contact.objects.get_or_create( first_name="Testy", last_name="Tester", @@ -567,7 +569,7 @@ def completed_application( zipcode="10002", authorizing_official=ao, requested_domain=domain, - submitter=you, + submitter=submitter, creator=user, status=status, ) diff --git a/src/registrar/tests/test_admin.py b/src/registrar/tests/test_admin.py index f7b1ef06e..0a40f85fb 100644 --- a/src/registrar/tests/test_admin.py +++ b/src/registrar/tests/test_admin.py @@ -1735,5 +1735,72 @@ class ContactAdminTest(TestCase): self.assertEqual(readonly_fields, expected_fields) + def test_change_view_for_joined_contact_five_or_less(self): + """Create a contact, join it to 4 domain requests. The 5th join will be a user. + Assert that the warning on the contact form lists 5 joins.""" + + self.client.force_login(self.superuser) + + # Create an instance of the model + contact, _ = Contact.objects.get_or_create(user=self.staffuser) + + # join it to 4 domain requests. The 5th join will be a user. + completed_application(submitter=contact, name="city1.gov") + completed_application(submitter=contact, name="city2.gov") + completed_application(submitter=contact, name="city3.gov") + completed_application(submitter=contact, name="city4.gov") + + with patch("django.contrib.messages.warning") as mock_warning: + # Use the test client to simulate the request + response = self.client.get(reverse("admin:registrar_contact_change", args=[contact.pk])) + + logger.info(mock_warning) + + # Assert that the error message was called with the correct argument + # Note: The 5th join will be a user. + mock_warning.assert_called_once_with( + response.wsgi_request, + "Joined to DomainApplication: city1.gov
                      " + "Joined to DomainApplication: city2.gov
                      " + "Joined to DomainApplication: city3.gov
                      " + "Joined to DomainApplication: city4.gov
                      " + "Joined to User: staff@example.com
                      ", + ) + + def test_change_view_for_joined_contact_five_or_more(self): + """Create a contact, join it to 5 domain requests. The 6th join will be a user. + Assert that the warning on the contact form lists 5 joins and a '1 more' ellispsis.""" + + self.client.force_login(self.superuser) + + # Create an instance of the model + # join it to 5 domain requests. The 6th join will be a user. + contact, _ = Contact.objects.get_or_create(user=self.staffuser) + completed_application(submitter=contact, name="city1.gov") + completed_application(submitter=contact, name="city2.gov") + completed_application(submitter=contact, name="city3.gov") + completed_application(submitter=contact, name="city4.gov") + completed_application(submitter=contact, name="city5.gov") + + with patch("django.contrib.messages.warning") as mock_warning: + # Use the test client to simulate the request + response = self.client.get(reverse("admin:registrar_contact_change", args=[contact.pk])) + + logger.info(mock_warning) + + # Assert that the error message was called with the correct argument + # Note: The 6th join will be a user. + mock_warning.assert_called_once_with( + response.wsgi_request, + "Joined to DomainApplication: city1.gov
                      " + "Joined to DomainApplication: city2.gov
                      " + "Joined to DomainApplication: city3.gov
                      " + "Joined to DomainApplication: city4.gov
                      " + "Joined to DomainApplication: city5.gov
                      " + "And 1 more...", + ) + def tearDown(self): + DomainApplication.objects.all().delete() + Contact.objects.all().delete() User.objects.all().delete() From 694ae50e34990158bce63fec5e42f0b145d07bce Mon Sep 17 00:00:00 2001 From: Rebecca Hsieh Date: Thu, 25 Jan 2024 11:58:38 -0800 Subject: [PATCH 073/137] Variable cleanup and function refactoring --- src/registrar/assets/js/get-gov.js | 19 +++++++++---------- src/registrar/models/domain.py | 13 +++++++------ 2 files changed, 16 insertions(+), 16 deletions(-) diff --git a/src/registrar/assets/js/get-gov.js b/src/registrar/assets/js/get-gov.js index 69ba50cd4..fba043888 100644 --- a/src/registrar/assets/js/get-gov.js +++ b/src/registrar/assets/js/get-gov.js @@ -212,23 +212,20 @@ function handleValidationClick(e) { } -function handleFormsetValidationClick(e) { - // Check availability for alternative domains - - const alternativeDomainsAvailability = document.getElementById('check-avail-for-alt-domains'); - +function handleFormsetValidationClick(e, availabilityButton) { + // Collect input IDs from the repeatable forms - let inputIds = Array.from(document.querySelectorAll('.repeatable-form input')).map(input => input.id); + let inputs = Array.from(document.querySelectorAll('.repeatable-form input')) // Run validators for each input - inputIds.forEach(inputId => { - const input = document.getElementById(inputId); + inputs.forEach(input => { runValidators(input); }); // Set the validate-for attribute on the button with the collected input IDs // Not needed for functionality but nice for accessibility - alternativeDomainsAvailability.setAttribute('validate-for', inputIds.join(', ')); + inputs = inputs.map(input => input.id).join(', '); + availabilityButton.setAttribute('validate-for', inputs); } // <<>><<>><<>><<>><<>><<>><<>><<>><<>><<>><<>><<>><<>><<>><<>> @@ -256,7 +253,9 @@ function handleFormsetValidationClick(e) { for(const button of activatesValidation) { // Adds multi-field validation for alternative domains if (button === alternativeDomainsAvailability) { - button.addEventListener('click', handleFormsetValidationClick); + button.addEventListener('click', (e) => { + handleFormsetValidationClick(e, alternativeDomainsAvailability) + }); } else { button.addEventListener('click', handleValidationClick); } diff --git a/src/registrar/models/domain.py b/src/registrar/models/domain.py index 1a581a4ec..6b5f0d19c 100644 --- a/src/registrar/models/domain.py +++ b/src/registrar/models/domain.py @@ -173,12 +173,13 @@ class Domain(TimeStampedModel, DomainHelper): @classmethod def available(cls, domain: str) -> bool: - """Check if a domain is available.""" - if not cls.string_could_be_domain(domain): - raise ValueError("Not a valid domain: %s" % str(domain)) - domain_name = domain.lower() - req = commands.CheckDomain([domain_name]) - return registry.send(req, cleaned=True).res_data[0].avail + return True + # """Check if a domain is available.""" + # if not cls.string_could_be_domain(domain): + # raise ValueError("Not a valid domain: %s" % str(domain)) + # domain_name = domain.lower() + # req = commands.CheckDomain([domain_name]) + # return registry.send(req, cleaned=True).res_data[0].avail @classmethod def registered(cls, domain: str) -> bool: From d9222864f975ba977875b1d71fd966e39d4aa3c2 Mon Sep 17 00:00:00 2001 From: Rachid Mrad Date: Thu, 25 Jan 2024 15:29:51 -0500 Subject: [PATCH 074/137] Fix pks in new tests to be aware of dynamic changes --- src/registrar/tests/test_admin.py | 36 +++++++++++++++---------------- 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/src/registrar/tests/test_admin.py b/src/registrar/tests/test_admin.py index 4bd58db25..43771a260 100644 --- a/src/registrar/tests/test_admin.py +++ b/src/registrar/tests/test_admin.py @@ -1747,10 +1747,10 @@ class ContactAdminTest(TestCase): contact, _ = Contact.objects.get_or_create(user=self.staffuser) # join it to 4 domain requests. The 5th join will be a user. - completed_application(submitter=contact, name="city1.gov") - completed_application(submitter=contact, name="city2.gov") - completed_application(submitter=contact, name="city3.gov") - completed_application(submitter=contact, name="city4.gov") + application1 = completed_application(submitter=contact, name="city1.gov") + application2 = completed_application(submitter=contact, name="city2.gov") + application3 = completed_application(submitter=contact, name="city3.gov") + application4 = completed_application(submitter=contact, name="city4.gov") with patch("django.contrib.messages.warning") as mock_warning: # Use the test client to simulate the request @@ -1762,10 +1762,10 @@ class ContactAdminTest(TestCase): # Note: The 5th join will be a user. mock_warning.assert_called_once_with( response.wsgi_request, - "Joined to DomainApplication: city1.gov
                      " - "Joined to DomainApplication: city2.gov
                      " - "Joined to DomainApplication: city3.gov
                      " - "Joined to DomainApplication: city4.gov
                      " + f"Joined to DomainApplication: city1.gov
                      " + f"Joined to DomainApplication: city2.gov
                      " + f"Joined to DomainApplication: city3.gov
                      " + f"Joined to DomainApplication: city4.gov
                      " "Joined to User: staff@example.com
                      ", ) @@ -1778,11 +1778,11 @@ class ContactAdminTest(TestCase): # Create an instance of the model # join it to 5 domain requests. The 6th join will be a user. contact, _ = Contact.objects.get_or_create(user=self.staffuser) - completed_application(submitter=contact, name="city1.gov") - completed_application(submitter=contact, name="city2.gov") - completed_application(submitter=contact, name="city3.gov") - completed_application(submitter=contact, name="city4.gov") - completed_application(submitter=contact, name="city5.gov") + application1 = completed_application(submitter=contact, name="city1.gov") + application2 = completed_application(submitter=contact, name="city2.gov") + application3 = completed_application(submitter=contact, name="city3.gov") + application4 = completed_application(submitter=contact, name="city4.gov") + application5 = completed_application(submitter=contact, name="city5.gov") with patch("django.contrib.messages.warning") as mock_warning: # Use the test client to simulate the request @@ -1794,11 +1794,11 @@ class ContactAdminTest(TestCase): # Note: The 6th join will be a user. mock_warning.assert_called_once_with( response.wsgi_request, - "Joined to DomainApplication: city1.gov
                      " - "Joined to DomainApplication: city2.gov
                      " - "Joined to DomainApplication: city3.gov
                      " - "Joined to DomainApplication: city4.gov
                      " - "Joined to DomainApplication: city5.gov
                      " + f"Joined to DomainApplication: city1.gov
                      " + f"Joined to DomainApplication: city2.gov
                      " + f"Joined to DomainApplication: city3.gov
                      " + f"Joined to DomainApplication: city4.gov
                      " + f"Joined to DomainApplication: city5.gov
                      " "And 1 more...", ) From 29af5d4ac67a0e960ca83f6342b3d868a97193ee Mon Sep 17 00:00:00 2001 From: Rebecca Hsieh Date: Thu, 25 Jan 2024 12:43:40 -0800 Subject: [PATCH 075/137] Update spacing --- src/registrar/assets/js/get-gov.js | 1 - 1 file changed, 1 deletion(-) diff --git a/src/registrar/assets/js/get-gov.js b/src/registrar/assets/js/get-gov.js index fba043888..af968b842 100644 --- a/src/registrar/assets/js/get-gov.js +++ b/src/registrar/assets/js/get-gov.js @@ -206,7 +206,6 @@ function handleInputValidation(e) { function handleValidationClick(e) { const attribute = e.target.getAttribute("validate-for") || ""; if (!attribute.length) return; - const input = document.getElementById(attribute); runValidators(input); } From ff44b2c4d9eab07f59292ebd208312a31826de8e Mon Sep 17 00:00:00 2001 From: Rebecca Hsieh Date: Thu, 25 Jan 2024 12:49:01 -0800 Subject: [PATCH 076/137] Add in EPP fix my bad --- src/registrar/models/domain.py | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/src/registrar/models/domain.py b/src/registrar/models/domain.py index 6b5f0d19c..1a581a4ec 100644 --- a/src/registrar/models/domain.py +++ b/src/registrar/models/domain.py @@ -173,13 +173,12 @@ class Domain(TimeStampedModel, DomainHelper): @classmethod def available(cls, domain: str) -> bool: - return True - # """Check if a domain is available.""" - # if not cls.string_could_be_domain(domain): - # raise ValueError("Not a valid domain: %s" % str(domain)) - # domain_name = domain.lower() - # req = commands.CheckDomain([domain_name]) - # return registry.send(req, cleaned=True).res_data[0].avail + """Check if a domain is available.""" + if not cls.string_could_be_domain(domain): + raise ValueError("Not a valid domain: %s" % str(domain)) + domain_name = domain.lower() + req = commands.CheckDomain([domain_name]) + return registry.send(req, cleaned=True).res_data[0].avail @classmethod def registered(cls, domain: str) -> bool: From 72bcf452767315fdd095b7cc6de784836621ece1 Mon Sep 17 00:00:00 2001 From: CocoByte Date: Thu, 25 Jan 2024 16:08:06 -0700 Subject: [PATCH 077/137] Added command to auto-run migrations on deploy-development --- .github/workflows/deploy-development.yaml | 25 +++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/.github/workflows/deploy-development.yaml b/.github/workflows/deploy-development.yaml index 562b2b11f..ee3f6004f 100644 --- a/.github/workflows/deploy-development.yaml +++ b/.github/workflows/deploy-development.yaml @@ -4,6 +4,28 @@ name: Build and deploy development for release on: + # This workflow_dispatch trigger was added for testing purposes. + # It enables us to manually run this set of jobs in git + workflow_dispatch: + inputs: + environment: + type: choice + description: Which environment should we use? + options: + - staging + - development + - backup + - ky + - es + - nl + - rh + - za + - gd + - rb + - ko + - ab + - rjm + - dk push: paths-ignore: - 'docs/**' @@ -28,6 +50,9 @@ jobs: - name: Collect static assets working-directory: ./src run: docker compose run app python manage.py collectstatic --no-input + - name: Run Django migrations + working-directory: ./src + run: docker compose run app python manage.py migrate - name: Deploy to cloud.gov sandbox uses: 18f/cg-deploy-action@main env: From 39c634bc3c1f7f2730f843d38641db26197ebb7f Mon Sep 17 00:00:00 2001 From: CocoByte Date: Thu, 25 Jan 2024 22:34:13 -0700 Subject: [PATCH 078/137] Attempt to enable workflow_dispatch trigger --- .github/workflows/deploy-development.yaml | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) diff --git a/.github/workflows/deploy-development.yaml b/.github/workflows/deploy-development.yaml index ee3f6004f..b9c9d470c 100644 --- a/.github/workflows/deploy-development.yaml +++ b/.github/workflows/deploy-development.yaml @@ -4,8 +4,6 @@ name: Build and deploy development for release on: - # This workflow_dispatch trigger was added for testing purposes. - # It enables us to manually run this set of jobs in git workflow_dispatch: inputs: environment: @@ -26,14 +24,6 @@ on: - ab - rjm - dk - push: - paths-ignore: - - 'docs/**' - - '**.md' - - '.gitignore' - - branches: - - main jobs: deploy-development: @@ -52,7 +42,8 @@ jobs: run: docker compose run app python manage.py collectstatic --no-input - name: Run Django migrations working-directory: ./src - run: docker compose run app python manage.py migrate + run: docker compose run app python manage.py migrate --no-input + cf_command: "run-task getgov-${{ github.event.inputs.environment }} --command 'python manage.py migrate' --name migrate" - name: Deploy to cloud.gov sandbox uses: 18f/cg-deploy-action@main env: From a438b8174fd36f8a3cf387f8e059df3999d439c4 Mon Sep 17 00:00:00 2001 From: CocoByte Date: Thu, 25 Jan 2024 22:39:22 -0700 Subject: [PATCH 079/137] Fix error in yaml --- .github/workflows/deploy-development.yaml | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/.github/workflows/deploy-development.yaml b/.github/workflows/deploy-development.yaml index b9c9d470c..ee3f6004f 100644 --- a/.github/workflows/deploy-development.yaml +++ b/.github/workflows/deploy-development.yaml @@ -4,6 +4,8 @@ name: Build and deploy development for release on: + # This workflow_dispatch trigger was added for testing purposes. + # It enables us to manually run this set of jobs in git workflow_dispatch: inputs: environment: @@ -24,6 +26,14 @@ on: - ab - rjm - dk + push: + paths-ignore: + - 'docs/**' + - '**.md' + - '.gitignore' + + branches: + - main jobs: deploy-development: @@ -42,8 +52,7 @@ jobs: run: docker compose run app python manage.py collectstatic --no-input - name: Run Django migrations working-directory: ./src - run: docker compose run app python manage.py migrate --no-input - cf_command: "run-task getgov-${{ github.event.inputs.environment }} --command 'python manage.py migrate' --name migrate" + run: docker compose run app python manage.py migrate - name: Deploy to cloud.gov sandbox uses: 18f/cg-deploy-action@main env: From c45eb237173b6a59f626bd729efc11ab47974899 Mon Sep 17 00:00:00 2001 From: CocoByte Date: Thu, 25 Jan 2024 22:57:08 -0700 Subject: [PATCH 080/137] Attempt to enable workflow_dispatch trigger --- .github/workflows/deploy-development.yaml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.github/workflows/deploy-development.yaml b/.github/workflows/deploy-development.yaml index ee3f6004f..ae79a06ca 100644 --- a/.github/workflows/deploy-development.yaml +++ b/.github/workflows/deploy-development.yaml @@ -4,8 +4,6 @@ name: Build and deploy development for release on: - # This workflow_dispatch trigger was added for testing purposes. - # It enables us to manually run this set of jobs in git workflow_dispatch: inputs: environment: From 564f60f72abc7d3a1d84e5b580b61af0f86549cd Mon Sep 17 00:00:00 2001 From: CocoByte Date: Thu, 25 Jan 2024 23:07:52 -0700 Subject: [PATCH 081/137] Re-trigger workflow --- .github/workflows/deploy-development.yaml | 20 -------------------- 1 file changed, 20 deletions(-) diff --git a/.github/workflows/deploy-development.yaml b/.github/workflows/deploy-development.yaml index ae79a06ca..6eb214eec 100644 --- a/.github/workflows/deploy-development.yaml +++ b/.github/workflows/deploy-development.yaml @@ -4,26 +4,6 @@ name: Build and deploy development for release on: - workflow_dispatch: - inputs: - environment: - type: choice - description: Which environment should we use? - options: - - staging - - development - - backup - - ky - - es - - nl - - rh - - za - - gd - - rb - - ko - - ab - - rjm - - dk push: paths-ignore: - 'docs/**' From 13e1dd6224694dd3685f6e95074feb1ecb5fb242 Mon Sep 17 00:00:00 2001 From: CocoByte Date: Thu, 25 Jan 2024 23:12:15 -0700 Subject: [PATCH 082/137] re-enable workflow trigger --- .github/workflows/deploy-development.yaml | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/.github/workflows/deploy-development.yaml b/.github/workflows/deploy-development.yaml index 6eb214eec..ae79a06ca 100644 --- a/.github/workflows/deploy-development.yaml +++ b/.github/workflows/deploy-development.yaml @@ -4,6 +4,26 @@ name: Build and deploy development for release on: + workflow_dispatch: + inputs: + environment: + type: choice + description: Which environment should we use? + options: + - staging + - development + - backup + - ky + - es + - nl + - rh + - za + - gd + - rb + - ko + - ab + - rjm + - dk push: paths-ignore: - 'docs/**' From cfda4416da07ec77fa57de99220bcc58085d2630 Mon Sep 17 00:00:00 2001 From: CocoByte Date: Thu, 25 Jan 2024 23:45:37 -0700 Subject: [PATCH 083/137] Trigger workflow on push to local branch --- .github/workflows/deploy-development.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/deploy-development.yaml b/.github/workflows/deploy-development.yaml index ae79a06ca..c69ddc5cb 100644 --- a/.github/workflows/deploy-development.yaml +++ b/.github/workflows/deploy-development.yaml @@ -32,6 +32,7 @@ on: branches: - main + - nl/1595-auto-run-migrations jobs: deploy-development: From 633855b57090a0e9aeb1a038aa144634f20c873a Mon Sep 17 00:00:00 2001 From: David Kennedy Date: Fri, 26 Jan 2024 10:24:50 -0500 Subject: [PATCH 084/137] fix situation where there are no other contacts in application status --- src/registrar/templates/application_status.html | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/registrar/templates/application_status.html b/src/registrar/templates/application_status.html index 590d00b28..c2178ef00 100644 --- a/src/registrar/templates/application_status.html +++ b/src/registrar/templates/application_status.html @@ -109,8 +109,12 @@ {% include "includes/summary_item.html" with title='Your contact information' value=domainapplication.submitter contact='true' heading_level=heading_level %} {% endif %} - {% include "includes/summary_item.html" with title='Other employees from your organization' value=domainapplication.other_contacts.all contact='true' list='true' heading_level=heading_level %} - + {% if domainapplication.other_contacts.all %} + {% include "includes/summary_item.html" with title='Other employees from your organization' value=domainapplication.other_contacts.all contact='true' list='true' heading_level=heading_level %} + {% else %} + {% include "includes/summary_item.html" with title='No other employees from your organization?' value=domainapplication.no_other_contacts_rationale heading_level=heading_level %} + {% endif %} + {% include "includes/summary_item.html" with title='Anything else?' value=domainapplication.anything_else|default:"No" heading_level=heading_level %} {% endwith %} From 96b929834f160119531af5b80956db3c44b0fdb3 Mon Sep 17 00:00:00 2001 From: David Kennedy Date: Fri, 26 Jan 2024 11:35:09 -0500 Subject: [PATCH 085/137] fixed broken test in test_admin --- src/registrar/tests/test_admin.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/registrar/tests/test_admin.py b/src/registrar/tests/test_admin.py index 43771a260..4bc532f10 100644 --- a/src/registrar/tests/test_admin.py +++ b/src/registrar/tests/test_admin.py @@ -1766,7 +1766,7 @@ class ContactAdminTest(TestCase): f"Joined to DomainApplication: city2.gov
                      " f"Joined to DomainApplication: city3.gov
                      " f"Joined to DomainApplication: city4.gov
                      " - "Joined to User: staff@example.com
                      ", + f"Joined to User: staff@example.com
                      ", ) def test_change_view_for_joined_contact_five_or_more(self): From 39cff906a796dd5d2d8dc77fea5590470de4c65a Mon Sep 17 00:00:00 2001 From: David Kennedy Date: Fri, 26 Jan 2024 11:41:04 -0500 Subject: [PATCH 086/137] linting --- src/registrar/tests/test_admin.py | 30 ++++++++++++++++++++---------- 1 file changed, 20 insertions(+), 10 deletions(-) diff --git a/src/registrar/tests/test_admin.py b/src/registrar/tests/test_admin.py index 4bc532f10..796e22b59 100644 --- a/src/registrar/tests/test_admin.py +++ b/src/registrar/tests/test_admin.py @@ -1762,11 +1762,16 @@ class ContactAdminTest(TestCase): # Note: The 5th join will be a user. mock_warning.assert_called_once_with( response.wsgi_request, - f"Joined to DomainApplication: city1.gov
                      " - f"Joined to DomainApplication: city2.gov
                      " - f"Joined to DomainApplication: city3.gov
                      " - f"Joined to DomainApplication: city4.gov
                      " - f"Joined to User: staff@example.com
                      ", + f"Joined to DomainApplication: " + "city1.gov
                      " + f"Joined to DomainApplication: " + "city2.gov
                      " + f"Joined to DomainApplication: " + "city3.gov
                      " + f"Joined to DomainApplication: " + "city4.gov
                      " + f"Joined to User: " + "staff@example.com
                      ", ) def test_change_view_for_joined_contact_five_or_more(self): @@ -1794,11 +1799,16 @@ class ContactAdminTest(TestCase): # Note: The 6th join will be a user. mock_warning.assert_called_once_with( response.wsgi_request, - f"Joined to DomainApplication: city1.gov
                      " - f"Joined to DomainApplication: city2.gov
                      " - f"Joined to DomainApplication: city3.gov
                      " - f"Joined to DomainApplication: city4.gov
                      " - f"Joined to DomainApplication: city5.gov
                      " + f"Joined to DomainApplication: " + "city1.gov
                      " + f"Joined to DomainApplication: " + "city2.gov
                      " + f"Joined to DomainApplication: " + "city3.gov
                      " + f"Joined to DomainApplication: " + "city4.gov
                      " + f"Joined to DomainApplication: " + "city5.gov
                      " "And 1 more...", ) From 2d717b030742f291c8b3150c9bf559f802c861ec Mon Sep 17 00:00:00 2001 From: Rachid Mrad Date: Fri, 26 Jan 2024 12:38:24 -0500 Subject: [PATCH 087/137] css refactor --- src/registrar/assets/sass/_theme/_lists.scss | 14 ++++++++++++++ .../assets/sass/_theme/_register-form.scss | 16 ++++++++++++++-- src/registrar/assets/sass/_theme/styles.scss | 1 + src/registrar/templates/application_review.html | 2 +- .../templates/includes/summary_item.html | 4 ++-- 5 files changed, 32 insertions(+), 5 deletions(-) create mode 100644 src/registrar/assets/sass/_theme/_lists.scss diff --git a/src/registrar/assets/sass/_theme/_lists.scss b/src/registrar/assets/sass/_theme/_lists.scss new file mode 100644 index 000000000..b97abd569 --- /dev/null +++ b/src/registrar/assets/sass/_theme/_lists.scss @@ -0,0 +1,14 @@ +@use "uswds-core" as *; + +dt { + color: color('primary-dark'); + margin-top: units(2); + font-weight: font-weight('semibold'); + // The units mixin can only get us close, so it's between + // hardcoding the value and using in markup + font-size: 16.96px; +} +dd { + margin-left: 0; +} + diff --git a/src/registrar/assets/sass/_theme/_register-form.scss b/src/registrar/assets/sass/_theme/_register-form.scss index d78bc512a..7c93f0a10 100644 --- a/src/registrar/assets/sass/_theme/_register-form.scss +++ b/src/registrar/assets/sass/_theme/_register-form.scss @@ -6,13 +6,15 @@ margin-top: units(-1); } - //Tighter spacing when H2 is immediatly after H1 +// Tighter spacing when h2 is immediatly after h1 .register-form-step .usa-fieldset:first-of-type h2:first-of-type, .register-form-step h1 + h2 { margin-top: units(1); } -.register-form-step h3:not(.text-base-darkest) { +// register-form-review-header is used on the summary page and +// should not be styled like the register form headers +.register-form-step h3 { color: color('primary-dark'); letter-spacing: $letter-space--xs; margin-top: units(3); @@ -23,6 +25,16 @@ } } +h3.register-form-review-header { + color: color('primary-dark'); + margin-top: units(2); + margin-bottom: 0; + font-weight: font-weight('semibold'); + // The units mixin can only get us close, so it's between + // hardcoding the value and using in markup + font-size: 16.96px; +} + .register-form-step h4 { margin-bottom: 0; diff --git a/src/registrar/assets/sass/_theme/styles.scss b/src/registrar/assets/sass/_theme/styles.scss index 8a2e1d2d3..0239199e7 100644 --- a/src/registrar/assets/sass/_theme/styles.scss +++ b/src/registrar/assets/sass/_theme/styles.scss @@ -10,6 +10,7 @@ --- Custom Styles ---------------------------------*/ @forward "base"; @forward "typography"; +@forward "lists"; @forward "buttons"; @forward "forms"; @forward "fieldsets"; diff --git a/src/registrar/templates/application_review.html b/src/registrar/templates/application_review.html index b6d37f6e3..7a4c1529b 100644 --- a/src/registrar/templates/application_review.html +++ b/src/registrar/templates/application_review.html @@ -112,7 +112,7 @@ {% endwith %} {% if application.alternative_domains.all %} -

                      Alternative domains

                      +

                      Alternative domains

                        {% for site in application.alternative_domains.all %}
                      • {{ site.website }}
                      • diff --git a/src/registrar/templates/includes/summary_item.html b/src/registrar/templates/includes/summary_item.html index d2bdae709..7c0d801ad 100644 --- a/src/registrar/templates/includes/summary_item.html +++ b/src/registrar/templates/includes/summary_item.html @@ -31,10 +31,10 @@ {% if value %}
                        {% for item in value %} -
                        +
                        Contact {{forloop.counter}}
                        -
                        +
                        {% include "includes/contact.html" with contact=item %}
                        {% endfor %} From 5a7b9b3a2275b4091a9e28016516ac0e0a8dab00 Mon Sep 17 00:00:00 2001 From: David Kennedy Date: Fri, 26 Jan 2024 12:39:15 -0500 Subject: [PATCH 088/137] changes to display of type of organization and to election office --- src/registrar/templates/application_review.html | 2 +- src/registrar/templates/application_status.html | 8 +++++--- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/registrar/templates/application_review.html b/src/registrar/templates/application_review.html index b6d37f6e3..933766bbc 100644 --- a/src/registrar/templates/application_review.html +++ b/src/registrar/templates/application_review.html @@ -25,7 +25,7 @@ {% if step == Step.ORGANIZATION_TYPE %} {% namespaced_url 'application' step as application_url %} {% if application.organization_type is not None %} - {% with title=form_titles|get_item:step value=application.organization_type|get_organization_long_name|default:"Incomplete" %} + {% with title=form_titles|get_item:step value=application.get_organization_type_display|default:"Incomplete" %} {% include "includes/summary_item.html" with title=title value=value heading_level=heading_level editable=True edit_link=application_url %} {% endwith %} {% else %} diff --git a/src/registrar/templates/application_status.html b/src/registrar/templates/application_status.html index c2178ef00..edbf86e7a 100644 --- a/src/registrar/templates/application_status.html +++ b/src/registrar/templates/application_status.html @@ -52,8 +52,8 @@

                        Summary of your domain request

                        {% with heading_level='h3' %} - {% with long_org_type=domainapplication.organization_type|get_organization_long_name %} - {% include "includes/summary_item.html" with title='Type of organization' value=long_org_type heading_level=heading_level %} + {% with org_type=domainapplication.get_organization_type_display %} + {% include "includes/summary_item.html" with title='Type of organization' value=org_type heading_level=heading_level %} {% endwith %} {% if domainapplication.tribe_name %} @@ -74,7 +74,9 @@ {% endif %} {% if domainapplication.is_election_board %} - {% include "includes/summary_item.html" with title='Election office' value=domainapplication.is_election_board heading_level=heading_level %} + {% with value=domainapplication.is_election_board|yesno:"Yes,No,Incomplete" %} + {% include "includes/summary_item.html" with title='Election office' value=value heading_level=heading_level %} + {% endwith %} {% endif %} {% if domainapplication.organization_name %} From d66899164d2f8660e71201e65c7f4003861a2b3b Mon Sep 17 00:00:00 2001 From: zandercymatics <141044360+zandercymatics@users.noreply.github.com> Date: Fri, 26 Jan 2024 10:41:45 -0700 Subject: [PATCH 089/137] Improve speed of load_transition_domain script Slightly decrease the wait time for the load transitoin domain script for testing purposes --- .../utility/extra_transition_domain_helper.py | 24 +++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/src/registrar/management/commands/utility/extra_transition_domain_helper.py b/src/registrar/management/commands/utility/extra_transition_domain_helper.py index 755c9b98a..926dc4553 100644 --- a/src/registrar/management/commands/utility/extra_transition_domain_helper.py +++ b/src/registrar/management/commands/utility/extra_transition_domain_helper.py @@ -182,8 +182,6 @@ class LoadExtraTransitionDomain: # STEP 5: Parse creation and expiration data updated_transition_domain = self.parse_creation_expiration_data(domain_name, transition_domain) - # Check if the instance has changed before saving - updated_transition_domain.save() updated_transition_domains.append(updated_transition_domain) logger.info(f"{TerminalColors.OKCYAN}" f"Successfully updated {domain_name}" f"{TerminalColors.ENDC}") @@ -198,6 +196,28 @@ class LoadExtraTransitionDomain: f"{TerminalColors.ENDC}" ) failed_transition_domains.append(domain_name) + + updated_fields = [ + "organization_name", + "organization_type", + "federal_type", + "federal_agency", + "first_name", + "middle_name", + "last_name", + "email", + "phone", + "epp_creation_date", + "epp_expiration_date", + ] + + batch_size = 1000 + # Create a Paginator object. Bulk_update on the full dataset + # is too memory intensive for our current app config, so we can chunk this data instead. + paginator = Paginator(updated_transition_domains, batch_size) + for page_num in paginator.page_range: + page = paginator.page(page_num) + TransitionDomain.objects.bulk_update(page.object_list, updated_fields) failed_count = len(failed_transition_domains) if failed_count == 0: From 5244f34433eeb475703c0b188d271166807e4369 Mon Sep 17 00:00:00 2001 From: David Kennedy Date: Fri, 26 Jan 2024 12:49:53 -0500 Subject: [PATCH 090/137] modified unit tests for the change in display of organization type --- src/registrar/tests/test_views.py | 14 +------------- 1 file changed, 1 insertion(+), 13 deletions(-) diff --git a/src/registrar/tests/test_views.py b/src/registrar/tests/test_views.py index 60ffab416..3796ba844 100644 --- a/src/registrar/tests/test_views.py +++ b/src/registrar/tests/test_views.py @@ -499,7 +499,7 @@ class DomainApplicationTests(TestWithUser, WebTest): # Review page contains all the previously entered data # Let's make sure the long org name is displayed - self.assertContains(review_page, "Federal: an agency of the U.S. government") + self.assertContains(review_page, "Federal") self.assertContains(review_page, "Executive") self.assertContains(review_page, "Testorg") self.assertContains(review_page, "address 1") @@ -2147,18 +2147,6 @@ class DomainApplicationTests(TestWithUser, WebTest): self.assertContains(type_page, "Federal: an agency of the U.S. government") - def test_long_org_name_in_application_manage(self): - """ - Make sure the long name is displaying in the application summary - page (manage your application) - """ - completed_application(status=DomainApplication.ApplicationStatus.SUBMITTED, user=self.user) - home_page = self.app.get("/") - self.assertContains(home_page, "city.gov") - # click the "Edit" link - detail_page = home_page.click("Manage", index=0) - self.assertContains(detail_page, "Federal: an agency of the U.S. government") - def test_submit_modal_no_domain_text_fallback(self): """When user clicks on submit your domain request and the requested domain is null (possible through url direct access to the review page), present From 18c3c0d01e03c179248987ee5976fed143fc6247 Mon Sep 17 00:00:00 2001 From: zandercymatics <141044360+zandercymatics@users.noreply.github.com> Date: Fri, 26 Jan 2024 10:53:52 -0700 Subject: [PATCH 091/137] Add back important --- src/registrar/assets/sass/_theme/_buttons.scss | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/registrar/assets/sass/_theme/_buttons.scss b/src/registrar/assets/sass/_theme/_buttons.scss index b168551b5..0576f8b47 100644 --- a/src/registrar/assets/sass/_theme/_buttons.scss +++ b/src/registrar/assets/sass/_theme/_buttons.scss @@ -47,8 +47,8 @@ a.usa-button.disabled-link:focus { a.usa-button--unstyled.disabled-link, a.usa-button--unstyled.disabled-link:hover, a.usa-button--unstyled.disabled-link:focus { - cursor: not-allowed; - outline: none; + cursor: not-allowed !important; + outline: none !important; } a.usa-button:not(.usa-button--unstyled, .usa-button--outline) { From c60f5bb6bcab59ee242ab9fb6afbd19916d01e90 Mon Sep 17 00:00:00 2001 From: zandercymatics <141044360+zandercymatics@users.noreply.github.com> Date: Fri, 26 Jan 2024 10:54:18 -0700 Subject: [PATCH 092/137] Undo important (my bad) --- src/registrar/assets/sass/_theme/_buttons.scss | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/registrar/assets/sass/_theme/_buttons.scss b/src/registrar/assets/sass/_theme/_buttons.scss index 0576f8b47..b168551b5 100644 --- a/src/registrar/assets/sass/_theme/_buttons.scss +++ b/src/registrar/assets/sass/_theme/_buttons.scss @@ -47,8 +47,8 @@ a.usa-button.disabled-link:focus { a.usa-button--unstyled.disabled-link, a.usa-button--unstyled.disabled-link:hover, a.usa-button--unstyled.disabled-link:focus { - cursor: not-allowed !important; - outline: none !important; + cursor: not-allowed; + outline: none; } a.usa-button:not(.usa-button--unstyled, .usa-button--outline) { From 30f6c93aaa2498d22b727335c8005b3c5d1e679c Mon Sep 17 00:00:00 2001 From: zandercymatics <141044360+zandercymatics@users.noreply.github.com> Date: Fri, 26 Jan 2024 11:15:34 -0700 Subject: [PATCH 093/137] Update _buttons.scss --- src/registrar/assets/sass/_theme/_buttons.scss | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/registrar/assets/sass/_theme/_buttons.scss b/src/registrar/assets/sass/_theme/_buttons.scss index b168551b5..0576f8b47 100644 --- a/src/registrar/assets/sass/_theme/_buttons.scss +++ b/src/registrar/assets/sass/_theme/_buttons.scss @@ -47,8 +47,8 @@ a.usa-button.disabled-link:focus { a.usa-button--unstyled.disabled-link, a.usa-button--unstyled.disabled-link:hover, a.usa-button--unstyled.disabled-link:focus { - cursor: not-allowed; - outline: none; + cursor: not-allowed !important; + outline: none !important; } a.usa-button:not(.usa-button--unstyled, .usa-button--outline) { From 44d1d65f84ff93faef12dded69f961a34c007b72 Mon Sep 17 00:00:00 2001 From: CocoByte Date: Fri, 26 Jan 2024 11:15:51 -0700 Subject: [PATCH 094/137] Moved migrations to run in correct location. Added PR trigger --- .github/workflows/deploy-development.yaml | 36 +++++++++-------------- 1 file changed, 14 insertions(+), 22 deletions(-) diff --git a/.github/workflows/deploy-development.yaml b/.github/workflows/deploy-development.yaml index c69ddc5cb..7572accf7 100644 --- a/.github/workflows/deploy-development.yaml +++ b/.github/workflows/deploy-development.yaml @@ -5,25 +5,12 @@ name: Build and deploy development for release on: workflow_dispatch: - inputs: - environment: - type: choice - description: Which environment should we use? - options: - - staging - - development - - backup - - ky - - es - - nl - - rh - - za - - gd - - rb - - ko - - ab - - rjm - - dk + pull_request: + types: + - opened + - review_requested + branches: + - 'releases/**' push: paths-ignore: - 'docs/**' @@ -49,9 +36,6 @@ jobs: - name: Collect static assets working-directory: ./src run: docker compose run app python manage.py collectstatic --no-input - - name: Run Django migrations - working-directory: ./src - run: docker compose run app python manage.py migrate - name: Deploy to cloud.gov sandbox uses: 18f/cg-deploy-action@main env: @@ -62,3 +46,11 @@ jobs: cf_org: cisa-dotgov cf_space: development push_arguments: "-f ops/manifests/manifest-development.yaml" + - name: Run Django migrations + uses: cloud-gov/cg-cli-tools@main + with: + cf_username: ${{ secrets.CF_DEVELOPMENT_USERNAME }} + cf_password: ${{ secrets.CF_DEVELOPMENT_PASSWORD }} + cf_org: cisa-dotgov + cf_space: development + cf_command: "run-task getgov-development --command 'python manage.py migrate' --name migrate" From fedca3098080f64894367d01b011fa939294b838 Mon Sep 17 00:00:00 2001 From: Rachid Mrad Date: Fri, 26 Jan 2024 13:20:01 -0500 Subject: [PATCH 095/137] Revise template --- src/registrar/admin.py | 7 ++-- src/registrar/assets/sass/_theme/_admin.scss | 12 +++++++ src/registrar/tests/test_admin.py | 38 +++++++++++++------- 3 files changed, 41 insertions(+), 16 deletions(-) diff --git a/src/registrar/admin.py b/src/registrar/admin.py index a7a6be08d..0e9849370 100644 --- a/src/registrar/admin.py +++ b/src/registrar/admin.py @@ -490,14 +490,15 @@ class ContactAdmin(ListHeaderAdmin): related_objects.append((change_url, obj)) if related_objects: - message = "" + message = "
                          " for i, (url, obj) in enumerate(related_objects): if i < 5: escaped_obj = escape(obj) - message += f"Joined to {obj.__class__.__name__}: {escaped_obj}
                          " + message += f"
                        • Joined to {obj.__class__.__name__}: {escaped_obj}
                        • " + message += "
                        " if len(related_objects) > 5: related_objects_over_five = len(related_objects) - 5 - message += f"And {related_objects_over_five} more..." + message += f"

                        And {related_objects_over_five} more...

                        " message_html = mark_safe(message) # nosec messages.warning( diff --git a/src/registrar/assets/sass/_theme/_admin.scss b/src/registrar/assets/sass/_theme/_admin.scss index a3d631243..6d9ab550f 100644 --- a/src/registrar/assets/sass/_theme/_admin.scss +++ b/src/registrar/assets/sass/_theme/_admin.scss @@ -258,3 +258,15 @@ h1, h2, h3, #select2-id_user-results { width: 100%; } + +// Content list inside of a DjA alert, unstyled +.messagelist_content-list--unstyled { + padding-left: 0; + li { + font-family: "Source Sans Pro Web", "Helvetica Neue", Helvetica, Roboto, Arial, sans-serif; + font-size: 13.92px!important; + background: none!important; + padding: 0!important; + margin: 0!important; + } +} diff --git a/src/registrar/tests/test_admin.py b/src/registrar/tests/test_admin.py index 43771a260..ebf3dfed9 100644 --- a/src/registrar/tests/test_admin.py +++ b/src/registrar/tests/test_admin.py @@ -1756,17 +1756,22 @@ class ContactAdminTest(TestCase): # Use the test client to simulate the request response = self.client.get(reverse("admin:registrar_contact_change", args=[contact.pk])) - logger.info(mock_warning) - # Assert that the error message was called with the correct argument # Note: The 5th join will be a user. mock_warning.assert_called_once_with( response.wsgi_request, - f"Joined to DomainApplication: city1.gov
                        " - f"Joined to DomainApplication: city2.gov
                        " - f"Joined to DomainApplication: city3.gov
                        " - f"Joined to DomainApplication: city4.gov
                        " - "Joined to User: staff@example.com
                        ", + "", ) def test_change_view_for_joined_contact_five_or_more(self): @@ -1794,12 +1799,19 @@ class ContactAdminTest(TestCase): # Note: The 6th join will be a user. mock_warning.assert_called_once_with( response.wsgi_request, - f"Joined to DomainApplication: city1.gov
                        " - f"Joined to DomainApplication: city2.gov
                        " - f"Joined to DomainApplication: city3.gov
                        " - f"Joined to DomainApplication: city4.gov
                        " - f"Joined to DomainApplication: city5.gov
                        " - "And 1 more...", + "" + "

                        And 1 more...

                        ", ) def tearDown(self): From d9610ae12dac880997837cc2656495203b1bab00 Mon Sep 17 00:00:00 2001 From: zandercymatics <141044360+zandercymatics@users.noreply.github.com> Date: Fri, 26 Jan 2024 12:13:09 -0700 Subject: [PATCH 096/137] UI changes --- src/registrar/assets/sass/_theme/_buttons.scss | 1 + src/registrar/templates/domain_users.html | 8 ++++---- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/registrar/assets/sass/_theme/_buttons.scss b/src/registrar/assets/sass/_theme/_buttons.scss index 0576f8b47..5148456e5 100644 --- a/src/registrar/assets/sass/_theme/_buttons.scss +++ b/src/registrar/assets/sass/_theme/_buttons.scss @@ -49,6 +49,7 @@ a.usa-button--unstyled.disabled-link:hover, a.usa-button--unstyled.disabled-link:focus { cursor: not-allowed !important; outline: none !important; + text-decoration: none !important; } a.usa-button:not(.usa-button--unstyled, .usa-button--outline) { diff --git a/src/registrar/templates/domain_users.html b/src/registrar/templates/domain_users.html index e22800677..b3d52bdd4 100644 --- a/src/registrar/templates/domain_users.html +++ b/src/registrar/templates/domain_users.html @@ -53,7 +53,7 @@ {# Display a custom message if the user is trying to delete themselves #} {% if permission.user.email == current_user_email %}
                        {% with domain_name=domain.name|force_escape %} - {% include 'includes/modal.html' with modal_heading="Are you sure you want to remove yourself as a domain manager for "|add:domain_name|add:"?"|safe modal_description="You will no longer be able to manage the domain "|add:domain_name|add:"."|safe modal_button=modal_button_self|safe %} + {% include 'includes/modal.html' with modal_heading="Are you sure you want to remove yourself as a domain manager?" modal_description="You will no longer be able to manage the domain "|add:domain_name|add:"."|safe modal_button=modal_button_self|safe %} {% endwith %}
                        {% else %}
                        {% with email=permission.user.email|default:permission.user|force_escape domain_name=domain.name|force_escape %} - {% include 'includes/modal.html' with modal_heading="Are you sure you want to remove <"|add:email|add:">?"|safe modal_description="<"|add:email|add:"> will no longer be able to manage the domain "|add:domain_name|add:"."|safe modal_button=modal_button|safe %} + {% include 'includes/modal.html' with modal_heading="Are you sure you want to remove " heading_value="<"|add:email|add:">?" modal_description="<"|add:email|add:"> will no longer be able to manage the domain "|add:domain_name|add:"."|safe modal_button=modal_button|safe %} {% endwith %}
                        From 17896d96fc3c2eb0215a4052fb957fcdf77af564 Mon Sep 17 00:00:00 2001 From: David Kennedy Date: Fri, 26 Jan 2024 15:16:15 -0500 Subject: [PATCH 097/137] changes to how other employees are displayed in 2 of the 3 scenarios --- src/registrar/templates/application_status.html | 2 +- .../templates/emails/includes/application_summary.txt | 10 ++++------ 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/src/registrar/templates/application_status.html b/src/registrar/templates/application_status.html index edbf86e7a..bb17dfcfa 100644 --- a/src/registrar/templates/application_status.html +++ b/src/registrar/templates/application_status.html @@ -114,7 +114,7 @@ {% if domainapplication.other_contacts.all %} {% include "includes/summary_item.html" with title='Other employees from your organization' value=domainapplication.other_contacts.all contact='true' list='true' heading_level=heading_level %} {% else %} - {% include "includes/summary_item.html" with title='No other employees from your organization?' value=domainapplication.no_other_contacts_rationale heading_level=heading_level %} + {% include "includes/summary_item.html" with title='Other employees from your organization' value=domainapplication.no_other_contacts_rationale heading_level=heading_level %} {% endif %} {% include "includes/summary_item.html" with title='Anything else?' value=domainapplication.anything_else|default:"No" heading_level=heading_level %} diff --git a/src/registrar/templates/emails/includes/application_summary.txt b/src/registrar/templates/emails/includes/application_summary.txt index efed65401..707689812 100644 --- a/src/registrar/templates/emails/includes/application_summary.txt +++ b/src/registrar/templates/emails/includes/application_summary.txt @@ -44,14 +44,12 @@ Purpose of your domain: Your contact information: {% spaceless %}{% include "emails/includes/contact.txt" with contact=application.submitter %}{% endspaceless %} -{% if application.other_contacts.all %} -Other employees from your organization: -{% for other in application.other_contacts.all %} + +Other employees from your organization:{% for other in application.other_contacts.all %} {% spaceless %}{% include "emails/includes/contact.txt" with contact=other %}{% endspaceless %} -{% endfor %}{% else %} -No other employees from your organization? +{% empty %} {{ application.no_other_contacts_rationale }} -{% endif %}{% if application.anything_else %} +{% endfor %}{% if application.anything_else %} Anything else? {{ application.anything_else }} {% endif %} \ No newline at end of file From 04c3d4c7112c45d5b9ea2f2354394188bc3413d1 Mon Sep 17 00:00:00 2001 From: David Kennedy Date: Fri, 26 Jan 2024 15:24:12 -0500 Subject: [PATCH 098/137] updated test to reflect change in how other employees are displayed in email --- src/registrar/tests/test_emails.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/registrar/tests/test_emails.py b/src/registrar/tests/test_emails.py index d21358402..0560cab33 100644 --- a/src/registrar/tests/test_emails.py +++ b/src/registrar/tests/test_emails.py @@ -104,7 +104,7 @@ class TestEmails(TestCase): body = kwargs["Content"]["Simple"]["Body"]["Text"]["Data"] self.assertNotIn("Other employees from your organization:", body) # spacing should be right between adjacent elements - self.assertRegex(body, r"5556\n\nNo other employees") + self.assertRegex(body, r"5556\n\nOther employees") self.assertRegex(body, r"None\n\nAnything else") @boto3_mocking.patching From dcfe19dc7cc7ef8f455918c0b8f5329c304fe58d Mon Sep 17 00:00:00 2001 From: Rachid Mrad Date: Fri, 26 Jan 2024 15:42:09 -0500 Subject: [PATCH 099/137] Add VIP table access to staff --- .../migrations/0065_create_groups_v06.py | 37 +++++++++++++++++++ src/registrar/models/user_group.py | 5 +++ src/registrar/tests/test_migrations.py | 3 ++ 3 files changed, 45 insertions(+) create mode 100644 src/registrar/migrations/0065_create_groups_v06.py diff --git a/src/registrar/migrations/0065_create_groups_v06.py b/src/registrar/migrations/0065_create_groups_v06.py new file mode 100644 index 000000000..d2cb32cee --- /dev/null +++ b/src/registrar/migrations/0065_create_groups_v06.py @@ -0,0 +1,37 @@ +# This migration creates the create_full_access_group and create_cisa_analyst_group groups +# It is dependent on 0035 (which populates ContentType and Permissions) +# If permissions on the groups need changing, edit CISA_ANALYST_GROUP_PERMISSIONS +# in the user_group model then: +# [NOT RECOMMENDED] +# step 1: docker-compose exec app ./manage.py migrate --fake registrar 0035_contenttypes_permissions +# step 2: docker-compose exec app ./manage.py migrate registrar 0036_create_groups +# step 3: fake run the latest migration in the migrations list +# [RECOMMENDED] +# Alternatively: +# step 1: duplicate the migration that loads data +# step 2: docker-compose exec app ./manage.py migrate + +from django.db import migrations +from registrar.models import UserGroup +from typing import Any + + +# For linting: RunPython expects a function reference, +# so let's give it one +def create_groups(apps, schema_editor) -> Any: + UserGroup.create_cisa_analyst_group(apps, schema_editor) + UserGroup.create_full_access_group(apps, schema_editor) + + +class Migration(migrations.Migration): + dependencies = [ + ("registrar", "0064_alter_domainapplication_address_line1_and_more"), + ] + + operations = [ + migrations.RunPython( + create_groups, + reverse_code=migrations.RunPython.noop, + atomic=True, + ), + ] diff --git a/src/registrar/models/user_group.py b/src/registrar/models/user_group.py index a733239c7..2658ec52d 100644 --- a/src/registrar/models/user_group.py +++ b/src/registrar/models/user_group.py @@ -66,6 +66,11 @@ class UserGroup(Group): "model": "userdomainrole", "permissions": ["view_userdomainrole", "delete_userdomainrole"], }, + { + "app_label": "registrar", + "model": "veryimportantperson", + "permissions": ["add_veryimportantperson", "change_veryimportantperson", "delete_veryimportantperson"], + }, ] # Avoid error: You can't execute queries until the end diff --git a/src/registrar/tests/test_migrations.py b/src/registrar/tests/test_migrations.py index cc9d379e5..cf28aa81a 100644 --- a/src/registrar/tests/test_migrations.py +++ b/src/registrar/tests/test_migrations.py @@ -43,6 +43,9 @@ class TestGroups(TestCase): "change_user", "delete_userdomainrole", "view_userdomainrole", + "add_veryimportantperson", + "change_veryimportantperson", + "delete_veryimportantperson", "change_website", ] From e2537d6890fb7cca0c044da08834cedf85a49d7e Mon Sep 17 00:00:00 2001 From: David Kennedy Date: Fri, 26 Jan 2024 15:47:04 -0500 Subject: [PATCH 100/137] updated org name and address when no federal agency --- src/registrar/templates/includes/organization_address.html | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/registrar/templates/includes/organization_address.html b/src/registrar/templates/includes/organization_address.html index d0c62d685..c0baf3c9f 100644 --- a/src/registrar/templates/includes/organization_address.html +++ b/src/registrar/templates/includes/organization_address.html @@ -1,9 +1,9 @@
                        {% if organization.federal_agency %} - {{ organization.federal_agency }} + {{ organization.federal_agency }}
                        {% endif %} {% if organization.organization_name %} -
                        {{ organization.organization_name }} + {{ organization.organization_name }} {% endif %} {% if organization.address_line1 %}
                        {{ organization.address_line1 }} From 8a37f432c4f5855fdef55abbc6c1aef1cba0512c Mon Sep 17 00:00:00 2001 From: David Kennedy Date: Fri, 26 Jan 2024 15:59:44 -0500 Subject: [PATCH 101/137] updated test --- src/registrar/tests/test_emails.py | 1 - 1 file changed, 1 deletion(-) diff --git a/src/registrar/tests/test_emails.py b/src/registrar/tests/test_emails.py index 0560cab33..f2a94a186 100644 --- a/src/registrar/tests/test_emails.py +++ b/src/registrar/tests/test_emails.py @@ -102,7 +102,6 @@ class TestEmails(TestCase): application.submit() _, kwargs = self.mock_client.send_email.call_args body = kwargs["Content"]["Simple"]["Body"]["Text"]["Data"] - self.assertNotIn("Other employees from your organization:", body) # spacing should be right between adjacent elements self.assertRegex(body, r"5556\n\nOther employees") self.assertRegex(body, r"None\n\nAnything else") From 8b6d2ea2c76b5322d279df95845ff08493fa987f Mon Sep 17 00:00:00 2001 From: zandercymatics <141044360+zandercymatics@users.noreply.github.com> Date: Fri, 26 Jan 2024 15:02:52 -0700 Subject: [PATCH 102/137] Add back id --- src/registrar/assets/js/get-gov.js | 11 ++++------- .../templates/application_dotgov_domain.html | 2 +- 2 files changed, 5 insertions(+), 8 deletions(-) diff --git a/src/registrar/assets/js/get-gov.js b/src/registrar/assets/js/get-gov.js index 4a1ce005f..375b9738f 100644 --- a/src/registrar/assets/js/get-gov.js +++ b/src/registrar/assets/js/get-gov.js @@ -245,13 +245,10 @@ function handleValidationClick(e) { const alternateDomainsInputs = document.querySelectorAll('[auto-validate]'); if (alternateDomainsInputs) { for (const domainInput of alternateDomainsInputs){ - // Only apply this logic to alternate domains input - if (domainInput.classList.contains('alternate-domain-input')){ - domainInput.addEventListener('input', function() { - removeFormErrors(domainInput, true); - } - ); - } + domainInput.addEventListener('input', function() { + removeFormErrors(domainInput, true); + } + ); } } })(); diff --git a/src/registrar/templates/application_dotgov_domain.html b/src/registrar/templates/application_dotgov_domain.html index bd3c4a473..223fa8179 100644 --- a/src/registrar/templates/application_dotgov_domain.html +++ b/src/registrar/templates/application_dotgov_domain.html @@ -79,7 +79,7 @@ {% endwith %} {% endwith %} - ' ) context["modal_button"] = modal_button # Create HTML for the modal button when deleting yourself - modal_button_self = self._create_modal_button_html( - button_name="delete_domain_manager_self", - button_text_content="Yes, remove myself", - classes=["usa-button", "usa-button--secondary"], + modal_button_self = ( + '' ) context["modal_button_self"] = modal_button_self return context - def _create_modal_button_html(self, button_name: str, button_text_content: str, classes: List[str] | str): - """Template for modal submit buttons""" - - if isinstance(classes, list): - class_list = " ".join(classes) - elif isinstance(classes, str): - class_list = classes - - html_class = f'class="{class_list}"' if class_list else None - modal_button = '' - return modal_button - class DomainAddUserView(DomainFormBaseView): """Inside of a domain's user management, a form for adding users. diff --git a/src/registrar/views/utility/mixins.py b/src/registrar/views/utility/mixins.py index 980c0dad5..b2c4cb364 100644 --- a/src/registrar/views/utility/mixins.py +++ b/src/registrar/views/utility/mixins.py @@ -286,7 +286,7 @@ class DomainApplicationPermission(PermissionsLoginMixin): return True -class UserDomainRolePermission(PermissionsLoginMixin): +class UserDeleteDomainRolePermission(PermissionsLoginMixin): """Permission mixin for UserDomainRole if user has access, otherwise 403""" diff --git a/src/registrar/views/utility/permission_views.py b/src/registrar/views/utility/permission_views.py index a274db0d9..54c96d602 100644 --- a/src/registrar/views/utility/permission_views.py +++ b/src/registrar/views/utility/permission_views.py @@ -12,7 +12,7 @@ from .mixins import ( DomainApplicationPermissionWithdraw, DomainInvitationPermission, ApplicationWizardPermission, - UserDomainRolePermission, + UserDeleteDomainRolePermission, ) import logging @@ -134,21 +134,7 @@ class DomainApplicationPermissionDeleteView(DomainApplicationPermission, DeleteV object: DomainApplication -class UserDomainRolePermissionView(UserDomainRolePermission, DetailView, abc.ABC): - - """Abstract base view for UserDomainRole that enforces permissions. - - This abstract view cannot be instantiated. Actual views must specify - `template_name`. - """ - - # DetailView property for what model this is viewing - model = UserDomainRole - # variable name in template context for the model object - context_object_name = "userdomainrole" - - -class UserDomainRolePermissionDeleteView(UserDomainRolePermissionView, DeleteView, abc.ABC): +class UserDomainRolePermissionDeleteView(UserDeleteDomainRolePermission, DeleteView, abc.ABC): """Abstract base view for deleting a UserDomainRole. From 619cadb953820ec03d0f5a43f1e2399dde8be08f Mon Sep 17 00:00:00 2001 From: zandercymatics <141044360+zandercymatics@users.noreply.github.com> Date: Mon, 29 Jan 2024 10:52:38 -0700 Subject: [PATCH 107/137] Grab sec emails from dict --- src/registrar/utility/csv_export.py | 26 +++++++++++++++++++++----- 1 file changed, 21 insertions(+), 5 deletions(-) diff --git a/src/registrar/utility/csv_export.py b/src/registrar/utility/csv_export.py index 68dc126db..d87f97ad7 100644 --- a/src/registrar/utility/csv_export.py +++ b/src/registrar/utility/csv_export.py @@ -41,7 +41,7 @@ def get_domain_infos(filter_condition, sort_fields): return domain_infos_cleaned -def parse_row(columns, domain_info: DomainInformation, skip_epp_call=True): +def parse_row(columns, domain_info: DomainInformation, security_emails_dict=None, skip_epp_call=True): """Given a set of columns, generate a new row from cleaned column data""" # Domain should never be none when parsing this information @@ -50,11 +50,17 @@ def parse_row(columns, domain_info: DomainInformation, skip_epp_call=True): domain = domain_info.domain # type: ignore - cached_sec_email = domain.get_security_email(skip_epp_call) - security_email = cached_sec_email if cached_sec_email is not None else " " + # Grab the security email from a preset dictionary. + # If nothing exists in the dictionary, grab from get_security_email + if security_emails_dict is not None and domain.name in security_emails_dict: + _email = security_emails_dict.get(domain.name) + security_email = _email if _email is not None else " " + else: + cached_sec_email = domain.get_security_email(skip_epp_call) + security_email = cached_sec_email if cached_sec_email is not None else " " - invalid_emails = {"registrar@dotgov.gov", "dotgov@cisa.dhs.gov"} # These are default emails that should not be displayed in the csv report + invalid_emails = {"registrar@dotgov.gov", "dotgov@cisa.dhs.gov"} if security_email.lower() in invalid_emails: security_email = "(blank)" @@ -98,6 +104,16 @@ def write_body( # Get the domainInfos all_domain_infos = get_domain_infos(filter_condition, sort_fields) + + # Populate a dictionary of domain names and their security contacts + security_emails_dict = {} + for domain_info in all_domain_infos: + if domain_info not in security_emails_dict: + domain: Domain = domain_info.domain + if domain is not None: + security_emails_dict[domain.name] = domain.security_contact_registry_id + else: + logger.warning("csv_export -> Duplicate domain object found") # Reduce the memory overhead when performing the write operation paginator = Paginator(all_domain_infos, 1000) @@ -106,7 +122,7 @@ def write_body( rows = [] for domain_info in page.object_list: try: - row = parse_row(columns, domain_info) + row = parse_row(columns, domain_info, security_emails_dict) rows.append(row) except ValueError: # This should not happen. If it does, just skip this row. From e420db52f22ad6006583e6a7dadc91e2ab4323f4 Mon Sep 17 00:00:00 2001 From: zandercymatics <141044360+zandercymatics@users.noreply.github.com> Date: Mon, 29 Jan 2024 11:07:37 -0700 Subject: [PATCH 108/137] Revert "Grab sec emails from dict" This reverts commit 619cadb953820ec03d0f5a43f1e2399dde8be08f. --- src/registrar/utility/csv_export.py | 26 +++++--------------------- 1 file changed, 5 insertions(+), 21 deletions(-) diff --git a/src/registrar/utility/csv_export.py b/src/registrar/utility/csv_export.py index d87f97ad7..68dc126db 100644 --- a/src/registrar/utility/csv_export.py +++ b/src/registrar/utility/csv_export.py @@ -41,7 +41,7 @@ def get_domain_infos(filter_condition, sort_fields): return domain_infos_cleaned -def parse_row(columns, domain_info: DomainInformation, security_emails_dict=None, skip_epp_call=True): +def parse_row(columns, domain_info: DomainInformation, skip_epp_call=True): """Given a set of columns, generate a new row from cleaned column data""" # Domain should never be none when parsing this information @@ -50,17 +50,11 @@ def parse_row(columns, domain_info: DomainInformation, security_emails_dict=None domain = domain_info.domain # type: ignore - # Grab the security email from a preset dictionary. - # If nothing exists in the dictionary, grab from get_security_email - if security_emails_dict is not None and domain.name in security_emails_dict: - _email = security_emails_dict.get(domain.name) - security_email = _email if _email is not None else " " - else: - cached_sec_email = domain.get_security_email(skip_epp_call) - security_email = cached_sec_email if cached_sec_email is not None else " " + cached_sec_email = domain.get_security_email(skip_epp_call) + security_email = cached_sec_email if cached_sec_email is not None else " " - # These are default emails that should not be displayed in the csv report invalid_emails = {"registrar@dotgov.gov", "dotgov@cisa.dhs.gov"} + # These are default emails that should not be displayed in the csv report if security_email.lower() in invalid_emails: security_email = "(blank)" @@ -104,16 +98,6 @@ def write_body( # Get the domainInfos all_domain_infos = get_domain_infos(filter_condition, sort_fields) - - # Populate a dictionary of domain names and their security contacts - security_emails_dict = {} - for domain_info in all_domain_infos: - if domain_info not in security_emails_dict: - domain: Domain = domain_info.domain - if domain is not None: - security_emails_dict[domain.name] = domain.security_contact_registry_id - else: - logger.warning("csv_export -> Duplicate domain object found") # Reduce the memory overhead when performing the write operation paginator = Paginator(all_domain_infos, 1000) @@ -122,7 +106,7 @@ def write_body( rows = [] for domain_info in page.object_list: try: - row = parse_row(columns, domain_info, security_emails_dict) + row = parse_row(columns, domain_info) rows.append(row) except ValueError: # This should not happen. If it does, just skip this row. From 148ccbdf2a907270ddaa1933e0547b33312499c3 Mon Sep 17 00:00:00 2001 From: zandercymatics <141044360+zandercymatics@users.noreply.github.com> Date: Mon, 29 Jan 2024 12:18:47 -0700 Subject: [PATCH 109/137] Revert "Revert "Grab sec emails from dict"" This reverts commit e420db52f22ad6006583e6a7dadc91e2ab4323f4. --- src/registrar/utility/csv_export.py | 26 +++++++++++++++++++++----- 1 file changed, 21 insertions(+), 5 deletions(-) diff --git a/src/registrar/utility/csv_export.py b/src/registrar/utility/csv_export.py index 68dc126db..d87f97ad7 100644 --- a/src/registrar/utility/csv_export.py +++ b/src/registrar/utility/csv_export.py @@ -41,7 +41,7 @@ def get_domain_infos(filter_condition, sort_fields): return domain_infos_cleaned -def parse_row(columns, domain_info: DomainInformation, skip_epp_call=True): +def parse_row(columns, domain_info: DomainInformation, security_emails_dict=None, skip_epp_call=True): """Given a set of columns, generate a new row from cleaned column data""" # Domain should never be none when parsing this information @@ -50,11 +50,17 @@ def parse_row(columns, domain_info: DomainInformation, skip_epp_call=True): domain = domain_info.domain # type: ignore - cached_sec_email = domain.get_security_email(skip_epp_call) - security_email = cached_sec_email if cached_sec_email is not None else " " + # Grab the security email from a preset dictionary. + # If nothing exists in the dictionary, grab from get_security_email + if security_emails_dict is not None and domain.name in security_emails_dict: + _email = security_emails_dict.get(domain.name) + security_email = _email if _email is not None else " " + else: + cached_sec_email = domain.get_security_email(skip_epp_call) + security_email = cached_sec_email if cached_sec_email is not None else " " - invalid_emails = {"registrar@dotgov.gov", "dotgov@cisa.dhs.gov"} # These are default emails that should not be displayed in the csv report + invalid_emails = {"registrar@dotgov.gov", "dotgov@cisa.dhs.gov"} if security_email.lower() in invalid_emails: security_email = "(blank)" @@ -98,6 +104,16 @@ def write_body( # Get the domainInfos all_domain_infos = get_domain_infos(filter_condition, sort_fields) + + # Populate a dictionary of domain names and their security contacts + security_emails_dict = {} + for domain_info in all_domain_infos: + if domain_info not in security_emails_dict: + domain: Domain = domain_info.domain + if domain is not None: + security_emails_dict[domain.name] = domain.security_contact_registry_id + else: + logger.warning("csv_export -> Duplicate domain object found") # Reduce the memory overhead when performing the write operation paginator = Paginator(all_domain_infos, 1000) @@ -106,7 +122,7 @@ def write_body( rows = [] for domain_info in page.object_list: try: - row = parse_row(columns, domain_info) + row = parse_row(columns, domain_info, security_emails_dict) rows.append(row) except ValueError: # This should not happen. If it does, just skip this row. From 75e687f13b7feccd3c360ca183cb814ab1f69f95 Mon Sep 17 00:00:00 2001 From: zandercymatics <141044360+zandercymatics@users.noreply.github.com> Date: Mon, 29 Jan 2024 12:38:56 -0700 Subject: [PATCH 110/137] Remove skip epp call, use dict instead --- src/registrar/models/domain.py | 22 +++++++------------- src/registrar/utility/csv_export.py | 32 ++++++++++++++++++----------- 2 files changed, 27 insertions(+), 27 deletions(-) diff --git a/src/registrar/models/domain.py b/src/registrar/models/domain.py index 0cbe8c071..27a8364bc 100644 --- a/src/registrar/models/domain.py +++ b/src/registrar/models/domain.py @@ -909,17 +909,11 @@ class Domain(TimeStampedModel, DomainHelper): """Time to renew. Not implemented.""" raise NotImplementedError() - def get_security_email(self, skip_epp_call=False): + def get_security_email(self): logger.info("get_security_email-> getting the contact") - # If specified, skip the epp call outright. - # Otherwise, proceed as normal. - if skip_epp_call: - logger.info("get_security_email-> skipping epp call") - security = PublicContact.ContactTypeChoices.SECURITY - security_contact = self.generic_contact_getter(security, skip_epp_call) - else: - security_contact = self.security_contact + security = PublicContact.ContactTypeChoices.SECURITY + security_contact = self.generic_contact_getter(security) # If we get a valid value for security_contact, pull its email # Otherwise, just return nothing @@ -1121,9 +1115,7 @@ class Domain(TimeStampedModel, DomainHelper): ) raise error - def generic_contact_getter( - self, contact_type_choice: PublicContact.ContactTypeChoices, skip_epp_call=False - ) -> PublicContact | None: + def generic_contact_getter(self, contact_type_choice: PublicContact.ContactTypeChoices) -> PublicContact | None: """Retrieves the desired PublicContact from the registry. This abstracts the caching and EPP retrieval for all contact items and thus may result in EPP calls being sent. @@ -1143,7 +1135,7 @@ class Domain(TimeStampedModel, DomainHelper): try: # Grab from cache - contacts = self._get_property(desired_property, skip_epp_call) + contacts = self._get_property(desired_property) except KeyError as error: # if contact type is security, attempt to retrieve registry id # for the security contact from domain.security_contact_registry_id @@ -1878,9 +1870,9 @@ class Domain(TimeStampedModel, DomainHelper): """Remove cache data when updates are made.""" self._cache = {} - def _get_property(self, property, skip_epp_call=False): + def _get_property(self, property): """Get some piece of info about a domain.""" - if property not in self._cache and not skip_epp_call: + if property not in self._cache: self._fetch_cache( fetch_hosts=(property == "hosts"), fetch_contacts=(property == "contacts"), diff --git a/src/registrar/utility/csv_export.py b/src/registrar/utility/csv_export.py index d87f97ad7..e2e31bc0f 100644 --- a/src/registrar/utility/csv_export.py +++ b/src/registrar/utility/csv_export.py @@ -8,6 +8,8 @@ from django.core.paginator import Paginator from django.db.models import F, Value, CharField from django.db.models.functions import Concat, Coalesce +from registrar.models.public_contact import PublicContact + logger = logging.getLogger(__name__) @@ -41,7 +43,7 @@ def get_domain_infos(filter_condition, sort_fields): return domain_infos_cleaned -def parse_row(columns, domain_info: DomainInformation, security_emails_dict=None, skip_epp_call=True): +def parse_row(columns, domain_info: DomainInformation, security_emails_dict=None): """Given a set of columns, generate a new row from cleaned column data""" # Domain should never be none when parsing this information @@ -51,13 +53,16 @@ def parse_row(columns, domain_info: DomainInformation, security_emails_dict=None domain = domain_info.domain # type: ignore # Grab the security email from a preset dictionary. - # If nothing exists in the dictionary, grab from get_security_email + # If nothing exists in the dictionary, grab from .contacts. if security_emails_dict is not None and domain.name in security_emails_dict: _email = security_emails_dict.get(domain.name) security_email = _email if _email is not None else " " else: - cached_sec_email = domain.get_security_email(skip_epp_call) - security_email = cached_sec_email if cached_sec_email is not None else " " + # If the dictionary doesn't contain that data, lets filter for it manually. + # This is a last resort as this is a more expensive operation. + security_contacts = domain_info.domain.contacts.filter(contact_type=PublicContact.ContactTypeChoices.SECURITY) + _email = security_contacts[0].email + security_email = _email if _email is not None else " " # These are default emails that should not be displayed in the csv report invalid_emails = {"registrar@dotgov.gov", "dotgov@cisa.dhs.gov"} @@ -104,16 +109,19 @@ def write_body( # Get the domainInfos all_domain_infos = get_domain_infos(filter_condition, sort_fields) - - # Populate a dictionary of domain names and their security contacts + + # Store all security emails to avoid epp calls or excessive filters + sec_contact_ids = list(all_domain_infos.values_list("domain__security_contact_registry_id", flat=True)) security_emails_dict = {} - for domain_info in all_domain_infos: - if domain_info not in security_emails_dict: - domain: Domain = domain_info.domain - if domain is not None: - security_emails_dict[domain.name] = domain.security_contact_registry_id + public_contacts = PublicContact.objects.filter(registry_id__in=sec_contact_ids) + + # Populate a dictionary of domain names and their security contacts + for contact in public_contacts: + domain: Domain = domain_info.domain + if domain is not None and domain.name not in security_emails_dict: + security_emails_dict[domain.name] = contact.email else: - logger.warning("csv_export -> Duplicate domain object found") + logger.warning("csv_export -> Domain was none for PublicContact") # Reduce the memory overhead when performing the write operation paginator = Paginator(all_domain_infos, 1000) From acbef25ec18effcd71eb8787e306c6849917ff83 Mon Sep 17 00:00:00 2001 From: zandercymatics <141044360+zandercymatics@users.noreply.github.com> Date: Mon, 29 Jan 2024 12:54:56 -0700 Subject: [PATCH 111/137] Bug fix --- src/registrar/utility/csv_export.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/registrar/utility/csv_export.py b/src/registrar/utility/csv_export.py index e2e31bc0f..4d9bd6869 100644 --- a/src/registrar/utility/csv_export.py +++ b/src/registrar/utility/csv_export.py @@ -60,9 +60,10 @@ def parse_row(columns, domain_info: DomainInformation, security_emails_dict=None else: # If the dictionary doesn't contain that data, lets filter for it manually. # This is a last resort as this is a more expensive operation. - security_contacts = domain_info.domain.contacts.filter(contact_type=PublicContact.ContactTypeChoices.SECURITY) - _email = security_contacts[0].email + security_contacts = domain.contacts.filter(contact_type=PublicContact.ContactTypeChoices.SECURITY) + _email = security_contacts[0].email if security_contacts else None security_email = _email if _email is not None else " " + print("in else statement....") # These are default emails that should not be displayed in the csv report invalid_emails = {"registrar@dotgov.gov", "dotgov@cisa.dhs.gov"} @@ -117,7 +118,7 @@ def write_body( # Populate a dictionary of domain names and their security contacts for contact in public_contacts: - domain: Domain = domain_info.domain + domain: Domain = contact.domain if domain is not None and domain.name not in security_emails_dict: security_emails_dict[domain.name] = contact.email else: From d8d7f6381935ba7706e9de05a2c3da83f497ec40 Mon Sep 17 00:00:00 2001 From: zandercymatics <141044360+zandercymatics@users.noreply.github.com> Date: Mon, 29 Jan 2024 14:00:41 -0700 Subject: [PATCH 112/137] Fix typo in unit test --- src/registrar/tests/test_views.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/registrar/tests/test_views.py b/src/registrar/tests/test_views.py index ffe94199c..3bbcfcf01 100644 --- a/src/registrar/tests/test_views.py +++ b/src/registrar/tests/test_views.py @@ -2781,7 +2781,7 @@ class TestDomainManagers(TestDomainOverview): self.assertTrue(role_2_exists) # Make sure that the current user wasn't deleted for some reason - current_user_exists = UserDomainRole.objects.filter(user=self.user.id, domain=self.domain).exists() + current_user_exists = UserDomainRole.objects.filter(user=dummy_user_1.id, domain=vip_domain.id).exists() self.assertTrue(current_user_exists) def test_domain_user_delete_denied_if_last_man_standing(self): @@ -2810,7 +2810,7 @@ class TestDomainManagers(TestDomainOverview): self.assertEqual(response.status_code, 403) # Make sure that the current user wasn't deleted - current_user_exists = UserDomainRole.objects.filter(user=self.user.id, domain=self.domain).exists() + current_user_exists = UserDomainRole.objects.filter(user=self.user.id, domain=vip_domain.id).exists() self.assertTrue(current_user_exists) def test_domain_user_delete_self_redirects_home(self): From 11542c9ca0353e7c7bef2e4df248f11970662c4b Mon Sep 17 00:00:00 2001 From: zandercymatics <141044360+zandercymatics@users.noreply.github.com> Date: Mon, 29 Jan 2024 15:18:22 -0700 Subject: [PATCH 113/137] Minor performance enhancement --- src/registrar/utility/csv_export.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/registrar/utility/csv_export.py b/src/registrar/utility/csv_export.py index 4d9bd6869..29fc2fc54 100644 --- a/src/registrar/utility/csv_export.py +++ b/src/registrar/utility/csv_export.py @@ -63,7 +63,6 @@ def parse_row(columns, domain_info: DomainInformation, security_emails_dict=None security_contacts = domain.contacts.filter(contact_type=PublicContact.ContactTypeChoices.SECURITY) _email = security_contacts[0].email if security_contacts else None security_email = _email if _email is not None else " " - print("in else statement....") # These are default emails that should not be displayed in the csv report invalid_emails = {"registrar@dotgov.gov", "dotgov@cisa.dhs.gov"} @@ -112,9 +111,9 @@ def write_body( all_domain_infos = get_domain_infos(filter_condition, sort_fields) # Store all security emails to avoid epp calls or excessive filters - sec_contact_ids = list(all_domain_infos.values_list("domain__security_contact_registry_id", flat=True)) + sec_contact_ids = all_domain_infos.values_list("domain__security_contact_registry_id", flat=True) security_emails_dict = {} - public_contacts = PublicContact.objects.filter(registry_id__in=sec_contact_ids) + public_contacts = PublicContact.objects.only('email', 'domain__name').select_related("domain").filter(registry_id__in=sec_contact_ids) # Populate a dictionary of domain names and their security contacts for contact in public_contacts: From d2a8ab16c8804aa4718ae85fa690657138abd8db Mon Sep 17 00:00:00 2001 From: zandercymatics <141044360+zandercymatics@users.noreply.github.com> Date: Mon, 29 Jan 2024 15:21:44 -0700 Subject: [PATCH 114/137] Linting --- src/registrar/utility/csv_export.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/registrar/utility/csv_export.py b/src/registrar/utility/csv_export.py index 29fc2fc54..f9608f553 100644 --- a/src/registrar/utility/csv_export.py +++ b/src/registrar/utility/csv_export.py @@ -52,7 +52,7 @@ def parse_row(columns, domain_info: DomainInformation, security_emails_dict=None domain = domain_info.domain # type: ignore - # Grab the security email from a preset dictionary. + # Grab the security email from a preset dictionary. # If nothing exists in the dictionary, grab from .contacts. if security_emails_dict is not None and domain.name in security_emails_dict: _email = security_emails_dict.get(domain.name) @@ -113,7 +113,11 @@ def write_body( # Store all security emails to avoid epp calls or excessive filters sec_contact_ids = all_domain_infos.values_list("domain__security_contact_registry_id", flat=True) security_emails_dict = {} - public_contacts = PublicContact.objects.only('email', 'domain__name').select_related("domain").filter(registry_id__in=sec_contact_ids) + public_contacts = ( + PublicContact.objects.only("email", "domain__name") + .select_related("domain") + .filter(registry_id__in=sec_contact_ids) + ) # Populate a dictionary of domain names and their security contacts for contact in public_contacts: From 07bcff952273fcae9bd45c204e3a5c0b3465a005 Mon Sep 17 00:00:00 2001 From: zandercymatics <141044360+zandercymatics@users.noreply.github.com> Date: Mon, 29 Jan 2024 15:22:35 -0700 Subject: [PATCH 115/137] Linting 2 --- .../utility/extra_transition_domain_helper.py | 22 +++++++++---------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/src/registrar/management/commands/utility/extra_transition_domain_helper.py b/src/registrar/management/commands/utility/extra_transition_domain_helper.py index 926dc4553..c082552eb 100644 --- a/src/registrar/management/commands/utility/extra_transition_domain_helper.py +++ b/src/registrar/management/commands/utility/extra_transition_domain_helper.py @@ -196,18 +196,18 @@ class LoadExtraTransitionDomain: f"{TerminalColors.ENDC}" ) failed_transition_domains.append(domain_name) - + updated_fields = [ - "organization_name", - "organization_type", - "federal_type", - "federal_agency", - "first_name", - "middle_name", - "last_name", - "email", - "phone", - "epp_creation_date", + "organization_name", + "organization_type", + "federal_type", + "federal_agency", + "first_name", + "middle_name", + "last_name", + "email", + "phone", + "epp_creation_date", "epp_expiration_date", ] From cca111bdec9ea0294d0072920fa58ec508125304 Mon Sep 17 00:00:00 2001 From: Alysia Broddrick Date: Mon, 29 Jan 2024 14:39:26 -0800 Subject: [PATCH 116/137] change very import person to verfied by staff --- src/registrar/admin.py | 2 +- ...mportantperson_verifiedbystaff_and_more.py | 20 ++++++++++ .../migrations/0067_create_groups_v07.py | 37 +++++++++++++++++++ src/registrar/models/__init__.py | 6 +-- src/registrar/models/user.py | 4 +- src/registrar/models/user_group.py | 4 +- ...portant_person.py => verified_by_staff.py} | 6 ++- src/registrar/tests/test_admin.py | 2 +- src/registrar/tests/test_models.py | 2 +- 9 files changed, 71 insertions(+), 12 deletions(-) create mode 100644 src/registrar/migrations/0066_rename_veryimportantperson_verifiedbystaff_and_more.py create mode 100644 src/registrar/migrations/0067_create_groups_v07.py rename src/registrar/models/{very_important_person.py => verified_by_staff.py} (84%) diff --git a/src/registrar/admin.py b/src/registrar/admin.py index 0e9849370..b8e08284f 100644 --- a/src/registrar/admin.py +++ b/src/registrar/admin.py @@ -1338,4 +1338,4 @@ admin.site.register(models.Website, WebsiteAdmin) admin.site.register(models.PublicContact, AuditedAdmin) admin.site.register(models.DomainApplication, DomainApplicationAdmin) admin.site.register(models.TransitionDomain, TransitionDomainAdmin) -admin.site.register(models.VeryImportantPerson, VeryImportantPersonAdmin) +admin.site.register(models.VerifiedByStaff, VeryImportantPersonAdmin) diff --git a/src/registrar/migrations/0066_rename_veryimportantperson_verifiedbystaff_and_more.py b/src/registrar/migrations/0066_rename_veryimportantperson_verifiedbystaff_and_more.py new file mode 100644 index 000000000..d167334a0 --- /dev/null +++ b/src/registrar/migrations/0066_rename_veryimportantperson_verifiedbystaff_and_more.py @@ -0,0 +1,20 @@ +# Generated by Django 4.2.7 on 2024-01-29 22:21 + +from django.db import migrations + + +class Migration(migrations.Migration): + dependencies = [ + ("registrar", "0065_create_groups_v06"), + ] + + operations = [ + migrations.RenameModel( + old_name="VeryImportantPerson", + new_name="VerifiedByStaff", + ), + migrations.AlterModelOptions( + name="verifiedbystaff", + options={"verbose_name_plural": "Verified by staff"}, + ), + ] diff --git a/src/registrar/migrations/0067_create_groups_v07.py b/src/registrar/migrations/0067_create_groups_v07.py new file mode 100644 index 000000000..b6fbd3e5c --- /dev/null +++ b/src/registrar/migrations/0067_create_groups_v07.py @@ -0,0 +1,37 @@ +# This migration creates the create_full_access_group and create_cisa_analyst_group groups +# It is dependent on 0035 (which populates ContentType and Permissions) +# If permissions on the groups need changing, edit CISA_ANALYST_GROUP_PERMISSIONS +# in the user_group model then: +# [NOT RECOMMENDED] +# step 1: docker-compose exec app ./manage.py migrate --fake registrar 0035_contenttypes_permissions +# step 2: docker-compose exec app ./manage.py migrate registrar 0036_create_groups +# step 3: fake run the latest migration in the migrations list +# [RECOMMENDED] +# Alternatively: +# step 1: duplicate the migration that loads data +# step 2: docker-compose exec app ./manage.py migrate + +from django.db import migrations +from registrar.models import UserGroup +from typing import Any + + +# For linting: RunPython expects a function reference, +# so let's give it one +def create_groups(apps, schema_editor) -> Any: + UserGroup.create_cisa_analyst_group(apps, schema_editor) + UserGroup.create_full_access_group(apps, schema_editor) + + +class Migration(migrations.Migration): + dependencies = [ + ("registrar", "0066_rename_veryimportperson_verifiedbystaff_and_more"), + ] + + operations = [ + migrations.RunPython( + create_groups, + reverse_code=migrations.RunPython.noop, + atomic=True, + ), + ] diff --git a/src/registrar/models/__init__.py b/src/registrar/models/__init__.py index 90cb2e286..d9ccd64cb 100644 --- a/src/registrar/models/__init__.py +++ b/src/registrar/models/__init__.py @@ -13,7 +13,7 @@ from .user import User from .user_group import UserGroup from .website import Website from .transition_domain import TransitionDomain -from .very_important_person import VeryImportantPerson +from .verified_by_staff import VerifiedByStaff __all__ = [ "Contact", @@ -30,7 +30,7 @@ __all__ = [ "UserGroup", "Website", "TransitionDomain", - "VeryImportantPerson", + "VerifiedByStaff", ] auditlog.register(Contact) @@ -47,4 +47,4 @@ auditlog.register(User, m2m_fields=["user_permissions", "groups"]) auditlog.register(UserGroup, m2m_fields=["permissions"]) auditlog.register(Website) auditlog.register(TransitionDomain) -auditlog.register(VeryImportantPerson) +auditlog.register(VerifiedByStaff) diff --git a/src/registrar/models/user.py b/src/registrar/models/user.py index 269569bfe..bf904a044 100644 --- a/src/registrar/models/user.py +++ b/src/registrar/models/user.py @@ -7,7 +7,7 @@ from registrar.models.user_domain_role import UserDomainRole from .domain_invitation import DomainInvitation from .transition_domain import TransitionDomain -from .very_important_person import VeryImportantPerson +from .verified_by_staff import VerifiedByStaff from .domain import Domain from phonenumber_field.modelfields import PhoneNumberField # type: ignore @@ -91,7 +91,7 @@ class User(AbstractUser): return False # New users flagged by Staff to bypass ial2 - if VeryImportantPerson.objects.filter(email=email).exists(): + if VerifiedByStaff.objects.filter(email=email).exists(): return False # A new incoming user who is being invited to be a domain manager (that is, diff --git a/src/registrar/models/user_group.py b/src/registrar/models/user_group.py index 2658ec52d..a32406a05 100644 --- a/src/registrar/models/user_group.py +++ b/src/registrar/models/user_group.py @@ -68,8 +68,8 @@ class UserGroup(Group): }, { "app_label": "registrar", - "model": "veryimportantperson", - "permissions": ["add_veryimportantperson", "change_veryimportantperson", "delete_veryimportantperson"], + "model": "verifiedbystaff", + "permissions": ["add_verifiedbystaff", "change_verifiedbystaff", "delete_verifiedbystaff"], }, ] diff --git a/src/registrar/models/very_important_person.py b/src/registrar/models/verified_by_staff.py similarity index 84% rename from src/registrar/models/very_important_person.py rename to src/registrar/models/verified_by_staff.py index 9134cb893..5ebbc8598 100644 --- a/src/registrar/models/very_important_person.py +++ b/src/registrar/models/verified_by_staff.py @@ -3,7 +3,7 @@ from django.db import models from .utility.time_stamped_model import TimeStampedModel -class VeryImportantPerson(TimeStampedModel): +class VerifiedByStaff(TimeStampedModel): """emails that get added to this table will bypass ial2 on login.""" @@ -27,6 +27,8 @@ class VeryImportantPerson(TimeStampedModel): blank=False, help_text="Notes", ) - + + class Meta: + verbose_name_plural ="Verified by staff" def __str__(self): return self.email diff --git a/src/registrar/tests/test_admin.py b/src/registrar/tests/test_admin.py index ebf3dfed9..5ca7866f7 100644 --- a/src/registrar/tests/test_admin.py +++ b/src/registrar/tests/test_admin.py @@ -18,7 +18,7 @@ from registrar.admin import ( ) from registrar.models import Domain, DomainApplication, DomainInformation, User, DomainInvitation, Contact, Website from registrar.models.user_domain_role import UserDomainRole -from registrar.models.very_important_person import VeryImportantPerson +from registrar.models.verified_by_staff import VeryImportantPerson from .common import ( MockSESClient, AuditedAdminMockData, diff --git a/src/registrar/tests/test_models.py b/src/registrar/tests/test_models.py index ef6522747..d84b241ec 100644 --- a/src/registrar/tests/test_models.py +++ b/src/registrar/tests/test_models.py @@ -16,7 +16,7 @@ from registrar.models import ( import boto3_mocking from registrar.models.transition_domain import TransitionDomain -from registrar.models.very_important_person import VeryImportantPerson # type: ignore +from registrar.models.verified_by_staff import VeryImportantPerson # type: ignore from .common import MockSESClient, less_console_noise, completed_application from django_fsm import TransitionNotAllowed From 7c63d9c21bfec343bc26d0091ddee3ed3f32c606 Mon Sep 17 00:00:00 2001 From: Alysia Broddrick Date: Mon, 29 Jan 2024 14:40:53 -0800 Subject: [PATCH 117/137] fixed typo --- src/registrar/migrations/0067_create_groups_v07.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/registrar/migrations/0067_create_groups_v07.py b/src/registrar/migrations/0067_create_groups_v07.py index b6fbd3e5c..85138d4af 100644 --- a/src/registrar/migrations/0067_create_groups_v07.py +++ b/src/registrar/migrations/0067_create_groups_v07.py @@ -25,7 +25,7 @@ def create_groups(apps, schema_editor) -> Any: class Migration(migrations.Migration): dependencies = [ - ("registrar", "0066_rename_veryimportperson_verifiedbystaff_and_more"), + ("registrar", "0066_rename_veryimportantperson_verifiedbystaff_and_more"), ] operations = [ From f85730af25398bf67b063bc717a0f834a42bd654 Mon Sep 17 00:00:00 2001 From: Alysia Broddrick Date: Mon, 29 Jan 2024 14:54:39 -0800 Subject: [PATCH 118/137] changed VIP to verified by staff --- src/registrar/admin.py | 4 ++-- src/registrar/tests/test_admin.py | 14 +++++++------- src/registrar/tests/test_migrations.py | 6 +++--- src/registrar/tests/test_models.py | 4 ++-- 4 files changed, 14 insertions(+), 14 deletions(-) diff --git a/src/registrar/admin.py b/src/registrar/admin.py index b8e08284f..325081575 100644 --- a/src/registrar/admin.py +++ b/src/registrar/admin.py @@ -1295,7 +1295,7 @@ class DraftDomainAdmin(ListHeaderAdmin): search_help_text = "Search by draft domain name." -class VeryImportantPersonAdmin(ListHeaderAdmin): +class VerifiedByStaffAdmin(ListHeaderAdmin): list_display = ("email", "requestor", "truncated_notes", "created_at") search_fields = ["email"] search_help_text = "Search by email." @@ -1338,4 +1338,4 @@ admin.site.register(models.Website, WebsiteAdmin) admin.site.register(models.PublicContact, AuditedAdmin) admin.site.register(models.DomainApplication, DomainApplicationAdmin) admin.site.register(models.TransitionDomain, TransitionDomainAdmin) -admin.site.register(models.VerifiedByStaff, VeryImportantPersonAdmin) +admin.site.register(models.VerifiedByStaff, VerifiedByStaffAdmin) diff --git a/src/registrar/tests/test_admin.py b/src/registrar/tests/test_admin.py index 5ca7866f7..0a99c039a 100644 --- a/src/registrar/tests/test_admin.py +++ b/src/registrar/tests/test_admin.py @@ -14,11 +14,11 @@ from registrar.admin import ( ContactAdmin, DomainInformationAdmin, UserDomainRoleAdmin, - VeryImportantPersonAdmin, + VerifiedByStaff, ) from registrar.models import Domain, DomainApplication, DomainInformation, User, DomainInvitation, Contact, Website from registrar.models.user_domain_role import UserDomainRole -from registrar.models.verified_by_staff import VeryImportantPerson +from registrar.models.verified_by_staff import VerifiedByStaffAdmin from .common import ( MockSESClient, AuditedAdminMockData, @@ -1820,7 +1820,7 @@ class ContactAdminTest(TestCase): User.objects.all().delete() -class VeryImportantPersonAdminTestCase(TestCase): +class VerifiedByStaffAdminTestCase(TestCase): def setUp(self): self.superuser = create_superuser() self.factory = RequestFactory() @@ -1829,13 +1829,13 @@ class VeryImportantPersonAdminTestCase(TestCase): self.client.force_login(self.superuser) # Create an instance of the admin class - admin_instance = VeryImportantPersonAdmin(model=VeryImportantPerson, admin_site=None) + admin_instance = VerifiedByStaffAdmin(model=VerifiedB, admin_site=None) - # Create a VeryImportantPerson instance - vip_instance = VeryImportantPerson(email="test@example.com", notes="Test Notes") + # Create a VerifiedByStaff instance + vip_instance = VerifiedByStaff(email="test@example.com", notes="Test Notes") # Create a request object - request = self.factory.post("/admin/yourapp/veryimportantperson/add/") + request = self.factory.post("/admin/yourapp/VerifiedByStaff/add/") request.user = self.superuser # Call the save_model method diff --git a/src/registrar/tests/test_migrations.py b/src/registrar/tests/test_migrations.py index cf28aa81a..98c9c1271 100644 --- a/src/registrar/tests/test_migrations.py +++ b/src/registrar/tests/test_migrations.py @@ -43,9 +43,9 @@ class TestGroups(TestCase): "change_user", "delete_userdomainrole", "view_userdomainrole", - "add_veryimportantperson", - "change_veryimportantperson", - "delete_veryimportantperson", + "add_verfiedbystaff", + "change_verfiedbystaff", + "delete_verfiedbystaff", "change_website", ] diff --git a/src/registrar/tests/test_models.py b/src/registrar/tests/test_models.py index d84b241ec..d0005cbd5 100644 --- a/src/registrar/tests/test_models.py +++ b/src/registrar/tests/test_models.py @@ -16,7 +16,7 @@ from registrar.models import ( import boto3_mocking from registrar.models.transition_domain import TransitionDomain -from registrar.models.verified_by_staff import VeryImportantPerson # type: ignore +from registrar.models.verified_by_staff import VerifiedByStaff # type: ignore from .common import MockSESClient, less_console_noise, completed_application from django_fsm import TransitionNotAllowed @@ -656,7 +656,7 @@ class TestUser(TestCase): def test_identity_verification_with_very_important_person(self): """A Very Important Person should return False when tested with class method needs_identity_verification""" - VeryImportantPerson.objects.get_or_create(email=self.user.email) + VerifiedByStaff.objects.get_or_create(email=self.user.email) self.assertFalse(User.needs_identity_verification(self.user.email, self.user.username)) def test_identity_verification_with_invited_user(self): From ad2d9e6f2d49f51fcbc677199e228103230ff717 Mon Sep 17 00:00:00 2001 From: Erin <121973038+erinysong@users.noreply.github.com> Date: Mon, 29 Jan 2024 14:58:05 -0800 Subject: [PATCH 119/137] removeFormErrors on availability button click --- src/registrar/assets/js/get-gov.js | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/src/registrar/assets/js/get-gov.js b/src/registrar/assets/js/get-gov.js index d92554baa..337086522 100644 --- a/src/registrar/assets/js/get-gov.js +++ b/src/registrar/assets/js/get-gov.js @@ -207,6 +207,7 @@ function handleValidationClick(e) { const attribute = e.target.getAttribute("validate-for") || ""; if (!attribute.length) return; const input = document.getElementById(attribute); + removeFormErrors(input, true); runValidators(input); } @@ -262,16 +263,16 @@ function handleFormsetValidationClick(e, availabilityButton) { // Add event listener to the "Check availability" button - const checkAvailabilityButton = document.getElementById('check-availability-button'); - if (checkAvailabilityButton) { - const targetId = checkAvailabilityButton.getAttribute('validate-for'); - const checkAvailabilityInput = document.getElementById(targetId); - checkAvailabilityButton.addEventListener('click', - function() { - removeFormErrors(checkAvailabilityInput, true); - } - ); - } + // const checkAvailabilityButton = document.getElementById('check-availability-button'); + // if (checkAvailabilityButton) { + // const targetId = checkAvailabilityButton.getAttribute('validate-for'); + // const checkAvailabilityInput = document.getElementById(targetId); + // checkAvailabilityButton.addEventListener('click', + // function() { + // removeFormErrors(checkAvailabilityInput, true); + // } + // ); + // } // Add event listener to the alternate domains input const alternateDomainsInputs = document.querySelectorAll('[auto-validate]'); From 35536327e37487be0b3bc2506359ebfa9078ba14 Mon Sep 17 00:00:00 2001 From: CocoByte Date: Mon, 29 Jan 2024 16:06:18 -0700 Subject: [PATCH 120/137] Fixed color of domain growth report heading to match colors used in model links --- src/registrar/templates/admin/index.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/registrar/templates/admin/index.html b/src/registrar/templates/admin/index.html index 04601ef32..020e258a5 100644 --- a/src/registrar/templates/admin/index.html +++ b/src/registrar/templates/admin/index.html @@ -5,7 +5,7 @@ {% include "admin/app_list.html" with app_list=app_list show_changelinks=True %}

                        Reports

                        -

                        Domain growth report

                        +

                        Domain growth report

                        {% comment %} Inputs of type date suck for accessibility. From 8a91643cd08a903ca9692700845d1aebfaf3bbfd Mon Sep 17 00:00:00 2001 From: Alysia Broddrick Date: Mon, 29 Jan 2024 15:08:43 -0800 Subject: [PATCH 121/137] linter --- src/registrar/models/verified_by_staff.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/registrar/models/verified_by_staff.py b/src/registrar/models/verified_by_staff.py index 5ebbc8598..4c9e76e9d 100644 --- a/src/registrar/models/verified_by_staff.py +++ b/src/registrar/models/verified_by_staff.py @@ -27,8 +27,9 @@ class VerifiedByStaff(TimeStampedModel): blank=False, help_text="Notes", ) - + class Meta: - verbose_name_plural ="Verified by staff" + verbose_name_plural = "Verified by staff" + def __str__(self): return self.email From 5e27ec571d07397180b0ce1850a92b8987ffe861 Mon Sep 17 00:00:00 2001 From: Erin <121973038+erinysong@users.noreply.github.com> Date: Mon, 29 Jan 2024 15:11:48 -0800 Subject: [PATCH 122/137] Remove unused function --- src/registrar/assets/js/get-gov.js | 13 ------------- 1 file changed, 13 deletions(-) diff --git a/src/registrar/assets/js/get-gov.js b/src/registrar/assets/js/get-gov.js index 337086522..2c6b7adf2 100644 --- a/src/registrar/assets/js/get-gov.js +++ b/src/registrar/assets/js/get-gov.js @@ -261,19 +261,6 @@ function handleFormsetValidationClick(e, availabilityButton) { } } - - // Add event listener to the "Check availability" button - // const checkAvailabilityButton = document.getElementById('check-availability-button'); - // if (checkAvailabilityButton) { - // const targetId = checkAvailabilityButton.getAttribute('validate-for'); - // const checkAvailabilityInput = document.getElementById(targetId); - // checkAvailabilityButton.addEventListener('click', - // function() { - // removeFormErrors(checkAvailabilityInput, true); - // } - // ); - // } - // Add event listener to the alternate domains input const alternateDomainsInputs = document.querySelectorAll('[auto-validate]'); if (alternateDomainsInputs) { From 865d8e2175763a6387e4d64d3f208d8e33e402ed Mon Sep 17 00:00:00 2001 From: CocoByte Date: Mon, 29 Jan 2024 16:23:25 -0700 Subject: [PATCH 123/137] Moved styling to sass --- src/registrar/assets/sass/_theme/_admin.scss | 2 +- src/registrar/templates/admin/index.html | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/registrar/assets/sass/_theme/_admin.scss b/src/registrar/assets/sass/_theme/_admin.scss index 6d9ab550f..760c4f13a 100644 --- a/src/registrar/assets/sass/_theme/_admin.scss +++ b/src/registrar/assets/sass/_theme/_admin.scss @@ -143,7 +143,7 @@ h1, h2, h3, .module h3 { padding: 0; - color: var(--primary); + color: var(--link-fg); margin: units(2) 0 units(1) 0; } diff --git a/src/registrar/templates/admin/index.html b/src/registrar/templates/admin/index.html index 020e258a5..04601ef32 100644 --- a/src/registrar/templates/admin/index.html +++ b/src/registrar/templates/admin/index.html @@ -5,7 +5,7 @@ {% include "admin/app_list.html" with app_list=app_list show_changelinks=True %}

                        Reports

                        -

                        Domain growth report

                        +

                        Domain growth report

                        {% comment %} Inputs of type date suck for accessibility. From 284c3107226ba8a6b6aa15edb2b13c529e90df6e Mon Sep 17 00:00:00 2001 From: Alysia Broddrick Date: Mon, 29 Jan 2024 15:25:58 -0800 Subject: [PATCH 124/137] added missing i in verified --- src/registrar/tests/test_migrations.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/registrar/tests/test_migrations.py b/src/registrar/tests/test_migrations.py index 98c9c1271..773a885c1 100644 --- a/src/registrar/tests/test_migrations.py +++ b/src/registrar/tests/test_migrations.py @@ -43,9 +43,9 @@ class TestGroups(TestCase): "change_user", "delete_userdomainrole", "view_userdomainrole", - "add_verfiedbystaff", - "change_verfiedbystaff", - "delete_verfiedbystaff", + "add_verifiedbystaff", + "change_verifiedbystaff", + "delete_verifiedbystaff", "change_website", ] From 6746947c2eb08e945a30c1fcaa25492778f0b75f Mon Sep 17 00:00:00 2001 From: Alysia Broddrick Date: Mon, 29 Jan 2024 15:27:42 -0800 Subject: [PATCH 125/137] fixed typo in test --- src/registrar/tests/test_admin.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/registrar/tests/test_admin.py b/src/registrar/tests/test_admin.py index 0a99c039a..8c75855dc 100644 --- a/src/registrar/tests/test_admin.py +++ b/src/registrar/tests/test_admin.py @@ -14,11 +14,11 @@ from registrar.admin import ( ContactAdmin, DomainInformationAdmin, UserDomainRoleAdmin, - VerifiedByStaff, + VerifiedByStaffAdmin, ) from registrar.models import Domain, DomainApplication, DomainInformation, User, DomainInvitation, Contact, Website from registrar.models.user_domain_role import UserDomainRole -from registrar.models.verified_by_staff import VerifiedByStaffAdmin +from registrar.models.verified_by_staff import VerifiedByStaff from .common import ( MockSESClient, AuditedAdminMockData, From c850e1d0841cee37fd1a90bb353894266dd49657 Mon Sep 17 00:00:00 2001 From: Alysia Broddrick Date: Mon, 29 Jan 2024 15:32:55 -0800 Subject: [PATCH 126/137] removed accidental delete --- src/registrar/tests/test_admin.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/registrar/tests/test_admin.py b/src/registrar/tests/test_admin.py index 8c75855dc..f88e25c2f 100644 --- a/src/registrar/tests/test_admin.py +++ b/src/registrar/tests/test_admin.py @@ -1829,7 +1829,7 @@ class VerifiedByStaffAdminTestCase(TestCase): self.client.force_login(self.superuser) # Create an instance of the admin class - admin_instance = VerifiedByStaffAdmin(model=VerifiedB, admin_site=None) + admin_instance = VerifiedByStaffAdmin(model=VerifiedByStaff, admin_site=None) # Create a VerifiedByStaff instance vip_instance = VerifiedByStaff(email="test@example.com", notes="Test Notes") From d2f6988bd8678721680ef65aded5ccb3b15e1f94 Mon Sep 17 00:00:00 2001 From: Erin <121973038+erinysong@users.noreply.github.com> Date: Tue, 30 Jan 2024 10:46:45 -0800 Subject: [PATCH 127/137] Rename functions for clarity --- src/registrar/assets/js/get-gov.js | 22 +++++++++---------- .../templates/application_dotgov_domain.html | 2 +- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/src/registrar/assets/js/get-gov.js b/src/registrar/assets/js/get-gov.js index 2c6b7adf2..53ab5e06b 100644 --- a/src/registrar/assets/js/get-gov.js +++ b/src/registrar/assets/js/get-gov.js @@ -203,7 +203,7 @@ function handleInputValidation(e) { } /** On button click, handles running any associated validators. */ -function handleValidationClick(e) { +function validateFieldInput(e) { const attribute = e.target.getAttribute("validate-for") || ""; if (!attribute.length) return; const input = document.getElementById(attribute); @@ -212,7 +212,7 @@ function handleValidationClick(e) { } -function handleFormsetValidationClick(e, availabilityButton) { +function validateFormsetInputs(e, availabilityButton) { // Collect input IDs from the repeatable forms let inputs = Array.from(document.querySelectorAll('.repeatable-form input')) @@ -247,26 +247,26 @@ function handleFormsetValidationClick(e, availabilityButton) { for(const input of needsValidation) { input.addEventListener('input', handleInputValidation); } - const alternativeDomainsAvailability = document.getElementById('check-avail-for-alt-domains'); + const alternativeDomainsAvailability = document.getElementById('validate-alt-domains-availability'); const activatesValidation = document.querySelectorAll('[validate-for]'); for(const button of activatesValidation) { // Adds multi-field validation for alternative domains if (button === alternativeDomainsAvailability) { button.addEventListener('click', (e) => { - handleFormsetValidationClick(e, alternativeDomainsAvailability) + validateFormsetInputs(e, alternativeDomainsAvailability) }); } else { - button.addEventListener('click', handleValidationClick); + button.addEventListener('click', validateField); } } - // Add event listener to the alternate domains input - const alternateDomainsInputs = document.querySelectorAll('[auto-validate]'); - if (alternateDomainsInputs) { - for (const domainInput of alternateDomainsInputs){ - domainInput.addEventListener('input', function() { - removeFormErrors(domainInput, true); + // Clear errors on auto-validated inputs when user reselects input + const autoValidateInputs = document.querySelectorAll('[auto-validate]'); + if (autoValidateInputs) { + for (const input of autoValidateInputs){ + input.addEventListener('input', function() { + removeFormErrors(input, true); } ); } diff --git a/src/registrar/templates/application_dotgov_domain.html b/src/registrar/templates/application_dotgov_domain.html index ac59d4629..f5b31fb15 100644 --- a/src/registrar/templates/application_dotgov_domain.html +++ b/src/registrar/templates/application_dotgov_domain.html @@ -84,7 +84,7 @@
                        From f85dc682a3c3e30ac5efcdf059887193eed0c879 Mon Sep 17 00:00:00 2001 From: zandercymatics <141044360+zandercymatics@users.noreply.github.com> Date: Tue, 30 Jan 2024 13:16:38 -0700 Subject: [PATCH 131/137] Hotfix --- src/registrar/templates/domain_users.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/registrar/templates/domain_users.html b/src/registrar/templates/domain_users.html index 349e4125a..544cb7249 100644 --- a/src/registrar/templates/domain_users.html +++ b/src/registrar/templates/domain_users.html @@ -75,7 +75,7 @@ >
                        {% with email=permission.user.email|default:permission.user|force_escape domain_name=domain.name|force_escape %} - {% include 'includes/modal.html' with modal_heading="Are you sure you want to remove " heading_value="email|add:"?" modal_description=""|add:email|add:" will no longer be able to manage the domain "|add:domain_name|add:"."|safe modal_button=modal_button|safe %} + {% include 'includes/modal.html' with modal_heading="Are you sure you want to remove " heading_value=email|add:"?" modal_description=""|add:email|add:" will no longer be able to manage the domain "|add:domain_name|add:"."|safe modal_button=modal_button|safe %} {% endwith %}
                        From 6f5a1cf5e9bbd057d4ed91ed8d3152716235618f Mon Sep 17 00:00:00 2001 From: Rebecca Hsieh Date: Tue, 30 Jan 2024 13:06:04 -0800 Subject: [PATCH 132/137] Address quick comments --- src/registrar/assets/js/get-gov.js | 2 +- src/registrar/templates/application_dotgov_domain.html | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/src/registrar/assets/js/get-gov.js b/src/registrar/assets/js/get-gov.js index 52f88bb1d..587b95305 100644 --- a/src/registrar/assets/js/get-gov.js +++ b/src/registrar/assets/js/get-gov.js @@ -219,8 +219,8 @@ function validateFormsetInputs(e, availabilityButton) { // Run validators for each input inputs.forEach(input => { - runValidators(input); removeFormErrors(input, true); + runValidators(input); }); // Set the validate-for attribute on the button with the collected input IDs diff --git a/src/registrar/templates/application_dotgov_domain.html b/src/registrar/templates/application_dotgov_domain.html index f5b31fb15..39f9935c2 100644 --- a/src/registrar/templates/application_dotgov_domain.html +++ b/src/registrar/templates/application_dotgov_domain.html @@ -48,7 +48,6 @@ {% endwith %} {% endwith %}
                        {% endif %} {% else %} - - Remove - + data-tooltip="true"> {% endif %} From 161bd30e1f5e674ed7072a5323ad9cb5cbb0b80c Mon Sep 17 00:00:00 2001 From: zandercymatics <141044360+zandercymatics@users.noreply.github.com> Date: Wed, 31 Jan 2024 08:34:05 -0700 Subject: [PATCH 136/137] Add style for disabled button --- src/registrar/assets/sass/_theme/_buttons.scss | 8 ++++++++ src/registrar/templates/domain_users.html | 6 ++++-- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/src/registrar/assets/sass/_theme/_buttons.scss b/src/registrar/assets/sass/_theme/_buttons.scss index 5148456e5..2f4121399 100644 --- a/src/registrar/assets/sass/_theme/_buttons.scss +++ b/src/registrar/assets/sass/_theme/_buttons.scss @@ -52,6 +52,14 @@ a.usa-button--unstyled.disabled-link:focus { text-decoration: none !important; } +.usa-button--unstyled.disabled-button, +.usa-button--unstyled.disabled-link:hover, +.usa-button--unstyled.disabled-link:focus { + cursor: not-allowed !important; + outline: none !important; + text-decoration: none !important; +} + a.usa-button:not(.usa-button--unstyled, .usa-button--outline) { color: color('white'); } diff --git a/src/registrar/templates/domain_users.html b/src/registrar/templates/domain_users.html index beed4a462..e295d2f7e 100644 --- a/src/registrar/templates/domain_users.html +++ b/src/registrar/templates/domain_users.html @@ -84,12 +84,14 @@ {% else %} + role="button" + > {% endif %} From 9dffa049b8001d8e9af46780b921ce2f60004808 Mon Sep 17 00:00:00 2001 From: Rachid Mrad Date: Wed, 31 Jan 2024 12:06:18 -0500 Subject: [PATCH 137/137] move the start and end date assignemnets inside check for elements --- src/registrar/assets/js/get-gov-admin.js | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/registrar/assets/js/get-gov-admin.js b/src/registrar/assets/js/get-gov-admin.js index cdbbc83ee..866c7bd7d 100644 --- a/src/registrar/assets/js/get-gov-admin.js +++ b/src/registrar/assets/js/get-gov-admin.js @@ -283,19 +283,20 @@ function enableRelatedWidgetButtons(changeLink, deleteLink, viewLink, elementPk, (function (){ // Get the current date in the format YYYY-MM-DD - var currentDate = new Date().toISOString().split('T')[0]; + let currentDate = new Date().toISOString().split('T')[0]; // Default the value of the start date input field to the current date let startDateInput =document.getElementById('start'); - startDateInput.value = currentDate; - + // Default the value of the end date input field to the current date let endDateInput =document.getElementById('end'); - endDateInput.value = currentDate; let exportGrowthReportButton = document.getElementById('exportLink'); if (exportGrowthReportButton) { + startDateInput.value = currentDate; + endDateInput.value = currentDate; + exportGrowthReportButton.addEventListener('click', function() { // Get the selected start and end dates let startDate = startDateInput.value;