Cleanup context and template logic

This commit is contained in:
zandercymatics 2024-05-21 15:00:03 -06:00
parent 47de6f17a7
commit 84febbbde3
No known key found for this signature in database
GPG key ID: FF4636ABEC9682B7
4 changed files with 44 additions and 69 deletions

View file

@ -8,41 +8,12 @@
{% include "includes/gov_extended_logo.html" with logo_clickable=False %} {% include "includes/gov_extended_logo.html" with logo_clickable=False %}
{% endblock %} {% endblock %}
{% block content %} {# Add the new form #}
<div class="grid-container"> {% block content_bottom %}
<div class="grid-row grid-gap"> {% include "includes/finish_profile_form.html" with form=form %}
<div class="tablet:grid-col">
<main id="main-content" class="grid-container">
{# messages block is under the back breadcrumb link #}
{% if messages %}
{% for message in messages %}
<div class="usa-alert usa-alert--{{ message.tags }} usa-alert--slim margin-bottom-3">
<div class="usa-alert__body">
{{ message }}
</div>
</div>
{% endfor %}
{% endif %}
{% include "includes/form_errors.html" with form=form %}
{% if confirm_changes and not going_to_specific_page %}
<a href="{% url 'home' %}" class="breadcrumb__back">
<svg class="usa-icon" aria-hidden="true" focusable="false" role="img">
<use xlink:href="{% static 'img/sprite.svg' %}#arrow_back"></use>
</svg>
<p class="margin-left-05 margin-top-0 margin-bottom-0 line-height-sans-1">
Back to manage your domains
</p>
</a>
{% endif %}
{% include "includes/finish_profile_form.html" with form=form %}
</main>
</div>
</div> </div>
</div> </main>
{% endblock content %} {% endblock content_bottom %}
{% block footer %} {% block footer %}
{% include "includes/footer.html" %} {% include "includes/footer.html" %}

View file

@ -51,10 +51,12 @@
{% endwith %} {% endwith %}
</div> </div>
{# This field doesn't have the readonly button but it has common design elements from it #} {% public_site_url "help/account-management/#get-help-with-login.gov" as login_help_url %}
{% with show_readonly=True group_classes="usa-form-readonly padding-top-2 bold-usa-label" %} {% 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 target_blank="true" sublabel_text=email_sublabel_text add_class="display-none" %} {% with sublabel_text="We recommend using your work email for your .gov account. If the wrong email is displayed below, youll 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 %}

View file

@ -8,16 +8,6 @@ Edit your User Profile |
{% block content %} {% block content %}
<main id="main-content" class="grid-container"> <main id="main-content" class="grid-container">
<div class="grid-col desktop:grid-offset-2 desktop:grid-col-8"> <div class="grid-col desktop:grid-offset-2 desktop:grid-col-8">
<a href="{% url 'home' %}" class="breadcrumb__back">
<svg class="usa-icon" aria-hidden="true" focusable="false" role="img">
<use xlink:href="{% static 'img/sprite.svg' %}#arrow_back"></use>
</svg>
<p class="margin-left-05 margin-top-0 margin-bottom-0 line-height-sans-1">
Go to manage your domains
</p>
</a>
{# messages block is under the back breadcrumb link #}
{% if messages %} {% if messages %}
{% for message in messages %} {% for message in messages %}
<div class="usa-alert usa-alert--{{ message.tags }} usa-alert--slim margin-bottom-3"> <div class="usa-alert usa-alert--{{ message.tags }} usa-alert--slim margin-bottom-3">
@ -28,7 +18,23 @@ Edit your User Profile |
{% endfor %} {% endfor %}
{% endif %} {% endif %}
{% include "includes/form_errors.html" with form=form %} {% include "includes/form_errors.html" with form=form %}
{% include "includes/profile_form.html" with form=form %}
{% if show_back_button %}
<a href="{% url 'home' %}" class="breadcrumb__back">
<svg class="usa-icon" aria-hidden="true" focusable="false" role="img">
<use xlink:href="{% static 'img/sprite.svg' %}#arrow_back"></use>
</svg>
<p class="margin-left-05 margin-top-0 margin-bottom-0 line-height-sans-1">
{{ profile_back_button_text }}
</p>
</a>
{% endif %}
{% endblock content %}
{% block content_bottom %}
{% include "includes/profile_form.html" with form=form %}
</div> </div>
</main> </main>
{% endblock content %} {% endblock %}

View file

@ -56,6 +56,11 @@ class UserProfileView(UserProfilePermissionView, FormMixin):
context = super().get_context_data(**kwargs) context = super().get_context_data(**kwargs)
# This is a django waffle flag which toggles features based off of the "flag" table # This is a django waffle flag which toggles features based off of the "flag" table
context["has_profile_feature_flag"] = flag_is_active(self.request, "profile_feature") context["has_profile_feature_flag"] = flag_is_active(self.request, "profile_feature")
# The text for the back button on this page
context["profile_back_button_text"] = "Go to manage your domains"
context["show_back_button"] = True
return context return context
def get_success_url(self): def get_success_url(self):
@ -104,44 +109,35 @@ class FinishProfileSetupView(UserProfileView):
Enums for each type of redirection. Enforces behaviour on `get_redirect_url()`. Enums for each type of redirection. Enforces behaviour on `get_redirect_url()`.
- HOME: We want to redirect to reverse("home") - HOME: We want to redirect to reverse("home")
- BACK_TO_SELF: We want to redirect back to reverse("finish-user-profile-setup") - BACK_TO_SELF: We want to redirect back to this page
- TO_SPECIFIC_PAGE: We want to redirect to the page specified in the queryparam "redirect" - TO_SPECIFIC_PAGE: We want to redirect to the page specified in the queryparam "redirect"
- COMPLETE_SETUP: Indicates that we want to navigate BACK_TO_SELF, but the subsequent - COMPLETE_SETUP: Indicates that we want to navigate BACK_TO_SELF, but the subsequent
redirect after the next POST should be either HOME or TO_SPECIFIC_PAGE redirect after the next POST should be either HOME or TO_SPECIFIC_PAGE
""" """
HOME = "home" HOME = "home"
TO_SPECIFIC_PAGE = "domain_request"
BACK_TO_SELF = "back_to_self" BACK_TO_SELF = "back_to_self"
COMPLETE_SETUP = "complete_setup" COMPLETE_SETUP = "complete_setup"
TO_SPECIFIC_PAGE = "domain_request"
def get_context_data(self, **kwargs): def get_context_data(self, **kwargs):
context = super().get_context_data(**kwargs) context = super().get_context_data(**kwargs)
context["email_sublabel_text"] = self._email_sublabel_text()
# Hide the back button by default
context["show_back_button"] = False
if self.redirect_type == self.RedirectType.COMPLETE_SETUP: if self.redirect_type == self.RedirectType.COMPLETE_SETUP:
context["confirm_changes"] = True context["confirm_changes"] = True
if "redirect_viewname" in self.session: if "redirect_viewname" not in self.session:
context["going_to_specific_page"] = True context["show_back_button"] = True
context["redirect_button_text"] = "Continue to your request" else:
context["going_to_specific_page"] = True
context["redirect_button_text"] = "Continue to your request"
return context return context
def _email_sublabel_text(self):
"""Returns the lengthy sublabel for the email field"""
help_url = public_site_url("help/account-management/#get-help-with-login.gov")
return mark_safe(
"We recommend using your work email for your .gov account. "
"If the wrong email is displayed below, youll need to update your Login.gov account "
f'and log back in. <a class="usa-link" href={help_url}>Get help with your Login.gov account.</a>'
) # nosec
def get_success_message(self, cleaned_data):
"""Content of the returned success message"""
return "Your profile has been successfully updated."
@method_decorator(csrf_protect) @method_decorator(csrf_protect)
def dispatch(self, request, *args, **kwargs): def dispatch(self, request, *args, **kwargs):
""" """