Skip to content

Commit 18bea68

Browse files
reCAPTCHA: Add reCAPTCHA text, hide flag on Elig Index, Elig Confirm (#2586)
2 parents 1561cb5 + 69b7cc8 commit 18bea68

File tree

8 files changed

+99
-53
lines changed

8 files changed

+99
-53
lines changed

benefits/core/templates/core/includes/form.html

Lines changed: 30 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -3,41 +3,39 @@
33

44
{% url form.action_url as form_action %}
55

6-
<form id="{{ form.id }}" action="{{ form_action }}" method="{{ form.method | default:"post" | upper }}" role="form">
6+
<form id="{{ form.id }}"
7+
class="{{ form.classes }}"
8+
action="{{ form_action }}"
9+
method="{{ form.method | default:"post" | upper }}"
10+
role="form">
711
{% csrf_token %}
812

9-
<div class="row form-container justify-content-center">
10-
<div class="{{ form.classes }}">
11-
{% for field in form %}
12-
<div class="row form-group mb-0">
13-
<div class="col-12">
14-
{# djlint:off #}
15-
{% if field.label %}
16-
<label for="{{ field.id_for_label }}" class="form-control-label">{{ field.label }}{% if field.field.required %}<span class="required-label text-body">*</span>{% endif %}
17-
</label>
18-
{% endif %}
19-
{# djlint:on #}
20-
21-
{{ field }}
22-
23-
{% if field.help_text %}<small class="d-block mt-2 pt-1 form-text text-body">{{ field.help_text }}</small>{% endif %}
24-
</div>
25-
</div>
26-
{% endfor %}
27-
</div>
13+
<div class="form-field-container d-flex flex-column gap-4">
14+
{% for field in form %}
15+
<div class="form-group mb-0">
16+
{# djlint:off #}
17+
{% if field.label %}
18+
<label for="{{ field.id_for_label }}" class="form-control-label">{{ field.label }}{% if field.field.required %}<span class="required-label text-body">*</span>{% endif %}
19+
</label>
20+
{% endif %}
21+
{# djlint:on #}
22+
23+
{{ field }}
24+
25+
{% if field.help_text %}<small class="d-block mt-2 pt-1 form-text text-body">{{ field.help_text }}</small>{% endif %}
26+
</div>
27+
{% endfor %}
2828
</div>
2929

3030
{% if form.submit_value %}
31-
<div class="row d-flex justify-content-center pt-8">
32-
<div class="col-lg-6">
33-
<button class="btn btn-lg btn-primary spinner-hidden d-flex justify-content-center align-items-center"
34-
data-action="submit"
35-
type="submit"
36-
form="{{ form.id }}">
37-
<span class="btn-text">{{ form.submit_value }}</span>
38-
<span class="spinner-border spinner-border-sm"></span>
39-
</button>
40-
</div>
31+
<div class="pt-8">
32+
<button class="btn btn-lg btn-primary spinner-hidden d-flex justify-content-center align-items-center"
33+
data-action="submit"
34+
type="submit"
35+
form="{{ form.id }}">
36+
<span class="btn-text">{{ form.submit_value }}</span>
37+
<span class="spinner-border spinner-border-sm"></span>
38+
</button>
4139
</div>
4240
{% endif %}
4341

@@ -94,6 +92,8 @@
9492
{% endcomment %}
9593
<input type="hidden" name="{{ request.recaptcha.data_field }}" value="">
9694

95+
<div class="pt-8">{% include "core/includes/recaptcha-text.html" %}</div>
96+
9797
<script nonce="{{ request.csp_nonce }}">
9898
function recaptchaSubmit($event) {
9999
// checks the validity of the form. Return if invalid; HTML5 validation errors should display
@@ -121,6 +121,5 @@
121121
$("button[type=submit]", "#{{ form.id }}").on("click", recaptchaSubmit);
122122
</script>
123123
{% endif %}
124-
125124
</form>
126125
{% endif %}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{% load i18n %}
2+
3+
<p class="form-text text-body mt-0">
4+
{% blocktranslate trimmed %}
5+
This site is protected by reCAPTCHA and the Google <a href="https://policies.google.com/privacy" target="_blank" rel="noopener noreferrer">Privacy Policy</a> and <a href="https://policies.google.com/terms" target="_blank" rel="noopener noreferrer">Terms of Service</a> apply.
6+
{% endblocktranslate %}
7+
</p>

benefits/eligibility/forms.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ def __init__(self, agency: models.TransitAgency, *args, **kwargs):
2828
super().__init__(*args, **kwargs)
2929
flows = agency.enrollment_flows.filter(supported_enrollment_methods__contains=models.EnrollmentMethods.DIGITAL)
3030

31-
self.classes = "col-lg-6"
3231
# second element is not used since we render the whole label using selection_label_template,
3332
# therefore set to None
3433
flow_field = self.fields["flow"]
@@ -110,7 +109,6 @@ def __init__(
110109
self.headline = headline
111110
self.blurb = blurb
112111

113-
self.classes = "col-lg-6"
114112
sub_widget = widgets.FormControlTextInput(placeholder=sub_placeholder)
115113
if sub_pattern:
116114
sub_widget.attrs.update({"pattern": sub_pattern})

benefits/eligibility/templates/eligibility/confirm.html

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,11 @@ <h1>{{ form.headline }}</h1>
2626
{% endblock explanatory-text-wrapper %}
2727

2828
{% block inner-content %}
29-
<div class="container">
30-
<div class="row">{% include "core/includes/form.html" with form=form %}</div>
29+
<div class="row justify-content-center">
30+
<div class="col-lg-6">{% include "core/includes/form.html" with form=form %}</div>
3131
</div>
3232
{% endblock inner-content %}
33+
34+
{% comment %} Override with empty block to prevent rendering empty divs {% endcomment %}
35+
{% block call-to-action %}
36+
{% endblock call-to-action %}

benefits/eligibility/templates/eligibility/index.html

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,9 @@ <h1>{% translate "Choose the transit benefit you would like to enroll in" %}</h1
3030
{% endblock explanatory-text-wrapper %}
3131

3232
{% block inner-content %}
33-
{% include "core/includes/form.html" with form=form %}
33+
<div class="row justify-content-center">
34+
<div class="col-lg-6">{% include "core/includes/form.html" with form=form %}</div>
35+
</div>
3436
<script nonce="{{ request.csp_nonce }}">
3537
$(".modal").on("click", function(event) {
3638
if (!(event.target instanceof HTMLAnchorElement)) {
@@ -40,3 +42,7 @@ <h1>{% translate "Choose the transit benefit you would like to enroll in" %}</h1
4042
});
4143
</script>
4244
{% endblock inner-content %}
45+
46+
{% comment %} Override with empty block to prevent rendering empty divs {% endcomment %}
47+
{% block call-to-action %}
48+
{% endblock call-to-action %}

benefits/locale/en/LC_MESSAGES/django.po

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -320,6 +320,14 @@ msgid ""
320320
"JavaScript. Please enable JavaScript for this website and"
321321
msgstr ""
322322

323+
msgid ""
324+
"This site is protected by reCAPTCHA and the Google <a href=\"https://"
325+
"policies.google.com/privacy\" target=\"_blank\" rel=\"noopener "
326+
"noreferrer\">Privacy Policy</a> and <a href=\"https://policies.google.com/"
327+
"terms\" target=\"_blank\" rel=\"noopener noreferrer\">Terms of Service</a> "
328+
"apply."
329+
msgstr ""
330+
323331
msgid "Get a reduced fare on CST public transportation when you tap to ride"
324332
msgstr ""
325333

benefits/locale/es/LC_MESSAGES/django.po

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -434,6 +434,19 @@ msgstr ""
434434
"Para funcionar correctamente, este sitio web requiere un navegador que "
435435
"admita JavaScript. Por favor, active JavaScript por este sitio web y"
436436

437+
msgid ""
438+
"This site is protected by reCAPTCHA and the Google <a href=\"https://"
439+
"policies.google.com/privacy\" target=\"_blank\" rel=\"noopener "
440+
"noreferrer\">Privacy Policy</a> and <a href=\"https://policies.google.com/"
441+
"terms\" target=\"_blank\" rel=\"noopener noreferrer\">Terms of Service</a> "
442+
"apply."
443+
msgstr ""
444+
"Este sitio está protegido por reCAPTCHA y se aplican la <a href=\"https://"
445+
"policies.google.com/privacy\" target=\"_blank\" rel=\"noopener "
446+
"noreferrer\">Política de privacidad</a> y <a href=\"https://policies.google."
447+
"com/terms\" target=\"_blank\" rel=\"noopener noreferrer\">las Condiciones de "
448+
"servicio</a> de Google."
449+
437450
msgid "Get a reduced fare on CST public transportation when you tap to ride"
438451
msgstr ""
439452
"Obtenga una tarifa reducida en el transporte público CST cuando toque para "

benefits/static/css/styles.css

Lines changed: 28 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,11 @@ html {
1414
scroll-padding-top: 101px; /* Header Height (80px) + Skip Nav Height (21px) = 101px */
1515
}
1616

17+
/* reCAPTCHA: Do not display badge */
18+
.grecaptcha-badge {
19+
display: none;
20+
}
21+
1722
body {
1823
font-size: 100%;
1924
color: var(--text-primary-color);
@@ -53,6 +58,8 @@ li {
5358
margin: 0;
5459
}
5560

61+
/* Utility Classes */
62+
5663
@media (min-width: 992px) {
5764
/* Utility Class: Padding bottom 64px on Desktop */
5865
/* Pair with pb-4 on Form pages to get 24px on Mobile, 64px on Desktop */
@@ -106,6 +113,11 @@ a:visited:not(.btn) {
106113
color: var(--selected-color);
107114
}
108115

116+
:root {
117+
--external-link-icon-size: var(--font-size-24px);
118+
--external-link-icon-size-small: var(--font-size-18px);
119+
}
120+
109121
a[target="_blank"]::after {
110122
content: " ";
111123
background-color: currentColor;
@@ -119,12 +131,19 @@ a[target="_blank"]::after {
119131

120132
display: inline-block;
121133
position: relative;
122-
width: 24px;
123-
height: 24px;
134+
width: var(--external-link-icon-size);
135+
height: var(--external-link-icon-size);
124136
margin-left: 2px;
125137
vertical-align: text-bottom;
126138
}
127139

140+
.form-text a[target="_blank"]::after {
141+
width: var(--external-link-icon-size-small);
142+
height: var(--external-link-icon-size-small);
143+
mask-size: contain;
144+
-webkit-mask-size: contain;
145+
}
146+
128147
/* Headlines */
129148
/* All headlines */
130149
h1,
@@ -513,26 +532,18 @@ footer .footer-links li a.footer-link:visited {
513532
}
514533

515534
/* Forms: Text Inputs */
516-
/* Form Container: Must use .form-container parent to use these styles */
517-
518-
:root {
519-
--form-input-gap: calc(24rem / 16);
520-
}
535+
/* Form Field Container: Must use .form-field-container parent to use these styles */
521536

522-
.form-container .form-group:not(:first-child) {
523-
padding-top: var(--form-input-gap);
524-
}
525-
526-
.form-container .form-control-label,
527-
.form-container .required-label {
537+
.form-field-container .form-control-label,
538+
.form-field-container .required-label {
528539
font-size: var(--font-size-16px);
529540
font-weight: var(--medium-font-weight);
530541
line-height: var(--form-field-text-line-height);
531542
letter-spacing: calc(var(--font-size-16px) * var(--letter-spacing-5));
532543
padding-bottom: calc(12rem / 16);
533544
}
534545

535-
.form-container .form-control {
546+
.form-field-container .form-control {
536547
border-width: var(--border-width);
537548
border-radius: var(--border-radius);
538549
border-color: var(--primary-color);
@@ -542,8 +553,8 @@ footer .footer-links li a.footer-link:visited {
542553
/* Input height should be 60px */
543554
}
544555

545-
.form-container .form-control:focus,
546-
.form-container .form-control:focus-visible {
556+
.form-field-container .form-control:focus,
557+
.form-field-container .form-control:focus-visible {
547558
outline: 3px solid var(--focus-color) !important;
548559
outline-offset: 2px !important;
549560
box-shadow: none !important;
@@ -552,7 +563,7 @@ footer .footer-links li a.footer-link:visited {
552563
.form-text {
553564
font-size: var(--font-size-14px);
554565
line-height: var(--form-field-text-line-height);
555-
letter-spacing: var(--letter-spacing-5);
566+
letter-spacing: calc(var(--font-size-14px) * var(--letter-spacing-5));
556567
}
557568

558569
/* Forms: Radio Buttons */

0 commit comments

Comments
 (0)