Skip to content

Commit

Permalink
[Merton] Initial WasteWorks setup.
Browse files Browse the repository at this point in the history
Include a script to send waste reports to a second endpoint.
  • Loading branch information
dracos committed Apr 17, 2024
1 parent ea45cd4 commit 1e7efcd
Show file tree
Hide file tree
Showing 22 changed files with 1,133 additions and 457 deletions.
19 changes: 19 additions & 0 deletions bin/merton/send-waste
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#!/usr/bin/env perl
#
# This script sends waste reports additionally to Merton's
# Open311 endpoint. They have already been sent to Echo.

use v5.14;
use warnings;

BEGIN { # set all the paths to the perl code
use File::Basename qw(dirname);
use File::Spec;
my $d = dirname(File::Spec->rel2abs($0));
require "$d/../../setenv.pl";
}

use FixMyStreet::Script::Merton::SendWaste;

my $send = FixMyStreet::Script::Merton::SendWaste->new;
$send->send_reports;
2 changes: 1 addition & 1 deletion perllib/FixMyStreet/App/Controller/Waste.pm
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,7 @@ sub confirm_subscription : Private {

if ($c->cobrand->suppress_report_sent_email($p)) {
# Send bulky confirmation email after report confirmation (see
# the suppress_report_sent_email in CobrandSLWP.pm)
# the suppress_report_sent_email for SLWP)
$p->send_logged_email({ %{$c->stash} }, 0, $c->cobrand);
}

Expand Down
2 changes: 1 addition & 1 deletion perllib/FixMyStreet/App/Form/Waste/Request/Kingston.pm
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ FixMyStreet::App::Form::Waste::Request::Kingston - Kingston-specific request new
=head1 SYNOPSIS
The Kingston container request form lets you request one container at a time
(code for that in L<FixMyStreet::Roles::CobrandSLWP>).
(code for that in L<FixMyStreet::Roles::Cobrand::KingstonSutton>).
=head1 PAGES
Expand Down
38 changes: 38 additions & 0 deletions perllib/FixMyStreet/App/Form/Waste/Request/Merton.pm
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
package FixMyStreet::App::Form::Waste::Request::Merton;

use utf8;
use HTML::FormHandler::Moose;
extends 'FixMyStreet::App::Form::Waste::Request';

has_page about_you => (
fields => ['name', 'email', 'phone', 'continue'],
intro => 'about_you.html',
title => 'About you',
next => 'summary',
);

has_page replacement => (
fields => ['request_reason', 'continue'],
title => 'Reason for request',
next => 'about_you',
);

has_field request_reason => (
required => 1,
type => 'Select',
widget => 'RadioGroup',
label => 'Why do you need a replacement container?',
);

sub options_request_reason {
my $form = shift;
my @options = (
{ value => 'new_build', label => 'I am a new resident without a container' },
{ value => 'damaged', label => 'Damaged' },
{ value => 'missing', label => 'Missing' },
{ value => 'more', label => 'I need an additional container/bin' },
);
return @options;
}

1;
2 changes: 2 additions & 0 deletions perllib/FixMyStreet/Cobrand/Bexley/Waste.pm
Original file line number Diff line number Diff line change
Expand Up @@ -548,6 +548,8 @@ sub image_for_unit {

sub bin_day_format { '%A, %-d~~~ %B %Y' }

sub waste_images_2x_unavailable { 1 }

# TODO This logic is copypasted across multiple files; get it into one place
my %irregulars = ( 1 => 'st', 2 => 'nd', 3 => 'rd', 11 => 'th', 12 => 'th', 13 => 'th');
sub ordinal {
Expand Down
2 changes: 1 addition & 1 deletion perllib/FixMyStreet/Cobrand/Kingston.pm
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package FixMyStreet::Cobrand::Kingston;
use parent 'FixMyStreet::Cobrand::UKCouncils';

use Moo;
with 'FixMyStreet::Roles::CobrandSLWP';
with 'FixMyStreet::Roles::Cobrand::KingstonSutton';
with 'FixMyStreet::Roles::SCP';

sub council_area_id { return 2480; }
Expand Down
1 change: 1 addition & 0 deletions perllib/FixMyStreet/Cobrand/Merton.pm
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ use strict;
use warnings;
use Moo;
with 'FixMyStreet::Roles::CobrandOpenUSRN';
with 'FixMyStreet::Cobrand::Merton::Waste';

sub council_area_id { 2500 }
sub council_area { 'Merton' }
Expand Down
135 changes: 135 additions & 0 deletions perllib/FixMyStreet/Cobrand/Merton/Waste.pm
Original file line number Diff line number Diff line change
@@ -0,0 +1,135 @@
package FixMyStreet::Cobrand::Merton::Waste;

use Moo::Role;
with 'FixMyStreet::Roles::Cobrand::SLWP';

use FixMyStreet::App::Form::Waste::Request::Merton;

has lpi_value => ( is => 'ro', default => 'MERTON' );

sub waste_auto_confirm_report { 1 }

sub service_name_override {
my ($self, $service) = @_;

my %service_name_override = (
2238 => 'Non-recyclable Refuse',
2239 => 'Food waste',
2240 => 'Paper and card',
2241 => 'Mixed recycling',
2242 => 'Non-recyclable Refuse',
2243 => 'Non-recyclable Refuse',
2246 => 'Mixed recycling',
2247 => 'Garden Waste',
2248 => "Food waste",
2249 => "Paper and card",
2250 => "Mixed recycling",
2632 => 'Paper and card',
3571 => 'Mixed recycling',
3576 => 'Non-recyclable Refuse',
2256 => '', # Deliver refuse bags
2257 => '', # Deliver recycling bags
);

return $service_name_override{$service->{ServiceId}} // '';
}

sub waste_password_hidden { 1 }

Check warning on line 37 in perllib/FixMyStreet/Cobrand/Merton/Waste.pm

View check run for this annotation

Codecov / codecov/patch

perllib/FixMyStreet/Cobrand/Merton/Waste.pm#L37

Added line #L37 was not covered by tests

sub waste_containers {
return {
1 => 'Black rubbish bin (140L)',
2 => 'Black rubbish bin (240L)',
3 => 'Black rubbish bin (360L)',
35 => 'Black rubbish bin (180L)',

4 => 'Refuse Blue Sack',
5 => 'Refuse Black Sack',
6 => 'Refuse Red Stripe Bag',

12 => 'Green recycling bin (240L)',
13 => 'Green recycling bin (360L)',
16 => 'Green recycling box (55L)',

18 => 'Recycling Blue Stripe Bag',
29 => 'Recycling Single Use Bag',

19 => 'Blue lid paper and cardboard bin (240L)',
20 => 'Blue lid paper and cardboard bin (360L)',
36 => 'Blue lid paper and cardboard bin (180L)',

21 => 'Paper & Card Reusable Bag',
22 => 'Paper Sacks',
30 => 'Paper Single Use Bag',
31 => 'Paper 55L Box',

23 => 'Food waste bin (kitchen)',
24 => 'Food waste bin (outdoor)',

26 => 'Garden waste bin (240L)',
27 => 'Garden waste bin (140L)',
28 => 'Garden waste sacks',

7 => 'Communal Refuse bin (240L)',
8 => 'Communal Refuse bin (360L)',
9 => 'Communal Refuse bin (660L)',
10 => 'Communal Refuse bin (1100L)',
11 => 'Communal Refuse Chamberlain',
33 => 'Communal Refuse bin (140L)',
34 => 'Communal Refuse bin (1280L)',
14 => 'Communal Recycling bin (660L)',
15 => 'Communal Recycling bin (1100L)',
25 => 'Communal Food bin (240L)',
};
}

sub image_for_unit {
my ($self, $unit) = @_;
my $base = '/i/waste-containers';
my $service_id = $unit->{service_id};
my $images = {
2238 => "$base/bin-black", # refuse
2239 => "$base/caddy-brown-large", # food
2240 => "$base/bin-grey-blue-lid-recycling", # paper and card
2241 => "$base/box-green-mix", # dry mixed
2242 => "$base/sack-clear-red", # domestic refuse bag
2243 => "$base/large-communal-grey-black-lid", # Communal refuse
2246 => "$base/sack-clear-blue", # domestic recycling bag
2247 => "$base/bin-brown", # garden
#2248 => "$base/bin-brown", # Communal food
#2249 => "$base/bin-grey-blue-lid-recycling", # Communal paper
2250 => "$base/large-communal-green", # Communal recycling
2632 => "$base/sack-clear", # domestic paper bag
};
return $images->{$service_id};
}

sub _closed_event {
my ($self, $event) = @_;
return 1 if $event->{ResolvedDate};
return 1 if $event->{ResolutionCodeId} && $event->{ResolutionCodeId} != 584; # Out of Stock
return 0;
}

# TODO
sub garden_container_data_extract { }
sub waste_bulky_missed_blocked_codes {}

sub waste_quantity_max {
return (
2247 => 3, # Garden waste maximum
);
}

sub waste_request_form_first_next {
my $self = shift;
return sub {
my $data = shift;
return 'about_you' if $data->{"container-18"} || $data->{"container-30"};
return 'replacement';
};
}

sub garden_due_days { 30 }

Check warning on line 133 in perllib/FixMyStreet/Cobrand/Merton/Waste.pm

View check run for this annotation

Codecov / codecov/patch

perllib/FixMyStreet/Cobrand/Merton/Waste.pm#L133

Added line #L133 was not covered by tests

1;
2 changes: 1 addition & 1 deletion perllib/FixMyStreet/Cobrand/Sutton.pm
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use parent 'FixMyStreet::Cobrand::UKCouncils';

use utf8;
use Moo;
with 'FixMyStreet::Roles::CobrandSLWP';
with 'FixMyStreet::Roles::Cobrand::KingstonSutton';
with 'FixMyStreet::Roles::SCP';

use Digest::SHA qw(sha1_hex);
Expand Down

0 comments on commit 1e7efcd

Please sign in to comment.