aboutsummaryrefslogtreecommitdiffstats
path: root/perllib/FixMyStreet/App/Controller/Report/Update.pm
diff options
context:
space:
mode:
authorDave Whiteland <dave@mysociety.org>2012-06-25 14:33:57 +0100
committerDave Whiteland <dave@mysociety.org>2012-06-25 14:33:57 +0100
commitf9fe02f91ac72ea2954ee68a5f32d96a237fcd67 (patch)
treef91d63ab3d6b9cd3555587090a541c870ecd3363 /perllib/FixMyStreet/App/Controller/Report/Update.pm
parent67da8efc720d2d0bd22bd9fe8655b7e983b35bb4 (diff)
parent45b3040884d7089e7d8c6f4acccd657b91c92a04 (diff)
Merge branch 'master' into fmb-read-only
Conflicts: .gitignore bin/make_css perllib/FixMyStreet/Cobrand/FixMyStreet.pm
Diffstat (limited to 'perllib/FixMyStreet/App/Controller/Report/Update.pm')
-rw-r--r--perllib/FixMyStreet/App/Controller/Report/Update.pm31
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) ) ) {