diff options
-rw-r--r-- | perllib/FixMyStreet/App/Controller/Report/New.pm | 24 | ||||
-rw-r--r-- | perllib/FixMyStreet/Cobrand/Bromley.pm | 28 | ||||
-rw-r--r-- | perllib/FixMyStreet/Cobrand/Default.pm | 2 | ||||
-rw-r--r-- | perllib/FixMyStreet/Cobrand/FixMyStreet.pm | 26 |
4 files changed, 57 insertions, 23 deletions
diff --git a/perllib/FixMyStreet/App/Controller/Report/New.pm b/perllib/FixMyStreet/App/Controller/Report/New.pm index 003de943d..7b630d36f 100644 --- a/perllib/FixMyStreet/App/Controller/Report/New.pm +++ b/perllib/FixMyStreet/App/Controller/Report/New.pm @@ -797,29 +797,7 @@ sub process_report : Private { }; } - if ( $contacts[0]->area_id == 2482 ) { - for my $field ( qw/ fms_extra_title first_name last_name / ) { - my $value = $c->request->param( $field ); - next if ( - $c->cobrand->moniker ne 'bromley' && - ( $field eq 'first_name' || $field eq 'last_name' ) - ); - - if ( !$value ) { - $c->stash->{field_errors}->{ $field } = _('This information is required'); - } - push @extra, { - name => $field, - description => uc( $field), - value => $value || '', - }; - } - - if ( $c->request->param('fms_extra_title') ) { - $c->stash->{fms_extra_title} = $c->request->param('fms_extra_title'); - $c->stash->{extra_name_info} = 1; - } - } + $c->cobrand->process_extras( $c, \@contacts, \@extra ); if ( @extra ) { $c->stash->{report_meta} = \@extra; diff --git a/perllib/FixMyStreet/Cobrand/Bromley.pm b/perllib/FixMyStreet/Cobrand/Bromley.pm index 75174b638..90661c0c3 100644 --- a/perllib/FixMyStreet/Cobrand/Bromley.pm +++ b/perllib/FixMyStreet/Cobrand/Bromley.pm @@ -31,5 +31,33 @@ sub example_places { return ( 'BR1 3UH', 'Glebe Rd, Bromley' ); } +sub process_extras { + my $self = shift; + my $ctx = shift; + my $contacts = shift; + my $extra = shift; + + for my $field (qw/ fms_extra_title first_name last_name /) { + my $value = $ctx->request->param($field); + + if ( !$value ) { + $ctx->stash->{field_errors}->{$field} = + _('This information is required'); + } + push @$extra, + { + name => $field, + description => uc($field), + value => $value || '', + }; + } + + if ( $ctx->request->param('fms_extra_title') ) { + $ctx->stash->{fms_extra_title} = + $ctx->request->param('fms_extra_title'); + $ctx->stash->{extra_name_info} = 1; + } +} + 1; diff --git a/perllib/FixMyStreet/Cobrand/Default.pm b/perllib/FixMyStreet/Cobrand/Default.pm index c45c36b0b..77518e142 100644 --- a/perllib/FixMyStreet/Cobrand/Default.pm +++ b/perllib/FixMyStreet/Cobrand/Default.pm @@ -920,5 +920,7 @@ sub example_places { return [ 'B2 4QA', 'Tib St, Manchester' ]; } +sub process_extras {} + 1; diff --git a/perllib/FixMyStreet/Cobrand/FixMyStreet.pm b/perllib/FixMyStreet/Cobrand/FixMyStreet.pm index 97b4c3c8b..c971a5a82 100644 --- a/perllib/FixMyStreet/Cobrand/FixMyStreet.pm +++ b/perllib/FixMyStreet/Cobrand/FixMyStreet.pm @@ -32,5 +32,31 @@ sub generate_problem_banner { return $banner; } +sub process_extras { + my $self = shift; + my $ctx = shift; + my $contacts = shift; + my $extra = shift; + + if ( $contacts->[0]->area_id == 2482 ) { + for my $field ( qw/ fms_extra_title / ) { + my $value = $ctx->request->param( $field ); + + if ( !$value ) { + $ctx->stash->{field_errors}->{ $field } = _('This information is required'); + } + push @$extra, { + name => $field, + description => uc( $field), + value => $value || '', + }; + } + + if ( $ctx->request->param('fms_extra_title') ) { + $ctx->stash->{fms_extra_title} = $ctx->request->param('fms_extra_title'); + $ctx->stash->{extra_name_info} = 1; + } + } +} 1; |