aboutsummaryrefslogtreecommitdiffstats
path: root/perllib
diff options
context:
space:
mode:
authorM Somerville <matthew-github@dracos.co.uk>2020-10-05 14:16:42 +0100
committerM Somerville <matthew-github@dracos.co.uk>2020-11-11 10:31:33 +0000
commit2e1c10996a0a08b9bf50af05300fef5c253854e7 (patch)
tree4fc93f71dd6fc30fe784096603dcbcd35772ba6e /perllib
parent5e645b3e795e0d9a60425f0d8240c2263dc5a89d (diff)
[Bromley] Nuanced template resolution codes.
Have the response template external status code be a combination of resolution code, task type ID, and task state.
Diffstat (limited to 'perllib')
-rw-r--r--perllib/FixMyStreet/App/Controller/Admin/Templates.pm5
-rw-r--r--perllib/FixMyStreet/Cobrand/Bromley.pm22
-rw-r--r--perllib/Integrations/Echo.pm1
3 files changed, 25 insertions, 3 deletions
diff --git a/perllib/FixMyStreet/App/Controller/Admin/Templates.pm b/perllib/FixMyStreet/App/Controller/Admin/Templates.pm
index f933c5f8a..9fb401e2b 100644
--- a/perllib/FixMyStreet/App/Controller/Admin/Templates.pm
+++ b/perllib/FixMyStreet/App/Controller/Admin/Templates.pm
@@ -100,7 +100,10 @@ sub edit : Path : Args(2) {
$template->text( $c->get_param('text') );
$template->state( $c->get_param('state') );
- $template->external_status_code( $c->get_param('external_status_code') );
+
+ my $ext_code = $c->cobrand->call_hook('admin_templates_external_status_code_hook');
+ $ext_code ||= $c->get_param('external_status_code');
+ $template->external_status_code($ext_code);
if ( $template->state && $template->external_status_code ) {
$c->stash->{errors} ||= {};
diff --git a/perllib/FixMyStreet/Cobrand/Bromley.pm b/perllib/FixMyStreet/Cobrand/Bromley.pm
index c984f1728..e098815db 100644
--- a/perllib/FixMyStreet/Cobrand/Bromley.pm
+++ b/perllib/FixMyStreet/Cobrand/Bromley.pm
@@ -571,13 +571,20 @@ sub bin_services_for_address {
my $ref = join(',', @{$_->{Ref}{Value}{anyType}});
my $completed = construct_bin_date($_->{CompletedDate});
my $state = $_->{State}{Name} || '';
+ my $task_type_id = $_->{TaskTypeId} || '';
my $resolution = $_->{Resolution}{Name} || '';
my $resolution_id = $_->{Resolution}{Ref}{Value}{anyType};
if ($resolution_id) {
my $template = FixMyStreet::DB->resultset('ResponseTemplate')->search({
'me.body_id' => $self->body->id,
- 'me.external_status_code' => $resolution_id,
+ 'me.external_status_code' => [
+ "$resolution_id,$task_type_id,$state",
+ "$resolution_id,$task_type_id,",
+ "$resolution_id,,$state",
+ "$resolution_id,,",
+ $resolution_id,
+ ],
})->first;
$resolution = $template->text if $template;
}
@@ -803,7 +810,7 @@ sub construct_waste_open311_update {
description => $description,
status => $status,
update_id => 'waste',
- external_status_code => $resolution_id,
+ external_status_code => "$resolution_id,,",
};
}
@@ -866,4 +873,15 @@ sub waste_check_last_update {
return 1;
}
+sub admin_templates_external_status_code_hook {
+ my ($self) = @_;
+ my $c = $self->{c};
+
+ my $res_code = $c->get_param('resolution_code') || '';
+ my $task_type = $c->get_param('task_type') || '';
+ my $task_state = $c->get_param('task_state') || '';
+
+ return "$res_code,$task_type,$task_state";
+}
+
1;
diff --git a/perllib/Integrations/Echo.pm b/perllib/Integrations/Echo.pm
index 5878cdfa1..0216240da 100644
--- a/perllib/Integrations/Echo.pm
+++ b/perllib/Integrations/Echo.pm
@@ -94,6 +94,7 @@ sub GetTasks {
Ref => { Value => { anyType => [ 123, 456 ] } },
State => { Name => 'Completed' },
Resolution => { Ref => { Value => { anyType => 187 } }, Name => 'Wrong Bin Out' },
+ TaskTypeId => 3216,
CompletedDate => { DateTime => '2020-05-27T10:00:00Z' }
},
{