aboutsummaryrefslogtreecommitdiffstats
path: root/perllib
diff options
context:
space:
mode:
Diffstat (limited to 'perllib')
-rw-r--r--perllib/FixMyStreet/App/Controller/Admin.pm4
-rw-r--r--perllib/FixMyStreet/DB/Result/Open311conf.pm10
-rw-r--r--perllib/Open311/GetServiceRequestUpdates.pm16
3 files changed, 27 insertions, 3 deletions
diff --git a/perllib/FixMyStreet/App/Controller/Admin.pm b/perllib/FixMyStreet/App/Controller/Admin.pm
index d11f1645e..d6f613fd3 100644
--- a/perllib/FixMyStreet/App/Controller/Admin.pm
+++ b/perllib/FixMyStreet/App/Controller/Admin.pm
@@ -339,7 +339,7 @@ sub update_contacts : Private {
} elsif ( $posted eq 'open311' ) {
$c->forward('check_token');
- my %params = map { $_ => $c->req->param($_) } qw/open311_id endpoint jurisdiction api_key area_id send_method send_comments comment_user_id/;
+ my %params = map { $_ => $c->req->param($_) } qw/open311_id endpoint jurisdiction api_key area_id send_method send_comments suppress_alerts comment_user_id/;
if ( $params{open311_id} ) {
my $conf = $c->model('DB::Open311Conf')->find( { id => $params{open311_id} } );
@@ -349,6 +349,7 @@ sub update_contacts : Private {
$conf->api_key( $params{api_key} );
$conf->send_method( $params{send_method} );
$conf->send_comments( $params{send_comments} );
+ $conf->suppress_alerts( $params{suppress_alerts} );
$conf->comment_user_id( $params{comment_user_id} || undef );
$conf->update();
@@ -362,6 +363,7 @@ sub update_contacts : Private {
$conf->api_key( $params{api_key} );
$conf->send_method( $params{send_method} );
$conf->send_comments( $params{send_comments} );
+ $conf->suppress_alerts( $params{suppress_alerts} );
$conf->comment_user_id( $params{comment_user_id} || undef );
$conf->insert();
diff --git a/perllib/FixMyStreet/DB/Result/Open311conf.pm b/perllib/FixMyStreet/DB/Result/Open311conf.pm
index b9cd432ee..d040cd44b 100644
--- a/perllib/FixMyStreet/DB/Result/Open311conf.pm
+++ b/perllib/FixMyStreet/DB/Result/Open311conf.pm
@@ -32,6 +32,12 @@ __PACKAGE__->add_columns(
{ data_type => "boolean", default_value => \"false", is_nullable => 0 },
"comment_user_id",
{ data_type => "integer", is_foreign_key => 1, is_nullable => 1 },
+ "username",
+ { data_type => "text", is_nullable => 1 },
+ "password",
+ { data_type => "text", is_nullable => 1 },
+ "suppress_alerts",
+ { data_type => "boolean", default_value => \"false", is_nullable => 0 },
);
__PACKAGE__->set_primary_key("id");
__PACKAGE__->add_unique_constraint("open311conf_area_id_key", ["area_id"]);
@@ -48,8 +54,8 @@ __PACKAGE__->belongs_to(
);
-# Created by DBIx::Class::Schema::Loader v0.07017 @ 2012-03-26 17:03:34
-# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:fC6Ws8p/pXyjgqfm2LRKsw
+# Created by DBIx::Class::Schema::Loader v0.07017 @ 2012-05-11 13:07:38
+# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:Mckkx2rjx9ug3+HaXKzw5g
# You can replace this text with custom code or comments, and it will be preserved on regeneration
diff --git a/perllib/Open311/GetServiceRequestUpdates.pm b/perllib/Open311/GetServiceRequestUpdates.pm
index b656da879..b5577ff6c 100644
--- a/perllib/Open311/GetServiceRequestUpdates.pm
+++ b/perllib/Open311/GetServiceRequestUpdates.pm
@@ -9,6 +9,7 @@ has council_list => ( is => 'ro' );
has system_user => ( is => 'rw' );
has start_date => ( is => 'ro', default => undef );
has end_date => ( is => 'ro', default => undef );
+has suppress_alerts => ( is => 'rw', default => 0 );
sub fetch {
my $self = shift;
@@ -30,6 +31,7 @@ sub fetch {
jurisdiction => $council->jurisdiction,
);
+ $self->suppress_alerts( $council->suppress_alerts );
$self->system_user( $council->comment_user );
$self->update_comments( $o, { areaid => $council->area_id }, );
}
@@ -110,6 +112,20 @@ sub update_comments {
}
$comment->insert();
+
+ if ( $self->suppress_alerts ) {
+ my $alert = FixMyStreet::App->model('DB::Alert')->find( {
+ alert_type => 'new_updates',
+ parameter => $p->id,
+ confirmed => 1,
+ user_id => $p->user->id,
+ } );
+
+ my $alerts_sent = FixMyStreet::App->model('DB::AlertSent')->find_or_create( {
+ alert_id => $alert->id,
+ parameter => $comment->id,
+ } );
+ }
}
}
}