Skip to content

Commit

Permalink
Add waste_property_id function.
Browse files Browse the repository at this point in the history
Bexley uses the UPRN, not the property ID, so use this
so that some things that add links to bin day pages can work
more automatically.
  • Loading branch information
dracos committed Dec 12, 2024
1 parent 6f72070 commit a851d69
Show file tree
Hide file tree
Showing 24 changed files with 51 additions and 30 deletions.
11 changes: 6 additions & 5 deletions perllib/FixMyStreet/App/Controller/Waste.pm
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ sub index : Path : Args(0) {
$c->stash->{continue_id} = $id;
if (my $p = $c->cobrand->problems->search({ state => 'unconfirmed' })->find($id)) {
if ($c->stash->{is_staff} && $c->stash->{waste_features}{bulky_retry_bookings}) {
my $property_id = $p->get_extra_field_value('property_id');
my $property_id = $p->waste_property_id;
my $saved_data = $c->cobrand->waste_reconstruct_bulky_data($p);
$saved_data->{continue_id} = $id;
my $saved_data_field = FixMyStreet::App::Form::Field::JSON->new(name => 'saved_data');
Expand Down Expand Up @@ -205,7 +205,7 @@ sub pay_retry : Path('pay_retry') : Args(0) {
$c->forward('check_payment_redirect_id', [ $id, $token ]);

my $p = $c->stash->{report};
$c->stash->{property} = $c->cobrand->call_hook(look_up_property => $p->get_extra_field_value('property_id'));
$c->stash->{property} = $c->cobrand->call_hook(look_up_property => $p->waste_property_id);
$c->forward('pay', [ 'bin_days' ]);
}

Expand Down Expand Up @@ -285,7 +285,7 @@ sub confirm_subscription : Private {
my ($self, $c, $reference) = @_;
my $p = $c->stash->{report};

$c->stash->{property_id} = $p->get_extra_field_value('property_id');
$c->stash->{property_id} = $p->waste_property_id;

if ($p->category eq 'Bulky collection' || $p->category eq 'Small items collection') {
$c->stash->{template} = 'waste/bulky/confirmation.html';
Expand Down Expand Up @@ -439,7 +439,7 @@ sub direct_debit_error : Path('dd_error') : Args(0) {
if ( $id && $token ) {
$c->forward('check_payment_redirect_id', [ $id, $token ]);
my $p = $c->stash->{report};
$c->stash->{property} = $c->cobrand->call_hook(look_up_property => $p->get_extra_field_value('property_id'));
$c->stash->{property} = $c->cobrand->call_hook(look_up_property => $p->waste_property_id);

Check warning on line 442 in perllib/FixMyStreet/App/Controller/Waste.pm

View check run for this annotation

Codecov / codecov/patch

perllib/FixMyStreet/App/Controller/Waste.pm#L442

Added line #L442 was not covered by tests
$c->forward('populate_dd_details');
}

Expand Down Expand Up @@ -545,7 +545,7 @@ sub csc_payment_failed : Path('csc_payment_failed') : Args(0) {

my $report = $c->model('DB::Problem')->find({ id => $id});
$c->stash->{report} = $report;
$c->stash->{property_id} = $report->get_extra_field_value('property_id');
$c->stash->{property_id} = $report->waste_property_id;

my $contributed_as = $report->get_extra_metadata('contributed_as') || '';
if ( $contributed_as ne 'anonymous_user' ) {
Expand Down Expand Up @@ -1403,6 +1403,7 @@ sub get_original_sub : Private {
my $p = $c->model('DB::Problem')->search({
category => 'Garden Subscription',
title => ['Garden Subscription - New', 'Garden Subscription - Renew'],
# XXX Bexley does not store a property_id
extra => { '@>' => encode_json({ "_fields" => [ { name => "property_id", value => $c->stash->{property}{id} } ] }) },
state => { '!=' => 'hidden' },
})->order_by('-id')->to_body($c->cobrand->body);
Expand Down
2 changes: 1 addition & 1 deletion perllib/FixMyStreet/App/Controller/Waste/Bulky.pm
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ sub view : Private {
my $p = $c->stash->{problem};

$c->stash->{property} = {
id => $p->get_extra_field_value('property_id'),
id => $p->waste_property_id,
address => $p->get_extra_metadata('property_address'),
};

Expand Down
20 changes: 20 additions & 0 deletions perllib/FixMyStreet/DB/Result/Problem.pm
Original file line number Diff line number Diff line change
Expand Up @@ -1519,6 +1519,26 @@ sub create_related_things {

=head2 Waste related activity
=head3 waste_property_id
Return the property ID used in the URL of a bin day page. This is usually
property_id on the report, but could be the UPRN (e.g. Bexley).
=cut

sub waste_property_id {
my $self = shift;
return $self->get_extra_field_value('uprn') if $self->cobrand eq 'bexley';
return $self->get_extra_field_value('property_id');
}

=head3 waste_confirm_payment
This is called when a payment has been confirmed in order to record the
payment, perhaps send an email, add a payment confirmation update for
already-sent bulky collections, cancel a previous collection if an amendment,
and so on.
=cut

sub waste_confirm_payment {
Expand Down
6 changes: 3 additions & 3 deletions perllib/FixMyStreet/Roles/Cobrand/DDProcessor.pm
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ sub waste_reconcile_direct_debits {
$p = $cur;
}
if ( $p ) {
my $service = $self->waste_get_current_garden_sub( $p->get_extra_field_value('property_id') );
my $service = $self->waste_get_current_garden_sub( $p->waste_property_id );
my $quantity;
if ($service) {
$quantity = $self->waste_get_sub_quantity($service);
Expand Down Expand Up @@ -244,7 +244,7 @@ sub waste_reconcile_direct_debits {

if ( $r ) {
$self->log("processing matched report " . $r->id);
my $service = $self->waste_get_current_garden_sub( $r->get_extra_field_value('property_id') );
my $service = $self->waste_get_current_garden_sub( $r->waste_property_id );
# if there's not a service then it's fine as it's already been cancelled
if ( $service ) {
$r->set_extra_metadata('dd_date', $payment->date);
Expand Down Expand Up @@ -301,7 +301,7 @@ sub _duplicate_waste_report {
payment_method => 'direct_debit',
$self->garden_subscription_container_field => $report->get_extra_field_value($self->garden_subscription_container_field),
service_id => $report->get_extra_field_value('service_id'),
property_id => $report->get_extra_field_value('property_id'),
property_id => $report->waste_property_id,
};


Expand Down
2 changes: 1 addition & 1 deletion perllib/FixMyStreet/Roles/Cobrand/Echo.pm
Original file line number Diff line number Diff line change
Expand Up @@ -1062,7 +1062,7 @@ sub clear_cached_lookups_bulky_slots {
sub bulky_refetch_slots {
my ($self, $row, $verbose) = @_;

my $property_id = $row->get_extra_field_value('property_id');
my $property_id = $row->waste_property_id;
my $date = $self->collection_date($row);
my $guid = $row->get_extra_field_value('GUID');
my $window = $self->_bulky_collection_window();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[% IF problem.cobrand_data == 'waste' %]
[% SET property_id = problem.get_extra_field_value('property_id') %]
[% SET property_id = problem.waste_property_id %]
<a href="https://recyclingservices.bromley.gov.uk/waste[% IF property_id %]/[% property_id %][% END %]">Check your bin collections day</a>
[% END %]
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[% IF problem.cobrand_data == 'waste' %]
[% SET property_id = problem.get_extra_field_value('property_id') %]
[% SET property_id = problem.waste_property_id %]
Check your bin collections day: https://recyclingservices.bromley.gov.uk/waste[% IF property_id %]/[% property_id %][% END %]
[% END %]
2 changes: 1 addition & 1 deletion templates/email/default/waste/bulky-reminder.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
PROCESS '_email_settings.html';
INCLUDE '_email_top.html';

property_id_uri = report.get_extra_field_value('property_id') | uri;
property_id_uri = report.waste_property_id | uri;
cancel_url = cobrand.base_url _ '/waste/' _ property_id_uri _ '/' _ bulky_cancel_url _ '/' _ report.id;
%]

Expand Down
2 changes: 1 addition & 1 deletion templates/email/default/waste/bulky-reminder.txt
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ If you wish to cancel your booking, please call 01733 74 74 74.

If you wish to cancel your booking, please visit:

[% cobrand.base_url %]/waste/[% report.get_extra_field_value('property_id') | uri %]/[% bulky_cancel_url %]/[% report.id %]
[% cobrand.base_url %]/waste/[% report.waste_property_id | uri %]/[% bulky_cancel_url %]/[% report.id %]

[% IF days == 1 %]
You may still be able to cancel your booking.
Expand Down
2 changes: 1 addition & 1 deletion templates/email/default/waste/other-reported-bulky.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
PROCESS '_email_settings.html';
INCLUDE '_email_top.html';

property_id_uri = report.get_extra_field_value('property_id') | uri;
property_id_uri = report.waste_property_id | uri;
cancel_url = cobrand.base_url _ '/waste/' _ property_id_uri _ '/' _ bulky_cancel_url _ '/' _ report.id;
%]

Expand Down
2 changes: 1 addition & 1 deletion templates/email/default/waste/other-reported-bulky.txt
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ If you wish to cancel your booking, please call 01733 74 74 74.

If you wish to cancel your booking, please visit:

[% cobrand.base_url %]/waste/[% report.get_extra_field_value('property_id') | uri %]/[% bulky_cancel_url %]/[% report.id %]
[% cobrand.base_url %]/waste/[% report.waste_property_id | uri %]/[% bulky_cancel_url %]/[% report.id %]

[% END ~%]

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[% IF problem.cobrand_data == 'waste' %]
[% SET property_id = problem.get_extra_field_value('property_id') %]
[% SET property_id = problem.waste_property_id %]
<a href="https://waste-services.kingston.gov.uk/waste[% IF property_id %]/[% property_id %][% END %]">Check your bin collections day</a>
[% END %]
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[% IF problem.cobrand_data == 'waste' %]
[% SET property_id = problem.get_extra_field_value('property_id') %]
[% SET property_id = problem.waste_property_id %]
Check your bin collections day: https://waste-services.kingston.gov.uk/waste[% IF property_id %]/[% property_id %][% END %]
[% END %]
2 changes: 1 addition & 1 deletion templates/email/kingston/waste/bulky-reminder.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
PROCESS '_email_settings.html';
INCLUDE '_email_top.html';

property_id_uri = report.get_extra_field_value('property_id') | uri;
property_id_uri = report.waste_property_id | uri;
cancel_url = cobrand.base_url _ '/waste/' _ property_id_uri _ '/' _ bulky_cancel_url _ '/' _ report.id;
%]

Expand Down
2 changes: 1 addition & 1 deletion templates/email/kingston/waste/bulky-reminder.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ END;

[% PROCESS 'waste/_bulky_data.html';

property_id_uri = report.get_extra_field_value('property_id') | uri;
property_id_uri = report.waste_property_id | uri;
cancel_url = cobrand.base_url _ '/waste/' _ property_id_uri _ '/' _ bulky_cancel_url _ '/' _ report.id;

~%]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[% IF problem.cobrand_data == 'waste' %]
[% SET property_id = problem.get_extra_field_value('property_id') %]
[% SET property_id = problem.waste_property_id %]
<a href="https://recycling-services.merton.gov.uk/waste[% IF property_id %]/[% property_id %][% END %]">Check your bin collections day</a>
[% END %]
2 changes: 1 addition & 1 deletion templates/email/merton/_council_reference_alert_update.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[% IF problem.cobrand_data == 'waste' %]
[% SET property_id = problem.get_extra_field_value('property_id') %]
[% SET property_id = problem.waste_property_id %]
Check your bin collections day: https://recycling-services.merton.gov.uk/waste[% IF property_id %]/[% property_id %][% END %]
[% END %]
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[% IF problem.cobrand_data == 'waste' %]
[% SET property_id = problem.get_extra_field_value('property_id') %]
[% SET property_id = problem.waste_property_id %]
<a href="https://waste-services.sutton.gov.uk/waste[% IF property_id %]/[% property_id %][% END %]">Check your bin collections day</a>
[% END %]
2 changes: 1 addition & 1 deletion templates/email/sutton/_council_reference_alert_update.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[% IF problem.cobrand_data == 'waste' %]
[% SET property_id = problem.get_extra_field_value('property_id') %]
[% SET property_id = problem.waste_property_id %]
Check your bin collections day: https://waste-services.sutton.gov.uk/waste[% IF property_id %]/[% property_id %][% END %]
[% END %]
4 changes: 2 additions & 2 deletions templates/web/base/admin/reports/_edit_waste.html
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,8 @@
[% IF problem.get_extra_field_value('uprn') %]
<li>UPRN: [% problem.get_extra_field_value('uprn') %]
[% END %]
[% IF problem.get_extra_field_value('property_id') %]
<li>Property ID: <a href="/waste/[% problem.get_extra_field_value('property_id') %]">[% problem.get_extra_field_value('property_id') %]</a>
[% IF problem.waste_property_id %]
<li>Property ID: <a href="/waste/[% problem.waste_property_id %]">[% problem.waste_property_id %]</a>
[% END %]
[% IF problem.get_extra_field_value('service_id') %]
<li>Service ID: [% problem.get_extra_field_value('service_id') %]
Expand Down
2 changes: 1 addition & 1 deletion templates/web/base/waste/_button_show_upcoming.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@

<p>
[% # sometimes we have the property on the stash, sometimes it's just the report (e.g. token confirmation)
property_id = property.id OR report.get_extra_field_value('property_id') %]
property_id = property.id OR report.waste_property_id %]
<a href="[% c.uri_for_action('waste/bin_days', [ property_id ]) %]" class="govuk-button">[% button_text %]</a>
</p>
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[% IF disallowed == 'waste';
SET property_id = problem.get_extra_field_value('property_id');
SET property_id = problem.waste_property_id;
%]
<p>
<a href="/waste[% IF property_id %]/[% property_id %][% END %]">See your bin collections</a>.
Expand Down
2 changes: 1 addition & 1 deletion templates/web/peterborough/waste/bulky/confirmation.html
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ <h3 class="govuk-heading-l govuk-warning-text__heading">Collection booked</h3>
<p class="govuk-!-margin-bottom-2">We have sent you an email confirming this booking.</p>
<p>Can’t find our email? <strong>Check your spam folder.</strong></p>
[% END %]
<a href="[% c.uri_for_action('waste/bin_days', [ report.get_extra_field_value('property_id') ]) %]" class="btn btn--primary">Go back home</a>
<a href="[% c.uri_for_action('waste/bin_days', [ report.waste_property_id ]) %]" class="btn btn--primary">Go back home</a>
</div>
</div>

Expand Down
2 changes: 1 addition & 1 deletion templates/web/peterborough/waste/confirmation.html
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ <h1 class="govuk-panel__title">
<div class="govuk-grid-row">
<div class="govuk-grid-column-two-thirds">
[% # sometimes we have the property on the stash, sometimes it's just the report (e.g. token confirmation)
property_id = property.id OR report.get_extra_field_value('property_id') %]
property_id = property.id OR report.waste_property_id %]
<a href="[% c.uri_for_action('waste/bin_days', [ property_id ]) %]" class="govuk-button">Show upcoming bin days</a>
</div>
</div>
Expand Down

0 comments on commit a851d69

Please sign in to comment.