diff options
Diffstat (limited to 'perllib/FixMyStreet/App/Controller/Report/Update.pm')
-rw-r--r-- | perllib/FixMyStreet/App/Controller/Report/Update.pm | 31 |
1 files changed, 20 insertions, 11 deletions
diff --git a/perllib/FixMyStreet/App/Controller/Report/Update.pm b/perllib/FixMyStreet/App/Controller/Report/Update.pm index 5b0dad170..3a2b40c2c 100644 --- a/perllib/FixMyStreet/App/Controller/Report/Update.pm +++ b/perllib/FixMyStreet/App/Controller/Report/Update.pm @@ -201,13 +201,16 @@ sub process_update : Private { $update->problem_state( $params{state} ); } + my @extra; # Next function fills this, but we don't need it here. + # This is just so that the error checkign for these extra fields runs. + # TODO Use extra here as it is used on reports. + $c->cobrand->process_extras( $c, $update->problem->council, \@extra ); + if ( $c->req->param('fms_extra_title') ) { my %extras = (); $extras{title} = $c->req->param('fms_extra_title'); - $extras{email_alerts_required} = $c->req->param('add_alert'); + $extras{email_alerts_requested} = $c->req->param('add_alert'); $update->extra( \%extras ); - - $c->stash->{fms_extra_title} = $c->req->param('fms_extra_title'); } if ( $c->stash->{ first_name } && $c->stash->{ last_name } ) { @@ -392,14 +395,20 @@ sub signup_for_alerts : Private { if ( $c->stash->{add_alert} ) { my $update = $c->stash->{update}; - my $alert = $c->model('DB::Alert')->find_or_create( - user => $update->user, - alert_type => 'new_updates', - parameter => $update->problem_id, - cobrand => $update->cobrand, - cobrand_data => $update->cobrand_data, - lang => $update->lang, - ); + my $options = { + user => $update->user, + alert_type => 'new_updates', + parameter => $update->problem_id, + }; + my $alert = $c->model('DB::Alert')->find($options); + unless ($alert) { + $alert = $c->model('DB::Alert')->create({ + %$options, + cobrand => $update->cobrand, + cobrand_data => $update->cobrand_data, + lang => $update->lang, + }); + } $alert->confirm(); } elsif ( $c->user && ( my $alert = $c->user->alert_for_problem($c->stash->{update}->problem_id) ) ) { |