aboutsummaryrefslogtreecommitdiffstats
path: root/perllib
diff options
context:
space:
mode:
authorM Somerville <matthew-github@dracos.co.uk>2020-11-12 11:48:24 +0000
committerM Somerville <matthew-github@dracos.co.uk>2020-11-12 12:09:45 +0000
commit0b97468330ab7146f16dfe4060a63d28ce445fa6 (patch)
tree752104e2da254c10006a7093f2011b2e031c96d6 /perllib
parentf5dc489e9ad85a7cf3e7c937a926228cd8178432 (diff)
[Bromley] Use property ID, rather than UPRN.
Diffstat (limited to 'perllib')
-rw-r--r--perllib/FixMyStreet/App/Controller/Waste.pm42
-rw-r--r--perllib/FixMyStreet/Cobrand/Bromley.pm15
-rw-r--r--perllib/Integrations/Echo.pm27
3 files changed, 43 insertions, 41 deletions
diff --git a/perllib/FixMyStreet/App/Controller/Waste.pm b/perllib/FixMyStreet/App/Controller/Waste.pm
index 152c7c28e..fe177e9fe 100644
--- a/perllib/FixMyStreet/App/Controller/Waste.pm
+++ b/perllib/FixMyStreet/App/Controller/Waste.pm
@@ -23,8 +23,8 @@ sub auto : Private {
sub index : Path : Args(0) {
my ( $self, $c ) = @_;
- if (my $uprn = $c->get_param('address')) {
- $c->detach('redirect_to_uprn', [ $uprn ]);
+ if (my $id = $c->get_param('address')) {
+ $c->detach('redirect_to_id', [ $id ]);
}
$c->stash->{title} = 'What is your address?';
@@ -58,9 +58,9 @@ sub address_list_form {
);
}
-sub redirect_to_uprn : Private {
- my ($self, $c, $uprn) = @_;
- my $uri = '/waste/uprn/' . $uprn;
+sub redirect_to_id : Private {
+ my ($self, $c, $id) = @_;
+ my $uri = '/waste/' . $id;
my $type = $c->get_param('type') || '';
$uri .= '/request' if $type eq 'request';
$uri .= '/report' if $type eq 'report';
@@ -68,20 +68,19 @@ sub redirect_to_uprn : Private {
$c->detach;
}
-sub uprn : Chained('/') : PathPart('waste/uprn') : CaptureArgs(1) {
- my ($self, $c, $uprn) = @_;
+sub property : Chained('/') : PathPart('waste') : CaptureArgs(1) {
+ my ($self, $c, $id) = @_;
- if ($uprn eq 'missing') {
+ if ($id eq 'missing') {
$c->stash->{template} = 'waste/missing.html';
$c->detach;
}
$c->forward('/auth/get_csrf_token');
- my $property = $c->stash->{property} = $c->cobrand->call_hook(look_up_property => $uprn);
+ my $property = $c->stash->{property} = $c->cobrand->call_hook(look_up_property => $id);
$c->detach( '/page_error_404_not_found', [] ) unless $property;
- $c->stash->{uprn} = $uprn;
$c->stash->{latitude} = $property->{latitude};
$c->stash->{longitude} = $property->{longitude};
@@ -89,11 +88,11 @@ sub uprn : Chained('/') : PathPart('waste/uprn') : CaptureArgs(1) {
$c->stash->{services} = { map { $_->{service_id} => $_ } @{$c->stash->{service_data}} };
}
-sub bin_days : Chained('uprn') : PathPart('') : Args(0) {
+sub bin_days : Chained('property') : PathPart('') : Args(0) {
my ($self, $c) = @_;
}
-sub calendar : Chained('uprn') : PathPart('calendar.ics') : Args(0) {
+sub calendar : Chained('property') : PathPart('calendar.ics') : Args(0) {
my ($self, $c) = @_;
$c->res->header(Content_Type => 'text/calendar');
require Data::ICal::RFC7986;
@@ -110,8 +109,8 @@ sub calendar : Chained('uprn') : PathPart('calendar.ics') : Args(0) {
'x-published-ttl' => 'P1D',
calscale => 'GREGORIAN',
'x-wr-timezone' => 'Europe/London',
- source => [ $c->uri_for_action($c->action, [ $c->stash->{uprn} ]), { value => 'URI' } ],
- url => $c->uri_for_action('waste/bin_days', [ $c->stash->{uprn} ]),
+ source => [ $c->uri_for_action($c->action, [ $c->stash->{property}{id} ]), { value => 'URI' } ],
+ url => $c->uri_for_action('waste/bin_days', [ $c->stash->{property}{id} ]),
);
my $events = $c->cobrand->bin_future_collections;
@@ -175,7 +174,7 @@ sub construct_bin_request_form {
return $field_list;
}
-sub request : Chained('uprn') : Args(0) {
+sub request : Chained('property') : Args(0) {
my ($self, $c) = @_;
my $field_list = construct_bin_request_form($c);
@@ -231,7 +230,7 @@ sub construct_bin_report_form {
return $field_list;
}
-sub report : Chained('uprn') : Args(0) {
+sub report : Chained('property') : Args(0) {
my ($self, $c) = @_;
my $field_list = construct_bin_report_form($c);
@@ -266,7 +265,7 @@ sub process_report_data : Private {
return 1;
}
-sub enquiry : Chained('uprn') : Args(0) {
+sub enquiry : Chained('property') : Args(0) {
my ($self, $c) = @_;
if (my $template = $c->get_param('template')) {
@@ -279,18 +278,18 @@ sub enquiry : Chained('uprn') : Args(0) {
my $category = $c->get_param('category');
my $service = $c->get_param('service_id');
if (!$category || !$service || !$c->stash->{services}{$service}) {
- $c->res->redirect('/waste/uprn/' . $c->stash->{uprn});
+ $c->res->redirect('/waste/' . $c->stash->{property}{id});
$c->detach;
}
my ($contact) = grep { $_->category eq $category } @{$c->stash->{contacts}};
if (!$contact) {
- $c->res->redirect('/waste/uprn/' . $c->stash->{uprn});
+ $c->res->redirect('/waste/' . $c->stash->{property}{id});
$c->detach;
}
my $field_list = [];
foreach (@{$contact->get_metadata_for_input}) {
- next if $_->{code} eq 'service_id' || $_->{code} eq 'uprn';
+ next if $_->{code} eq 'service_id' || $_->{code} eq 'uprn' || $_->{code} eq 'property_id';
my $type = 'Text';
$type = 'TextArea' if 'text' eq ($_->{datatype} || '');
my $required = $_->{required} eq 'true' ? 1 : 0;
@@ -421,7 +420,8 @@ sub add_report : Private {
$c->set_param('category', $data->{category});
$c->set_param('title', $data->{title});
$c->set_param('detail', $data->{detail});
- $c->set_param('uprn', $c->stash->{uprn});
+ $c->set_param('uprn', $c->stash->{property}{uprn});
+ $c->set_param('property_id', $c->stash->{property}{id});
$c->forward('setup_categories_and_bodies') unless $c->stash->{contacts};
$c->forward('/report/new/non_map_creation', [['/waste/remove_name_errors']]) or return;
diff --git a/perllib/FixMyStreet/Cobrand/Bromley.pm b/perllib/FixMyStreet/Cobrand/Bromley.pm
index fc41eae28..0885f5b6b 100644
--- a/perllib/FixMyStreet/Cobrand/Bromley.pm
+++ b/perllib/FixMyStreet/Cobrand/Bromley.pm
@@ -426,7 +426,7 @@ sub bin_addresses_for_postcode {
$echo = Integrations::Echo->new(%$echo);
my $points = $echo->FindPoints($pc);
my $data = [ map { {
- value => $_->{SharedRef}{Value}{anyType},
+ value => $_->{Id},
label => FixMyStreet::Template::title($_->{Description}),
} } @$points ];
natkeysort_inplace { $_->{label} } @$data;
@@ -435,7 +435,7 @@ sub bin_addresses_for_postcode {
sub look_up_property {
my $self = shift;
- my $uprn = shift;
+ my $id = shift;
my $cfg = $self->feature('echo');
my $echo = Integrations::Echo->new(%$cfg);
@@ -448,10 +448,10 @@ sub look_up_property {
$self->{c}->detach('/page_error_403_access_denied', []) if $count > $cfg->{max_per_day};
}
- my $result = $echo->GetPointAddress($uprn);
+ my $result = $echo->GetPointAddress($id);
return {
id => $result->{Id},
- uprn => $uprn,
+ uprn => $result->{SharedRef}{Value}{anyType},
address => FixMyStreet::Template::title($result->{Description}),
latitude => $result->{Coordinates}{GeoPoint}{Latitude},
longitude => $result->{Coordinates}{GeoPoint}{Longitude},
@@ -538,7 +538,7 @@ sub bin_services_for_address {
my $echo = $self->feature('echo');
$echo = Integrations::Echo->new(%$echo);
- my $result = $echo->GetServiceUnitsForObject($property->{uprn});
+ my $result = $echo->GetServiceUnitsForObject($property->{id});
return [] unless @$result;
my $events = $echo->GetEventsForObject('PointAddress', $property->{id});
@@ -591,7 +591,8 @@ sub bin_services_for_address {
my $state = $_->{State}{Name} || '';
my $task_type_id = $_->{TaskTypeId} || '';
- my $resolution = $_->{Resolution}{Name} || '';
+ my $orig_resolution = $_->{Resolution}{Name} || '';
+ my $resolution = $orig_resolution;
my $resolution_id = $_->{Resolution}{Ref}{Value}{anyType};
if ($resolution_id) {
my $template = FixMyStreet::DB->resultset('ResponseTemplate')->search({
@@ -627,7 +628,7 @@ sub bin_services_for_address {
}
# If the task is ended and could not be done, do not allow reporting
- if ($state eq 'Not Completed' || ($state eq 'Completed' && $_->{Resolution}{Name} eq 'Excess Waste')) {
+ if ($state eq 'Not Completed' || ($state eq 'Completed' && $orig_resolution eq 'Excess Waste')) {
$row->{report_allowed} = 0;
$row->{report_locked_out} = 1;
}
diff --git a/perllib/Integrations/Echo.pm b/perllib/Integrations/Echo.pm
index bf4b453e6..d6783677c 100644
--- a/perllib/Integrations/Echo.pm
+++ b/perllib/Integrations/Echo.pm
@@ -129,14 +129,14 @@ sub GetTasks {
return force_arrayref($res, 'Task');
}
-sub _uprn_ref {
+sub _id_ref {
require SOAP::Lite;
- my $uprn = shift;
+ my $id = shift;
tie(my %obj, 'Tie::IxHash',
- Key => 'Uprn',
+ Key => 'Id',
Type => 'PointAddress',
Value => [
- { 'msArray:anyType' => SOAP::Data->value($uprn)->type('string') },
+ { 'msArray:anyType' => SOAP::Data->value($id) },
],
);
return \%obj;
@@ -144,10 +144,11 @@ sub _uprn_ref {
sub GetPointAddress {
my $self = shift;
- my $uprn = shift;
- my $obj = _uprn_ref($uprn);
+ my $id = shift;
+ my $obj = _id_ref($id);
return {
Id => '12345',
+ SharedRef => { Value => { anyType => '1000000002' } },
PointType => 'PointAddress',
PointAddressType => { Name => 'House' },
Coordinates => { GeoPoint => { Latitude => 51.401546, Longitude => 0.015415 } },
@@ -165,11 +166,11 @@ sub FindPoints {
Postcode => $pc,
);
return [
- { Description => '1 Example Street, Bromley, BR1 1AA', SharedRef => { Value => { anyType => 1000000001 } } },
- { Description => '2 Example Street, Bromley, BR1 1AA', SharedRef => { Value => { anyType => 1000000002 } } },
- { Description => '3 Example Street, Bromley, BR1 1AA', SharedRef => { Value => { anyType => 1000000003 } } },
- { Description => '4 Example Street, Bromley, BR1 1AA', SharedRef => { Value => { anyType => 1000000004 } } },
- { Description => '5 Example Street, Bromley, BR1 1AA', SharedRef => { Value => { anyType => 1000000005 } } },
+ { Description => '1 Example Street, Bromley, BR1 1AA', Id => '11345', SharedRef => { Value => { anyType => 1000000001 } } },
+ { Description => '2 Example Street, Bromley, BR1 1AA', Id => '12345', SharedRef => { Value => { anyType => 1000000002 } } },
+ { Description => '3 Example Street, Bromley, BR1 1AA', Id => '13345', SharedRef => { Value => { anyType => 1000000003 } } },
+ { Description => '4 Example Street, Bromley, BR1 1AA', Id => '14345', SharedRef => { Value => { anyType => 1000000004 } } },
+ { Description => '5 Example Street, Bromley, BR1 1AA', Id => '15345', SharedRef => { Value => { anyType => 1000000005 } } },
] if $self->sample_data;
my $res = $self->call('FindPoints', query => \%obj);
return force_arrayref($res, 'PointInfo');
@@ -177,8 +178,8 @@ sub FindPoints {
sub GetServiceUnitsForObject {
my $self = shift;
- my $uprn = shift;
- my $obj = _uprn_ref($uprn);
+ my $id = shift;
+ my $obj = _id_ref($id);
my $from = DateTime->now->set_time_zone(FixMyStreet->local_time_zone);
return [ {
Id => 1001,