aboutsummaryrefslogtreecommitdiffstats
path: root/perllib
diff options
context:
space:
mode:
authorStruan Donald <struan@exo.org.uk>2014-04-09 17:09:14 +0100
committerStruan Donald <struan@exo.org.uk>2014-04-15 15:53:18 +0100
commit565c6498aefea0fd39ec7453019bbf86b52672dd (patch)
treefa11d5c90de95202da33086a56285b6a348aee88 /perllib
parentb82228ce014cc87866d976eeb3ce6e454e87c336 (diff)
Add a who are you trying to contact option to contact form
In order to try and cut down on people mistakingly using this form to try and contact their council all some 'who are you trying to contact' options to the form that display appropriate messaged unless the 'FMS team option is selected. Add the validation code for this in the cobrand module. Fixes #41
Diffstat (limited to 'perllib')
-rw-r--r--perllib/FixMyStreet/App/Controller/Contact.pm5
-rw-r--r--perllib/FixMyStreet/Cobrand/Default.pm8
-rw-r--r--perllib/FixMyStreet/Cobrand/FixMyStreet.pm18
3 files changed, 31 insertions, 0 deletions
diff --git a/perllib/FixMyStreet/App/Controller/Contact.pm b/perllib/FixMyStreet/App/Controller/Contact.pm
index 7ba18ed2d..6bc6e90ef 100644
--- a/perllib/FixMyStreet/App/Controller/Contact.pm
+++ b/perllib/FixMyStreet/App/Controller/Contact.pm
@@ -108,6 +108,11 @@ sub validate : Private {
if !mySociety::EmailUtil::is_valid_email( $c->req->param('em') );
}
+ %field_errors = (
+ %field_errors,
+ $c->cobrand->extra_contact_validation($c)
+ );
+
push @errors, _('Illegal ID')
if $c->req->param('id') && $c->req->param('id') !~ /^[1-9]\d*$/
or $c->req->param('update_id')
diff --git a/perllib/FixMyStreet/Cobrand/Default.pm b/perllib/FixMyStreet/Cobrand/Default.pm
index 2de3eae5f..599ed5987 100644
--- a/perllib/FixMyStreet/Cobrand/Default.pm
+++ b/perllib/FixMyStreet/Cobrand/Default.pm
@@ -844,6 +844,14 @@ sub prettify_dt {
return Utils::prettify_dt( $dt, 1 );
}
+=head2 extra_contact_validation
+
+Perform any extra validation on the contact form.
+
+=cut
+
+sub extra_contact_validation { (); }
+
sub problem_as_hashref {
my $self = shift;
my $problem = shift;
diff --git a/perllib/FixMyStreet/Cobrand/FixMyStreet.pm b/perllib/FixMyStreet/Cobrand/FixMyStreet.pm
index c3a1f9d9d..ce62e206e 100644
--- a/perllib/FixMyStreet/Cobrand/FixMyStreet.pm
+++ b/perllib/FixMyStreet/Cobrand/FixMyStreet.pm
@@ -21,5 +21,23 @@ sub title_list {
return undef;
}
+sub extra_contact_validation {
+ my $self = shift;
+ my $c = shift;
+
+ my %errors;
+
+ $c->stash->{dest} = $c->req->param('dest');
+
+ $errors{dest} = "Please enter who your message is for"
+ unless $c->req->param('dest');
+
+ if ( $c->req->param('dest') eq 'council' || $c->req->param('dest') eq 'update' ) {
+ $errors{not_for_us} = 1;
+ }
+
+ return %errors;
+}
+
1;