mirror of
https://github.com/cisagov/manage.get.gov.git
synced 2025-07-25 12:08:40 +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 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");
|
||||
}
|
||||
|
|
|
@ -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};
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
@ -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 "sidenav";
|
||||
@forward "register-form";
|
||||
@forward "_headers";
|
||||
|
||||
/*--------------------------------------------------
|
||||
--- 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>,
|
||||
completing your domain request might take around 15 minutes.</p>
|
||||
|
||||
|
||||
{% block form_buttons %}
|
||||
<div class="stepnav">
|
||||
<button
|
||||
|
|
|
@ -33,38 +33,40 @@
|
|||
Your contact information
|
||||
</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 %}
|
||||
{% endwith %}
|
||||
|
||||
<div id="profile-name-fieldset" class="display-none" role="group">
|
||||
{% with group_classes="usa-form-readonly usa-form-readonly--no-border padding-top-2" %}
|
||||
<div id="profile-name-group" class="display-none" role="group">
|
||||
{% with group_classes="usa-form-editable usa-form-editable--no-border padding-top-2" %}
|
||||
{% input_with_errors form.first_name %}
|
||||
{% 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 %}
|
||||
{% 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 %}
|
||||
{% endwith %}
|
||||
</div>
|
||||
|
||||
{% 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 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_text="Get help with your Login.gov account" target_blank=True do_not_show_max_chars=True %}
|
||||
{% input_with_errors form.email %}
|
||||
{% with show_readonly=True add_class="display-none" group_classes="usa-form-editable padding-top-2 bold-usa-label" %}
|
||||
{% with link_href=login_help_url %}
|
||||
{% 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_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 %}
|
||||
|
||||
{% 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 %}
|
||||
{% 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" %}
|
||||
{% input_with_errors form.phone %}
|
||||
{% endwith %}
|
||||
|
|
|
@ -14,4 +14,4 @@
|
|||
>.gov Registrar</button>
|
||||
{% endif %}
|
||||
</strong>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
@ -36,5 +36,4 @@ Edit your User Profile |
|
|||
{% include "includes/profile_form.html" with form=form %}
|
||||
</div>
|
||||
</main>
|
||||
{% endblock %}
|
||||
|
||||
{% endblock content_bottom %}
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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"
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue