mirror of
https://github.com/cisagov/manage.get.gov.git
synced 2025-07-26 04:28:39 +02:00
Code cleanup
This commit is contained in:
parent
aa875aa325
commit
a32a228e6c
14 changed files with 63 additions and 67 deletions
|
@ -873,7 +873,7 @@ function hideDeletedForms() {
|
||||||
let fieldId = getInputFieldId(fieldName)
|
let fieldId = getInputFieldId(fieldName)
|
||||||
let inputField = document.querySelector(fieldId);
|
let inputField = document.querySelector(fieldId);
|
||||||
|
|
||||||
let nameFieldset = document.querySelector("#profile-name-fieldset");
|
let nameFieldset = document.querySelector("#profile-name-group");
|
||||||
if (nameFieldset){
|
if (nameFieldset){
|
||||||
nameFieldset.classList.remove("display-none");
|
nameFieldset.classList.remove("display-none");
|
||||||
}
|
}
|
||||||
|
|
|
@ -198,3 +198,16 @@ abbr[title] {
|
||||||
height: 1.25em !important;
|
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};
|
||||||
|
}
|
||||||
|
|
|
@ -15,9 +15,6 @@
|
||||||
|
|
||||||
.usa-form--extra-large {
|
.usa-form--extra-large {
|
||||||
max-width: none;
|
max-width: none;
|
||||||
.usa-summary-box {
|
|
||||||
max-width: 600px;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.usa-form--text-width {
|
.usa-form--text-width {
|
||||||
|
@ -30,7 +27,7 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.usa-form-readonly {
|
.usa-form-editable {
|
||||||
border-top: 2px #{$dhs-dark-gray-15} solid;
|
border-top: 2px #{$dhs-dark-gray-15} solid;
|
||||||
|
|
||||||
.bold-usa-label label.usa-label{
|
.bold-usa-label label.usa-label{
|
||||||
|
@ -41,14 +38,14 @@
|
||||||
font-weight: bold;
|
font-weight: bold;
|
||||||
}
|
}
|
||||||
|
|
||||||
&.usa-form-readonly--no-border {
|
&.usa-form-editable--no-border {
|
||||||
border-top: None;
|
border-top: None;
|
||||||
margin-top: 0px !important;
|
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;
|
margin-top: unset;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -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};
|
|
||||||
}
|
|
|
@ -20,7 +20,6 @@
|
||||||
@forward "tables";
|
@forward "tables";
|
||||||
@forward "sidenav";
|
@forward "sidenav";
|
||||||
@forward "register-form";
|
@forward "register-form";
|
||||||
@forward "_headers";
|
|
||||||
|
|
||||||
/*--------------------------------------------------
|
/*--------------------------------------------------
|
||||||
--- Admin ---------------------------------*/
|
--- Admin ---------------------------------*/
|
||||||
|
|
|
@ -15,6 +15,7 @@
|
||||||
<p>If you have <a href="{% public_site_url 'domains/before/#information-you%E2%80%99ll-need-to-complete-the-domain-request-form' %}" target="_blank" class="usa-link">all the information you need</a>,
|
<p>If you have <a href="{% public_site_url 'domains/before/#information-you%E2%80%99ll-need-to-complete-the-domain-request-form' %}" target="_blank" class="usa-link">all the information you need</a>,
|
||||||
completing your domain request might take around 15 minutes.</p>
|
completing your domain request might take around 15 minutes.</p>
|
||||||
|
|
||||||
|
|
||||||
{% block form_buttons %}
|
{% block form_buttons %}
|
||||||
<div class="stepnav">
|
<div class="stepnav">
|
||||||
<button
|
<button
|
||||||
|
|
|
@ -33,38 +33,40 @@
|
||||||
Your contact information
|
Your contact information
|
||||||
</legend>
|
</legend>
|
||||||
|
|
||||||
{% with show_edit_button=True show_readonly=True group_classes="usa-form-readonly usa-form-readonly--no-border padding-top-2" %}
|
{% with show_edit_button=True show_readonly=True group_classes="usa-form-editable--no-border padding-top-2" %}
|
||||||
{% input_with_errors form.full_name %}
|
{% input_with_errors form.full_name %}
|
||||||
{% endwith %}
|
{% endwith %}
|
||||||
|
|
||||||
<div id="profile-name-fieldset" class="display-none" role="group">
|
<div id="profile-name-group" class="display-none" role="group">
|
||||||
{% with group_classes="usa-form-readonly usa-form-readonly--no-border padding-top-2" %}
|
{% with group_classes="usa-form-editable usa-form-editable--no-border padding-top-2" %}
|
||||||
{% input_with_errors form.first_name %}
|
{% input_with_errors form.first_name %}
|
||||||
{% endwith %}
|
{% endwith %}
|
||||||
|
|
||||||
{% with group_classes="usa-form-readonly padding-top-2" %}
|
{% with group_classes="usa-form-editable padding-top-2" %}
|
||||||
{% input_with_errors form.middle_name %}
|
{% input_with_errors form.middle_name %}
|
||||||
{% endwith %}
|
{% endwith %}
|
||||||
|
|
||||||
{% with group_classes="usa-form-readonly padding-top-2" %}
|
{% with group_classes="usa-form-editable padding-top-2" %}
|
||||||
{% input_with_errors form.last_name %}
|
{% input_with_errors form.last_name %}
|
||||||
{% endwith %}
|
{% endwith %}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{% public_site_url "help/account-management/#get-help-with-login.gov" as login_help_url %}
|
{% public_site_url "help/account-management/#get-help-with-login.gov" as login_help_url %}
|
||||||
{% with link_href=login_help_url show_readonly=True group_classes="usa-form-readonly padding-top-2 bold-usa-label" add_class="display-none"%}
|
{% with show_readonly=True add_class="display-none" group_classes="usa-form-editable padding-top-2 bold-usa-label" %}
|
||||||
{% with sublabel_text="We recommend using your work email for your .gov account. If the wrong email is displayed below, you’ll need to update your Login.gov account and log back in. Get help with your Login.gov account." %}
|
{% with link_href=login_help_url %}
|
||||||
{% with link_text="Get help with your Login.gov account" target_blank=True do_not_show_max_chars=True %}
|
{% with sublabel_text="We recommend using your work email for your .gov account. If the wrong email is displayed below, you’ll need to update your Login.gov account and log back in. Get help with your Login.gov account." %}
|
||||||
{% input_with_errors form.email %}
|
{% with link_text="Get help with your Login.gov account" target_blank=True do_not_show_max_chars=True %}
|
||||||
|
{% input_with_errors form.email %}
|
||||||
|
{% endwith %}
|
||||||
{% endwith %}
|
{% endwith %}
|
||||||
{% endwith %}
|
{% endwith %}
|
||||||
{% endwith %}
|
{% endwith %}
|
||||||
|
|
||||||
{% with show_edit_button=True show_readonly=True group_classes="usa-form-readonly padding-top-2" %}
|
{% with show_edit_button=True show_readonly=True group_classes="padding-top-2" %}
|
||||||
{% input_with_errors form.title %}
|
{% input_with_errors form.title %}
|
||||||
{% endwith %}
|
{% endwith %}
|
||||||
|
|
||||||
{% with show_edit_button=True show_readonly=True group_classes="usa-form-readonly padding-top-2" %}
|
{% with show_edit_button=True show_readonly=True group_classes="padding-top-2" %}
|
||||||
{% with add_class="usa-input--medium" %}
|
{% with add_class="usa-input--medium" %}
|
||||||
{% input_with_errors form.phone %}
|
{% input_with_errors form.phone %}
|
||||||
{% endwith %}
|
{% endwith %}
|
||||||
|
|
|
@ -14,4 +14,4 @@
|
||||||
>.gov Registrar</button>
|
>.gov Registrar</button>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</strong>
|
</strong>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -36,5 +36,4 @@ Edit your User Profile |
|
||||||
{% include "includes/profile_form.html" with form=form %}
|
{% include "includes/profile_form.html" with form=form %}
|
||||||
</div>
|
</div>
|
||||||
</main>
|
</main>
|
||||||
{% endblock %}
|
{% endblock content_bottom %}
|
||||||
|
|
||||||
|
|
|
@ -95,10 +95,12 @@ def input_with_errors(context, field=None): # noqa: C901
|
||||||
elif key == "show_edit_button":
|
elif key == "show_edit_button":
|
||||||
# Hide the primary input field.
|
# Hide the primary input field.
|
||||||
# Used such that we can toggle it with JS
|
# 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")
|
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
|
attrs["id"] = field.auto_id
|
||||||
|
|
||||||
|
|
|
@ -15,7 +15,6 @@ from registrar.models.user import User
|
||||||
from registrar.utility import StrEnum
|
from registrar.utility import StrEnum
|
||||||
from registrar.views.utility import StepsHelper
|
from registrar.views.utility import StepsHelper
|
||||||
from registrar.views.utility.permission_views import DomainRequestPermissionDeleteView
|
from registrar.views.utility.permission_views import DomainRequestPermissionDeleteView
|
||||||
from waffle.decorators import flag_is_active, waffle_flag
|
|
||||||
|
|
||||||
from .utility import (
|
from .utility import (
|
||||||
DomainRequestPermissionView,
|
DomainRequestPermissionView,
|
||||||
|
@ -23,6 +22,7 @@ from .utility import (
|
||||||
DomainRequestWizardPermissionView,
|
DomainRequestWizardPermissionView,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
from waffle.decorators import flag_is_active
|
||||||
|
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
@ -400,13 +400,7 @@ class DomainRequestWizard(DomainRequestWizardPermissionView, TemplateView):
|
||||||
def get_step_list(self) -> list:
|
def get_step_list(self) -> list:
|
||||||
"""Dynamically generated list of steps in the form wizard."""
|
"""Dynamically generated list of steps in the form wizard."""
|
||||||
step_list = []
|
step_list = []
|
||||||
excluded_steps = [Step.YOUR_CONTACT]
|
|
||||||
should_exclude = flag_is_active(self.request, "profile_feature")
|
|
||||||
for step in Step:
|
for step in Step:
|
||||||
|
|
||||||
if should_exclude and step in excluded_steps:
|
|
||||||
continue
|
|
||||||
|
|
||||||
condition = self.WIZARD_CONDITIONS.get(step, True)
|
condition = self.WIZARD_CONDITIONS.get(step, True)
|
||||||
if callable(condition):
|
if callable(condition):
|
||||||
condition = condition(self)
|
condition = condition(self)
|
||||||
|
@ -546,10 +540,6 @@ class YourContact(DomainRequestWizard):
|
||||||
template_name = "domain_request_your_contact.html"
|
template_name = "domain_request_your_contact.html"
|
||||||
forms = [forms.YourContactForm]
|
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):
|
class OtherContacts(DomainRequestWizard):
|
||||||
template_name = "domain_request_other_contacts.html"
|
template_name = "domain_request_other_contacts.html"
|
||||||
|
|
|
@ -96,10 +96,6 @@ class FinishProfileSetupView(UserProfileView):
|
||||||
"""This view forces the user into providing additional details that
|
"""This view forces the user into providing additional details that
|
||||||
we may have missed from Login.gov"""
|
we may have missed from Login.gov"""
|
||||||
|
|
||||||
template_name = "finish_profile_setup.html"
|
|
||||||
form_class = FinishSetupProfileForm
|
|
||||||
model = Contact
|
|
||||||
|
|
||||||
class RedirectType(Enum):
|
class RedirectType(Enum):
|
||||||
"""
|
"""
|
||||||
Enums for each type of redirection. Enforces behaviour on `get_redirect_url()`.
|
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"
|
BACK_TO_SELF = "back_to_self"
|
||||||
COMPLETE_SETUP = "complete_setup"
|
COMPLETE_SETUP = "complete_setup"
|
||||||
|
|
||||||
redirect_type = None
|
@classmethod
|
||||||
all_redirect_types = [r.value for r in RedirectType]
|
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):
|
def get_context_data(self, **kwargs):
|
||||||
|
|
||||||
|
@ -151,16 +156,18 @@ class FinishProfileSetupView(UserProfileView):
|
||||||
"""
|
"""
|
||||||
|
|
||||||
# Update redirect type based on the query parameter if present
|
# Update redirect type based on the query parameter if present
|
||||||
redirect_type = request.GET.get("redirect", self.RedirectType.BACK_TO_SELF.value)
|
default_redirect_value = self.RedirectType.BACK_TO_SELF.value
|
||||||
if redirect_type in self.all_redirect_types:
|
redirect_value = request.GET.get("redirect", default_redirect_value)
|
||||||
self.redirect_type = self.RedirectType(redirect_type)
|
|
||||||
|
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:
|
else:
|
||||||
# If the redirect type is undefined, then we assume that
|
# If the redirect type is undefined, then we assume that we are specifying a particular page to redirect to.
|
||||||
# we are specifying a particular page to redirect to.
|
|
||||||
self.redirect_type = self.RedirectType.TO_SPECIFIC_PAGE
|
self.redirect_type = self.RedirectType.TO_SPECIFIC_PAGE
|
||||||
|
|
||||||
# Store the page that we want to redirect to for later use
|
# 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)
|
return super().dispatch(request, *args, **kwargs)
|
||||||
|
|
||||||
|
@ -183,8 +190,7 @@ class FinishProfileSetupView(UserProfileView):
|
||||||
|
|
||||||
def get_success_url(self):
|
def get_success_url(self):
|
||||||
"""Redirect to the nameservers page for the domain."""
|
"""Redirect to the nameservers page for the domain."""
|
||||||
redirect_url = self.get_redirect_url()
|
return self.get_redirect_url()
|
||||||
return redirect_url
|
|
||||||
|
|
||||||
def get_redirect_url(self):
|
def get_redirect_url(self):
|
||||||
"""
|
"""
|
||||||
|
@ -220,7 +226,7 @@ class FinishProfileSetupView(UserProfileView):
|
||||||
query_params = {}
|
query_params = {}
|
||||||
|
|
||||||
# Quote cleans up the value so that it can be used in a url
|
# 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)
|
query_params["redirect"] = quote(self.redirect_type.value)
|
||||||
|
|
||||||
# Generate the full url from the given query params
|
# Generate the full url from the given query params
|
||||||
|
|
|
@ -296,7 +296,6 @@ class UserDeleteDomainRolePermission(PermissionsLoginMixin):
|
||||||
domain_pk = self.kwargs["pk"]
|
domain_pk = self.kwargs["pk"]
|
||||||
user_pk = self.kwargs["user_pk"]
|
user_pk = self.kwargs["user_pk"]
|
||||||
|
|
||||||
# Check if the user is authenticated
|
|
||||||
if not self.request.user.is_authenticated:
|
if not self.request.user.is_authenticated:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
|
|
@ -3,7 +3,9 @@
|
||||||
import abc # abstract base class
|
import abc # abstract base class
|
||||||
|
|
||||||
from django.views.generic import DetailView, DeleteView, TemplateView
|
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 (
|
from .mixins import (
|
||||||
DomainPermission,
|
DomainPermission,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue