From a32a228e6ccb8edf9f7a809cd65a26100c284b02 Mon Sep 17 00:00:00 2001 From: zandercymatics <141044360+zandercymatics@users.noreply.github.com> Date: Tue, 28 May 2024 13:06:06 -0600 Subject: [PATCH] Code cleanup --- src/registrar/assets/js/get-gov.js | 2 +- src/registrar/assets/sass/_theme/_base.scss | 13 +++++++ src/registrar/assets/sass/_theme/_forms.scss | 9 ++--- .../assets/sass/_theme/_headers.scss | 14 -------- src/registrar/assets/sass/_theme/styles.scss | 1 - .../templates/domain_request_intro.html | 1 + .../includes/finish_profile_form.html | 24 +++++++------ .../templates/includes/gov_extended_logo.html | 2 +- src/registrar/templates/profile.html | 3 +- src/registrar/templatetags/field_helpers.py | 8 +++-- src/registrar/views/domain_request.py | 12 +------ src/registrar/views/user_profile.py | 36 +++++++++++-------- src/registrar/views/utility/mixins.py | 1 - .../views/utility/permission_views.py | 4 ++- 14 files changed, 63 insertions(+), 67 deletions(-) delete mode 100644 src/registrar/assets/sass/_theme/_headers.scss diff --git a/src/registrar/assets/js/get-gov.js b/src/registrar/assets/js/get-gov.js index 5db6cea54..a48d9b46b 100644 --- a/src/registrar/assets/js/get-gov.js +++ b/src/registrar/assets/js/get-gov.js @@ -873,7 +873,7 @@ function hideDeletedForms() { let fieldId = getInputFieldId(fieldName) let inputField = document.querySelector(fieldId); - let nameFieldset = document.querySelector("#profile-name-fieldset"); + let nameFieldset = document.querySelector("#profile-name-group"); if (nameFieldset){ nameFieldset.classList.remove("display-none"); } diff --git a/src/registrar/assets/sass/_theme/_base.scss b/src/registrar/assets/sass/_theme/_base.scss index 5e7fa0c6c..e88d75f4e 100644 --- a/src/registrar/assets/sass/_theme/_base.scss +++ b/src/registrar/assets/sass/_theme/_base.scss @@ -198,3 +198,16 @@ abbr[title] { height: 1.25em !important; } } + +// Define some styles for the .gov header/logo +.usa-logo button { + color: #{$dhs-dark-gray-85}; + font-weight: 700; + font-family: family('sans'); + font-size: 1.6rem; + line-height: 1.1; +} + +.usa-logo button.usa-button--unstyled.disabled-button:hover{ + color: #{$dhs-dark-gray-85}; +} diff --git a/src/registrar/assets/sass/_theme/_forms.scss b/src/registrar/assets/sass/_theme/_forms.scss index 46d41059a..b5229fae1 100644 --- a/src/registrar/assets/sass/_theme/_forms.scss +++ b/src/registrar/assets/sass/_theme/_forms.scss @@ -15,9 +15,6 @@ .usa-form--extra-large { max-width: none; - .usa-summary-box { - max-width: 600px; - } } .usa-form--text-width { @@ -30,7 +27,7 @@ } } -.usa-form-readonly { +.usa-form-editable { border-top: 2px #{$dhs-dark-gray-15} solid; .bold-usa-label label.usa-label{ @@ -41,14 +38,14 @@ font-weight: bold; } - &.usa-form-readonly--no-border { + &.usa-form-editable--no-border { border-top: None; margin-top: 0px !important; } } -.usa-form-readonly > .usa-form-group:first-of-type { +.usa-form-editable > .usa-form-group:first-of-type { margin-top: unset; } diff --git a/src/registrar/assets/sass/_theme/_headers.scss b/src/registrar/assets/sass/_theme/_headers.scss deleted file mode 100644 index 2e3992e5a..000000000 --- a/src/registrar/assets/sass/_theme/_headers.scss +++ /dev/null @@ -1,14 +0,0 @@ -@use "uswds-core" as *; -@use "cisa_colors" as *; - -.usa-logo button { - color: #{$dhs-dark-gray-85}; - font-weight: 700; - font-family: family('sans'); - font-size: 1.6rem; - line-height: 1.1; -} - -.usa-logo button.usa-button--unstyled.disabled-button:hover{ - color: #{$dhs-dark-gray-85}; -} diff --git a/src/registrar/assets/sass/_theme/styles.scss b/src/registrar/assets/sass/_theme/styles.scss index e24618a23..64b113a29 100644 --- a/src/registrar/assets/sass/_theme/styles.scss +++ b/src/registrar/assets/sass/_theme/styles.scss @@ -20,7 +20,6 @@ @forward "tables"; @forward "sidenav"; @forward "register-form"; -@forward "_headers"; /*-------------------------------------------------- --- Admin ---------------------------------*/ diff --git a/src/registrar/templates/domain_request_intro.html b/src/registrar/templates/domain_request_intro.html index 259657ad4..c0b566799 100644 --- a/src/registrar/templates/domain_request_intro.html +++ b/src/registrar/templates/domain_request_intro.html @@ -15,6 +15,7 @@

