aboutsummaryrefslogtreecommitdiffstats
path: root/perllib
diff options
context:
space:
mode:
authorStruan Donald <struan@exo.org.uk>2014-04-17 10:06:28 +0100
committerStruan Donald <struan@exo.org.uk>2014-04-17 10:06:28 +0100
commit2edcbe06b98e0f1daa11173477b7a90a57efcdbc (patch)
tree7b8ba67246b743ae568bf215810e59dfe19db170 /perllib
parent0625dbe113dc88fe707ca1fb036bf0a580781e15 (diff)
parent565c6498aefea0fd39ec7453019bbf86b52672dd (diff)
Merge branch 'improve-contact-form'
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 d2af4949e..c8bae90e6 100644
--- a/perllib/FixMyStreet/Cobrand/Default.pm
+++ b/perllib/FixMyStreet/Cobrand/Default.pm
@@ -854,6 +854,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;