aboutsummaryrefslogtreecommitdiffstats
path: root/perllib/FixMyStreet
diff options
context:
space:
mode:
Diffstat (limited to 'perllib/FixMyStreet')
-rw-r--r--perllib/FixMyStreet/Cobrand/Bromley.pm19
-rw-r--r--perllib/FixMyStreet/Cobrand/Buckinghamshire.pm5
-rw-r--r--perllib/FixMyStreet/Cobrand/Lewisham.pm15
-rw-r--r--perllib/FixMyStreet/Cobrand/Oxfordshire.pm13
-rw-r--r--perllib/FixMyStreet/DB/Result/Comment.pm20
-rw-r--r--perllib/FixMyStreet/DB/Result/Problem.pm10
-rw-r--r--perllib/FixMyStreet/Script/Questionnaires.pm2
-rw-r--r--perllib/FixMyStreet/Script/Reports.pm2
-rw-r--r--perllib/FixMyStreet/SendReport/Email.pm2
9 files changed, 80 insertions, 8 deletions
diff --git a/perllib/FixMyStreet/Cobrand/Bromley.pm b/perllib/FixMyStreet/Cobrand/Bromley.pm
index a6d58504c..e1021eda9 100644
--- a/perllib/FixMyStreet/Cobrand/Bromley.pm
+++ b/perllib/FixMyStreet/Cobrand/Bromley.pm
@@ -165,5 +165,24 @@ sub open311_config {
$params->{extended_description} = 0;
}
+sub open311_config_updates {
+ my ($self, $params) = @_;
+ $params->{use_extended_updates} = 1;
+ $params->{endpoints} = {
+ service_request_updates => 'update.xml',
+ update => 'update.xml'
+ };
+}
+
+sub open311_pre_send {
+ my ($self, $row, $open311) = @_;
+
+ my $extra = $row->extra || {};
+ unless ( $extra->{title} ) {
+ $extra->{title} = $row->user->title;
+ $row->extra( $extra );
+ }
+}
+
1;
diff --git a/perllib/FixMyStreet/Cobrand/Buckinghamshire.pm b/perllib/FixMyStreet/Cobrand/Buckinghamshire.pm
index 783a565f1..fb074da85 100644
--- a/perllib/FixMyStreet/Cobrand/Buckinghamshire.pm
+++ b/perllib/FixMyStreet/Cobrand/Buckinghamshire.pm
@@ -100,6 +100,11 @@ sub open311_post_send {
$sender->send($row, $h);
}
+sub open311_config_updates {
+ my ($self, $params) = @_;
+ $params->{mark_reopen} = 1;
+}
+
sub map_type { 'Buckinghamshire' }
sub default_map_zoom { 3 }
diff --git a/perllib/FixMyStreet/Cobrand/Lewisham.pm b/perllib/FixMyStreet/Cobrand/Lewisham.pm
new file mode 100644
index 000000000..325f6e833
--- /dev/null
+++ b/perllib/FixMyStreet/Cobrand/Lewisham.pm
@@ -0,0 +1,15 @@
+package FixMyStreet::Cobrand::Lewisham;
+use base 'FixMyStreet::Cobrand::UK';
+
+use strict;
+use warnings;
+
+sub council_area_id { 2492 }
+
+sub open311_post_update_skip {
+ my ($self) = @_;
+ return 1;
+}
+
+1;
+
diff --git a/perllib/FixMyStreet/Cobrand/Oxfordshire.pm b/perllib/FixMyStreet/Cobrand/Oxfordshire.pm
index f03f1b605..4d627c756 100644
--- a/perllib/FixMyStreet/Cobrand/Oxfordshire.pm
+++ b/perllib/FixMyStreet/Cobrand/Oxfordshire.pm
@@ -171,6 +171,19 @@ sub open311_config {
$params->{extended_description} = 'oxfordshire';
}
+sub open311_config_updates {
+ my ($self, $params) = @_;
+ $params->{use_customer_reference} = 1;
+}
+
+sub should_skip_sending_update {
+ my ($self, $update ) = @_;
+
+ # Oxfordshire stores the external id of the problem as a customer reference
+ # in metadata
+ return 1 if !$update->problem->get_extra_metadata('customer_reference');
+}
+
sub on_map_default_status { return 'open'; }
sub contact_email {
diff --git a/perllib/FixMyStreet/DB/Result/Comment.pm b/perllib/FixMyStreet/DB/Result/Comment.pm
index b4e42b456..d27c5ea8c 100644
--- a/perllib/FixMyStreet/DB/Result/Comment.pm
+++ b/perllib/FixMyStreet/DB/Result/Comment.pm
@@ -115,6 +115,26 @@ my $stz = sub {
around created => $stz;
around confirmed => $stz;
+=head2 get_cobrand_logged
+
+Get a cobrand object for the cobrand the update was made on.
+
+e.g. if an update was logged at www.fixmystreet.com, this will be a
+FixMyStreet::Cobrand::FixMyStreet object.
+
+=cut
+
+has get_cobrand_logged => (
+ is => 'ro',
+ lazy => 1,
+ default => sub {
+ my $self = shift;
+ my $cobrand_class = FixMyStreet::Cobrand->get_class_for_moniker( $self->cobrand );
+ return $cobrand_class->new;
+ },
+);
+
+
# You can replace this text with custom code or comments, and it will be preserved on regeneration
sub check_for_errors {
diff --git a/perllib/FixMyStreet/DB/Result/Problem.pm b/perllib/FixMyStreet/DB/Result/Problem.pm
index 76a6f72fb..2192158d3 100644
--- a/perllib/FixMyStreet/DB/Result/Problem.pm
+++ b/perllib/FixMyStreet/DB/Result/Problem.pm
@@ -780,7 +780,7 @@ sub duration_string {
sub local_coords {
my $self = shift;
- my $cobrand = FixMyStreet::Cobrand->get_class_for_moniker($self->cobrand)->new;
+ my $cobrand = $self->get_cobrand_logged;
if ($cobrand->moniker eq 'zurich') {
my ($x, $y) = Geo::Coordinates::CH1903Plus::from_latlon($self->latitude, $self->longitude);
return ( int($x+0.5), int($y+0.5) );
@@ -896,8 +896,9 @@ sub updates_sent_to_body {
return unless $self->send_method_used && $self->send_method_used eq 'Open311';
# Some bodies only send updates *to* FMS, they don't receive updates.
- # NB See also the list in bin/send-comments
- my $excluded = qr{Lewisham|Oxfordshire};
+ my $cobrand = $self->get_cobrand_logged;
+ my $handler = $cobrand->call_hook(get_body_handler_for_problem => $self);
+ return 0 if $handler && $handler->call_hook('open311_post_update_skip');
my @bodies = values %{ $self->bodies };
my @updates_sent = grep {
@@ -905,8 +906,7 @@ sub updates_sent_to_body {
(
$_->send_method eq 'Open311' ||
$_->send_method eq 'Noop' # Sending might be temporarily disabled
- ) &&
- !($_->name =~ /$excluded/)
+ )
} @bodies;
return scalar @updates_sent;
}
diff --git a/perllib/FixMyStreet/Script/Questionnaires.pm b/perllib/FixMyStreet/Script/Questionnaires.pm
index d89f1bcf8..bcdaa06d6 100644
--- a/perllib/FixMyStreet/Script/Questionnaires.pm
+++ b/perllib/FixMyStreet/Script/Questionnaires.pm
@@ -43,7 +43,7 @@ sub send_questionnaires_period {
while (my $row = $unsent->next) {
- my $cobrand = FixMyStreet::Cobrand->get_class_for_moniker($row->cobrand)->new();
+ my $cobrand = $row->get_cobrand_logged;
$cobrand->set_lang_and_domain($row->lang, 1);
FixMyStreet::Map::set_map_class($cobrand->map_type);
diff --git a/perllib/FixMyStreet/Script/Reports.pm b/perllib/FixMyStreet/Script/Reports.pm
index 87f9fd124..dd8f4e370 100644
--- a/perllib/FixMyStreet/Script/Reports.pm
+++ b/perllib/FixMyStreet/Script/Reports.pm
@@ -44,7 +44,7 @@ sub send(;$) {
debug_print("starting to loop through unsent problem reports...") if $debug_mode;
while (my $row = $unsent->next) {
- my $cobrand = FixMyStreet::Cobrand->get_class_for_moniker($row->cobrand)->new();
+ my $cobrand = $row->get_cobrand_logged;
FixMyStreet::DB->schema->cobrand($cobrand);
if ($debug_mode) {
diff --git a/perllib/FixMyStreet/SendReport/Email.pm b/perllib/FixMyStreet/SendReport/Email.pm
index 4307694a1..1b484aefe 100644
--- a/perllib/FixMyStreet/SendReport/Email.pm
+++ b/perllib/FixMyStreet/SendReport/Email.pm
@@ -71,7 +71,7 @@ sub send {
}
my ($verbose, $nomail) = CronFns::options();
- my $cobrand = FixMyStreet::Cobrand->get_class_for_moniker($row->cobrand)->new();
+ my $cobrand = $row->get_cobrand_logged;
$cobrand = $cobrand->call_hook(get_body_handler_for_problem => $row) || $cobrand;
my $params = {