diff options
author | Struan Donald <struan@exo.org.uk> | 2012-12-03 11:55:14 +0000 |
---|---|---|
committer | Struan Donald <struan@exo.org.uk> | 2012-12-03 17:49:11 +0000 |
commit | d17fadea1c8eaaed02cd82106e93b83fd74515be (patch) | |
tree | 8b0470316104f0a758ea3cc44f76cee7067c110f | |
parent | 59b4cd804cf9134f830109bfc51fba3856a21ea3 (diff) |
move new report validation out to cobrand so we can over-ride this for
special cases without hard coding it into controller
-rw-r--r-- | perllib/FixMyStreet/App/Controller/Report/New.pm | 6 | ||||
-rw-r--r-- | perllib/FixMyStreet/Cobrand/Default.pm | 17 |
2 files changed, 18 insertions, 5 deletions
diff --git a/perllib/FixMyStreet/App/Controller/Report/New.pm b/perllib/FixMyStreet/App/Controller/Report/New.pm index dedd447ee..b2413d9e5 100644 --- a/perllib/FixMyStreet/App/Controller/Report/New.pm +++ b/perllib/FixMyStreet/App/Controller/Report/New.pm @@ -922,11 +922,7 @@ sub check_for_errors : Private { # let the model check for errors $c->stash->{field_errors} ||= {}; - my %field_errors = ( - %{ $c->stash->{field_errors} }, - %{ $c->stash->{report}->user->check_for_errors }, - %{ $c->stash->{report}->check_for_errors }, - ); + my %field_errors = $c->cobrand->report_check_for_errors( $c ); # FIXME: need to check for required bromley fields here diff --git a/perllib/FixMyStreet/Cobrand/Default.pm b/perllib/FixMyStreet/Cobrand/Default.pm index cc8f6c526..0401f58c3 100644 --- a/perllib/FixMyStreet/Cobrand/Default.pm +++ b/perllib/FixMyStreet/Cobrand/Default.pm @@ -739,5 +739,22 @@ until the contacts/area/body handling is rewritten to be better. sub reports_by_body { 0; } +=head2 report_check_for_errors + +Perform validation for new reports. Takes Catalyst context object as an argument + +=cut + +sub report_check_for_errors { + my $self = shift; + my $c = shift; + + return ( + %{ $c->stash->{field_errors} }, + %{ $c->stash->{report}->user->check_for_errors }, + %{ $c->stash->{report}->check_for_errors }, + ); +} + 1; |