aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChris Mytton <self@hecticjeff.net>2013-09-12 09:49:39 +0100
committerChris Mytton <self@hecticjeff.net>2013-09-12 09:49:39 +0100
commit668e85086b7bfdf4a0ec99a2bd9d06476e7eb9e6 (patch)
tree1439a24308aa06d09cc932fd8eb7d9875d1ed71a
parent7fffbf2e562d9ede840c09f70e5495ac79890e4b (diff)
parent9727f3849c998216eb29ed2a7cbe78c85951e4b8 (diff)
Merge branch 'zurich-mandatory-telephone-number'
-rw-r--r--perllib/FixMyStreet/App/Controller/Report/New.pm3
-rw-r--r--t/cobrand/zurich.t11
-rw-r--r--templates/web/default/js/translation_strings.html3
-rw-r--r--templates/web/zurich/js/validation_rules.html8
-rw-r--r--templates/web/zurich/report/new/fill_in_details_form.html5
5 files changed, 27 insertions, 3 deletions
diff --git a/perllib/FixMyStreet/App/Controller/Report/New.pm b/perllib/FixMyStreet/App/Controller/Report/New.pm
index 3d3ddce1e..6018dfa80 100644
--- a/perllib/FixMyStreet/App/Controller/Report/New.pm
+++ b/perllib/FixMyStreet/App/Controller/Report/New.pm
@@ -956,6 +956,9 @@ sub check_for_errors : Private {
delete $field_errors{name};
my $report = $c->stash->{report};
$report->title( Utils::cleanup_text( substr($report->detail, 0, 25) ) );
+ if ( ! $c->req->param('phone') ) {
+ $field_errors{phone} = _("This information is required");
+ }
}
# FIXME: need to check for required bromley fields here
diff --git a/t/cobrand/zurich.t b/t/cobrand/zurich.t
index 721e6517a..69cf82db9 100644
--- a/t/cobrand/zurich.t
+++ b/t/cobrand/zurich.t
@@ -240,17 +240,24 @@ $mech->clear_emails_ok;
$mech->log_out_ok;
# Test only superuser can edit bodies
-$user = $mech->log_in_ok( 'dm1@example.org') ;
+$user = $mech->log_in_ok( 'dm1@example.org' );
$mech->get( '/admin/body/' . $zurich->id );
is $mech->res->code, 404, "only superuser should be able to edit bodies";
$mech->log_out_ok;
# Test only superuser can see "Add body" form
-$user = $mech->log_in_ok( 'dm1@example.org') ;
+$user = $mech->log_in_ok( 'dm1@example.org' );
$mech->get_ok( '/admin/bodies' );
$mech->content_lacks( '<form method="post" action="bodies"' );
$mech->log_out_ok;
+# Test phone number is mandatory
+$user = $mech->log_in_ok( 'dm1@example.org' );
+$mech->get_ok( '/report/new?latitude=51.500802;longitude=-0.143005' );
+$mech->submit_form( with_fields => { phone => "" } );
+$mech->content_contains( 'Diese Information wird ben&ouml;tigt' );
+$mech->log_out_ok;
+
$mech->delete_problems_for_body( 2 );
$mech->delete_user( 'dm1@example.org' );
$mech->delete_user( 'sdm1@example.org' );
diff --git a/templates/web/default/js/translation_strings.html b/templates/web/default/js/translation_strings.html
index f6c4f7d41..8f834a81c 100644
--- a/templates/web/default/js/translation_strings.html
+++ b/templates/web/default/js/translation_strings.html
@@ -15,6 +15,9 @@
required: '[% loc('Please enter your email') | replace("'", "\\'") %]',
email: '[% loc('Please enter a valid email') | replace("'", "\\'") %]'
},
+ phone: {
+ required: '[% loc('Please enter your phone number') | replace("'", "\\'") %]'
+ },
fms_extra_title: '[% loc('Please enter your title') | replace("'", "\\'") %]',
first_name: '[% loc('Please enter your first name') | replace("'", "\\'") %]',
last_name: '[% loc('Please enter your second name') | replace("'", "\\'") %]',
diff --git a/templates/web/zurich/js/validation_rules.html b/templates/web/zurich/js/validation_rules.html
new file mode 100644
index 000000000..d98bc1118
--- /dev/null
+++ b/templates/web/zurich/js/validation_rules.html
@@ -0,0 +1,8 @@
+ validation_rules = {
+ title: { required: true },
+ detail: { required: true },
+ email: { required: true },
+ update: { required: true },
+ phone: { required: true },
+ rznvy: { required: true }
+ };
diff --git a/templates/web/zurich/report/new/fill_in_details_form.html b/templates/web/zurich/report/new/fill_in_details_form.html
index 1cecf036d..076536601 100644
--- a/templates/web/zurich/report/new/fill_in_details_form.html
+++ b/templates/web/zurich/report/new/fill_in_details_form.html
@@ -103,7 +103,10 @@
[% END %]
<input type="text" value="[% report.name | html %]" name="name" id="form_name" placeholder="[% loc('Your name') %]">
- <label for="form_phone">[% loc('Phone number (optional)') %]</label>
+ <label for="form_phone">[% loc('Phone number') %]</label>
+ [% IF field_errors.phone %]
+ <p class='form-error'>[% field_errors.phone %]</p>
+ [% END %]
<input type="text" value="[% report.user.phone | html %]" name="phone" id="form_phone" placeholder="[% loc('Your phone number') %]">
<div class="form-txt-submit-box">