If you have all the information you need, completing your domain request might take around 15 minutes.

+ {% block form_buttons %}
{% endif %} -
\ No newline at end of file + diff --git a/src/registrar/templates/profile.html b/src/registrar/templates/profile.html index eeab1f945..12441da66 100644 --- a/src/registrar/templates/profile.html +++ b/src/registrar/templates/profile.html @@ -36,5 +36,4 @@ Edit your User Profile | {% include "includes/profile_form.html" with form=form %} -{% endblock %} - +{% endblock content_bottom %} diff --git a/src/registrar/templatetags/field_helpers.py b/src/registrar/templatetags/field_helpers.py index a7aa9d663..be78099db 100644 --- a/src/registrar/templatetags/field_helpers.py +++ b/src/registrar/templatetags/field_helpers.py @@ -95,10 +95,12 @@ def input_with_errors(context, field=None): # noqa: C901 elif key == "show_edit_button": # Hide the primary input field. # Used such that we can toggle it with JS - if "display-none" not in classes and isinstance(value, bool) and value: + if "display-none" not in classes: classes.append("display-none") - # Set this as a context value so we know what we're going to display - context["show_edit_button"] = value + + # Tag that this form contains the edit button. + if "usa-form-editable" not in group_classes: + group_classes.append("usa-form-editable") attrs["id"] = field.auto_id diff --git a/src/registrar/views/domain_request.py b/src/registrar/views/domain_request.py index 1d14e4b57..a90eaf271 100644 --- a/src/registrar/views/domain_request.py +++ b/src/registrar/views/domain_request.py @@ -15,7 +15,6 @@ from registrar.models.user import User from registrar.utility import StrEnum from registrar.views.utility import StepsHelper from registrar.views.utility.permission_views import DomainRequestPermissionDeleteView -from waffle.decorators import flag_is_active, waffle_flag from .utility import ( DomainRequestPermissionView, @@ -23,6 +22,7 @@ from .utility import ( DomainRequestWizardPermissionView, ) +from waffle.decorators import flag_is_active logger = logging.getLogger(__name__) @@ -400,13 +400,7 @@ class DomainRequestWizard(DomainRequestWizardPermissionView, TemplateView): def get_step_list(self) -> list: """Dynamically generated list of steps in the form wizard.""" step_list = [] - excluded_steps = [Step.YOUR_CONTACT] - should_exclude = flag_is_active(self.request, "profile_feature") for step in Step: - - if should_exclude and step in excluded_steps: - continue - condition = self.WIZARD_CONDITIONS.get(step, True) if callable(condition): condition = condition(self) @@ -546,10 +540,6 @@ class YourContact(DomainRequestWizard): template_name = "domain_request_your_contact.html" forms = [forms.YourContactForm] - @waffle_flag("!profile_feature") # type: ignore - def dispatch(self, request, *args, **kwargs): # type: ignore - return super().dispatch(request, *args, **kwargs) - class OtherContacts(DomainRequestWizard): template_name = "domain_request_other_contacts.html" diff --git a/src/registrar/views/user_profile.py b/src/registrar/views/user_profile.py index b12812849..a4756f482 100644 --- a/src/registrar/views/user_profile.py +++ b/src/registrar/views/user_profile.py @@ -96,10 +96,6 @@ class FinishProfileSetupView(UserProfileView): """This view forces the user into providing additional details that we may have missed from Login.gov""" - template_name = "finish_profile_setup.html" - form_class = FinishSetupProfileForm - model = Contact - class RedirectType(Enum): """ Enums for each type of redirection. Enforces behaviour on `get_redirect_url()`. @@ -116,8 +112,17 @@ class FinishProfileSetupView(UserProfileView): BACK_TO_SELF = "back_to_self" COMPLETE_SETUP = "complete_setup" - redirect_type = None - all_redirect_types = [r.value for r in RedirectType] + @classmethod + def get_all_redirect_types(cls) -> list[str]: + """Returns the value of every redirect type defined in this enum.""" + return [r.value for r in cls] + + template_name = "finish_profile_setup.html" + form_class = FinishSetupProfileForm + model = Contact + + all_redirect_types = RedirectType.get_all_redirect_types() + redirect_type: RedirectType def get_context_data(self, **kwargs): @@ -151,16 +156,18 @@ class FinishProfileSetupView(UserProfileView): """ # Update redirect type based on the query parameter if present - redirect_type = request.GET.get("redirect", self.RedirectType.BACK_TO_SELF.value) - if redirect_type in self.all_redirect_types: - self.redirect_type = self.RedirectType(redirect_type) + default_redirect_value = self.RedirectType.BACK_TO_SELF.value + redirect_value = request.GET.get("redirect", default_redirect_value) + + if redirect_value in self.all_redirect_types: + # If the redirect value is a preexisting value in our enum, set it to that. + self.redirect_type = self.RedirectType(redirect_value) else: - # If the redirect type is undefined, then we assume that - # we are specifying a particular page to redirect to. + # If the redirect type is undefined, then we assume that we are specifying a particular page to redirect to. self.redirect_type = self.RedirectType.TO_SPECIFIC_PAGE # Store the page that we want to redirect to for later use - request.session["redirect_viewname"] = str(redirect_type) + request.session["redirect_viewname"] = str(redirect_value) return super().dispatch(request, *args, **kwargs) @@ -183,8 +190,7 @@ class FinishProfileSetupView(UserProfileView): def get_success_url(self): """Redirect to the nameservers page for the domain.""" - redirect_url = self.get_redirect_url() - return redirect_url + return self.get_redirect_url() def get_redirect_url(self): """ @@ -220,7 +226,7 @@ class FinishProfileSetupView(UserProfileView): query_params = {} # Quote cleans up the value so that it can be used in a url - if self.redirect_type: + if self.redirect_type and self.redirect_type.value: query_params["redirect"] = quote(self.redirect_type.value) # Generate the full url from the given query params diff --git a/src/registrar/views/utility/mixins.py b/src/registrar/views/utility/mixins.py index 0b8a7605a..926ee4a8c 100644 --- a/src/registrar/views/utility/mixins.py +++ b/src/registrar/views/utility/mixins.py @@ -296,7 +296,6 @@ class UserDeleteDomainRolePermission(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 diff --git a/src/registrar/views/utility/permission_views.py b/src/registrar/views/utility/permission_views.py index eb40621b5..d35647af2 100644 --- a/src/registrar/views/utility/permission_views.py +++ b/src/registrar/views/utility/permission_views.py @@ -3,7 +3,9 @@ import abc # abstract base class from django.views.generic import DetailView, DeleteView, TemplateView -from registrar.models import Domain, DomainRequest, DomainInvitation, UserDomainRole, Contact +from registrar.models import Domain, DomainRequest, DomainInvitation +from registrar.models.contact import Contact +from registrar.models.user_domain_role import UserDomainRole from .mixins import ( DomainPermission,