mirror of
https://github.com/cisagov/manage.get.gov.git
synced 2025-07-24 03:30:50 +02:00
v2 with signed. Referring to PR #414
This commit is contained in:
parent
e3b6aaaf62
commit
2024d1c905
5 changed files with 36 additions and 2 deletions
|
@ -18,6 +18,10 @@
|
|||
</a>
|
||||
{% endif %}
|
||||
|
||||
{% block form_messages %}
|
||||
{% include "includes/form_messages.html" %}
|
||||
{% endblock %}
|
||||
|
||||
{% block form_errors %}
|
||||
{% comment %}
|
||||
to make sense of this loop, consider that
|
||||
|
|
|
@ -167,9 +167,11 @@
|
|||
{% if messages %}
|
||||
<ul class="messages">
|
||||
{% for message in messages %}
|
||||
{% if 'base' in message.extra_tags %}
|
||||
<li{% if message.tags %} class="{{ message.tags }}" {% endif %}>
|
||||
{{ message }}
|
||||
</li>
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
</ul>
|
||||
{% endif %}
|
||||
|
|
|
@ -1,5 +1,9 @@
|
|||
{% comment %}
|
||||
Commenting the code below to turn off the error because
|
||||
we are showing the caution dialog instead. But saving in
|
||||
case we want to revert this.
|
||||
{% if form.errors %}
|
||||
{% for error in form.non_field_errors %}
|
||||
{% for error in form.non_field_errors %}
|
||||
<div class="usa-alert usa-alert--error usa-alert--slim margin-bottom-2">
|
||||
<div class="usa-alert__body">
|
||||
{{ error|escape }}
|
||||
|
@ -15,4 +19,5 @@
|
|||
</div>
|
||||
{% endfor %}
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
{% endcomment %}
|
10
src/registrar/templates/includes/form_messages.html
Normal file
10
src/registrar/templates/includes/form_messages.html
Normal file
|
@ -0,0 +1,10 @@
|
|||
{% if messages %}
|
||||
{% for message in messages %}
|
||||
<div class="usa-alert usa-alert--{{ message.tags }} usa-alert--slim margin-bottom-2">
|
||||
<div class="usa-alert__body">
|
||||
{{ message }}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{% endfor %}
|
||||
{% endif %}
|
|
@ -6,6 +6,8 @@ from django.shortcuts import redirect, render
|
|||
from django.urls import resolve, reverse
|
||||
from django.utils.translation import gettext_lazy as _
|
||||
from django.views.generic import TemplateView
|
||||
from django.contrib import messages
|
||||
from django.utils.safestring import mark_safe
|
||||
|
||||
from registrar.forms import application_wizard as forms
|
||||
from registrar.models import DomainApplication
|
||||
|
@ -319,6 +321,16 @@ class ApplicationWizard(LoginRequiredMixin, TemplateView):
|
|||
self.save(forms)
|
||||
else:
|
||||
# unless there are errors
|
||||
# no sec because this use of mark_safe does not introduce a cross-site
|
||||
# scripting vulnerability because there is no untrusted content inside.
|
||||
# It is only being used to pass a specific HTML entity into a template.
|
||||
messages.warning(
|
||||
request,
|
||||
mark_safe( # nosec
|
||||
"<b>We could not save all the fields.</b><br/> The highlighted "
|
||||
+ "fields below <b>could not be saved</b> because they have "
|
||||
+ "missing or invalid data. All other information on this page "
|
||||
+ "has been saved."
|
||||
context = self.get_context_data()
|
||||
context["forms"] = forms
|
||||
return render(request, self.template_name, context)
|
||||
|
@ -326,6 +338,7 @@ class ApplicationWizard(LoginRequiredMixin, TemplateView):
|
|||
# if user opted to save their progress,
|
||||
# return them to the page they were already on
|
||||
if button == "save":
|
||||
messages.success(request, "Your progress has been saved!")
|
||||
return self.goto(self.steps.current)
|
||||
# otherwise, proceed as normal
|
||||
return self.goto_next_step()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue