Skip to content

Commit

Permalink
[Merton] Add larger bin process flow.
Browse files Browse the repository at this point in the history
  • Loading branch information
dracos committed Dec 11, 2024
1 parent 607249c commit 91b8b54
Show file tree
Hide file tree
Showing 10 changed files with 221 additions and 15 deletions.
6 changes: 3 additions & 3 deletions perllib/FixMyStreet/App/Form/Waste/Request.pm
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,9 @@ sub validate {
my $any = 0;

foreach ($self->all_fields) {
$any = 1 if $_->name =~ /^container-/ && ($_->value || $self->saved_data->{$_->name});
# Kingston special case for change-size-first-page
$any = 1 if $_->name eq 'how_many_exchange' && ($_->value || $self->saved_data->{$_->name});
# Either a container-* has been selected, or
# Kingston/Merton special cases for change-size-first-page
$any = 1 if $_->name =~ /^container-|how_many_exchange|medical_condition/ && ($_->value || $self->saved_data->{$_->name});
}
$self->add_form_error('Please specify what you need')
unless $any;
Expand Down
95 changes: 95 additions & 0 deletions perllib/FixMyStreet/App/Form/Waste/Request/Merton/Larger.pm
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
package FixMyStreet::App::Form::Waste::Request::Merton::Larger;

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

use constant CONTAINER_REFUSE_240 => 2;

has_page medical_condition => (
fields => ['medical_condition', 'continue'],
title => 'Larger black bin request',
intro => 'request/intro.html',
next => sub {
my $data = shift;
return 'how_much' if $data->{medical_condition} eq 'Yes';
return 'how_many';
},
);

has_field medical_condition => (
required => 1,
type => 'Select',
widget => 'RadioGroup',
label => 'Does anyone in your household have any medical condition that causes extra waste that cannot be recycled?',
options => [
{ value => 'Yes', label => 'Yes' },
{ value => 'No', label => 'No' },
],
);

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

has_page how_much => (
fields => ['how_much', 'continue'],
intro => 'request/intro.html',
title => 'Larger black bin request',
next => sub {
my $data = shift;
my $how_much = $data->{how_much};
return 'how_many' if $how_much eq 'less1';
return 'request_static' if $how_much eq '3more';
$data->{'container-' . CONTAINER_REFUSE_240} = 1;
$data->{'quantity-' . CONTAINER_REFUSE_240} = 1;
$data->{'removal-' . CONTAINER_REFUSE_240} = 1;
return 'about_you';
},
);

has_field how_much => (
required => 1,
type => 'Select',
widget => 'RadioGroup',
label => 'How much non-hazardous, non-recyclable waste does your household produce due to medical conditions?',
options => [
{ value => 'less1', label => 'Less than 1 black sack a fortnight' },
{ value => '1or2', label => '1 or 2 black sacks a fortnight' },
{ value => '3more', label => '3 or more black sacks a fortnight' },
],
);

has_page how_many => (
fields => ['how_many', 'continue'],
title => 'Larger black bin request',
next => sub {
my $data = shift;
return 'request_static' if $data->{how_many} eq 'less5';
$data->{'container-' . CONTAINER_REFUSE_240} = 1;
$data->{'quantity-' . CONTAINER_REFUSE_240} = 1;
$data->{'removal-' . CONTAINER_REFUSE_240} = 1;
return 'about_you';
},
);

has_field how_many => (
required => 1,
type => 'Select',
widget => 'RadioGroup',
label => 'How many people live in your home (include you)?',
options => [
{ value => 'less5', label => '1 to 4' },
{ value => '5more', label => '5 or more' },
],
);

has_page request_static => (
fields => [],
template => 'waste/request/static.html',
);

1;
27 changes: 25 additions & 2 deletions perllib/FixMyStreet/Cobrand/Merton/Waste.pm
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ with 'FixMyStreet::Roles::Cobrand::Adelante';

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

=over 4
Expand Down Expand Up @@ -260,6 +261,22 @@ sub staff_override_request_options {
push @$rows, \%new_row;
}

=head2 waste_munge_request_form_pages
Larger bin request has a separate request flow
=cut

sub waste_munge_request_form_pages {
my ($self, $page_list, $field_list) = @_;
my $c = $self->{c};

if ($c->get_param('exchange')) {
$c->stash->{first_page} = 'medical_condition';
$c->stash->{form_class} = "FixMyStreet::App::Form::Waste::Request::Merton::Larger";
}
}

sub waste_request_form_first_next {
my $self = shift;
return sub {
Expand All @@ -277,10 +294,16 @@ sub waste_munge_request_data {
my $container = $c->stash->{containers}{$id};
my $quantity = $data->{"quantity-$id"} || 1;
my $reason = $data->{request_reason} || '';
my $nice_reason = $c->stash->{label_for_field}->($form, 'request_reason', $reason);
my $nice_reason = $c->stash->{label_for_field}->($form, 'request_reason', $reason)
if $reason;

my ($action_id, $reason_id);
if ($reason eq 'damaged') {
if ($data->{medical_condition}) { # Filled in the larger form
$reason = 'change_capacity';
$action_id = '2::1';
$reason_id = '3::3';
$id = '35::2';
} elsif ($reason eq 'damaged') {
$action_id = 3; # Replace
$reason_id = 2; # Damaged
} elsif ($reason eq 'missing') {
Expand Down
37 changes: 37 additions & 0 deletions t/app/controller/waste_merton.t
Original file line number Diff line number Diff line change
Expand Up @@ -366,6 +366,43 @@ FixMyStreet::override_config {
$mech->log_out_ok;
};

subtest 'Request larger refuse bin' => sub {
$bin_data->[1]{ServiceTasks}{ServiceTask}{Data}{ExtensibleDatum}{ChildData}{ExtensibleDatum}[0]{Value} = '35';
$mech->get_ok('/waste/12345');
$mech->follow_link_ok({ text => 'Request a larger refuse container' });
$mech->submit_form_ok({ with_fields => { medical_condition => 'No' } });
$mech->submit_form_ok({ with_fields => { how_many => 'less5' } });
$mech->content_contains('Sorry, you are not eligible');
$mech->back;
$mech->submit_form_ok({ with_fields => { how_many => '5more' } });
$mech->submit_form_ok({ with_fields => { name => 'Bob Marge', email => $user->email }});
$mech->back;
$mech->back;
$mech->back;
$mech->submit_form_ok({ with_fields => { medical_condition => 'Yes' } });
$mech->submit_form_ok({ with_fields => { how_much => 'less1' } });
$mech->content_contains('How many people live');
$mech->back;
$mech->submit_form_ok({ with_fields => { how_much => '3more' } });
$mech->content_contains('Clinical waste');
$mech->back;
$mech->submit_form_ok({ with_fields => { how_much => '1or2' } });
$mech->submit_form_ok({ with_fields => { name => 'Bob Marge', email => $user->email }});
$mech->content_contains('name="goto" value="medical_condition"');
$mech->submit_form_ok({ with_fields => { process => 'summary' } });
$mech->content_contains('request has been sent');
$mech->content_contains('consider your request');
my $report = FixMyStreet::DB->resultset("Problem")->search(undef, { order_by => { -desc => 'id' } })->first;
is $report->get_extra_field_value('uprn'), 1000000002;
is $report->detail, "Quantity: 1\n\n2 Example Street, Merton, KT1 1AA";
is $report->title, 'Request exchange for Black rubbish bin (240L)';
FixMyStreet::Script::Reports::send();
my $req = Open311->test_req_used;
my $cgi = CGI::Simple->new($req->content);
is $cgi->param('attribute[Action]'), '2::1';
is $cgi->param('attribute[Reason]'), '3::3';
$bin_data->[1]{ServiceTasks}{ServiceTask}{Data}{ExtensibleDatum}{ChildData}{ExtensibleDatum}[0]{Value} = '1'; # Reset
};

subtest 'Report missed collection' => sub {
$mech->get_ok('/waste/12345/report');
Expand Down
2 changes: 1 addition & 1 deletion templates/web/base/waste/summary_request.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
title = 'Submit container request';
thing = 'container request';
summary_title = 'Container requests';
step1 = 'request';
step1 = first_page;
%]

[% BLOCK answers %]
Expand Down
9 changes: 9 additions & 0 deletions templates/web/merton/waste/_confirmation_after.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
[% IF first_page == 'medical_condition' %]
<p>
We will consider your request. We reserve the right to check the information given.
</p>

<p>
We will swap your bin for a larger one within 2 weeks, or if your request was unsuccessful we will contact you to let you know.
</p>
[% END %]
3 changes: 3 additions & 0 deletions templates/web/merton/waste/_more_services_sidebar.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ <h3>More services</h3>
[% IF any_request_allowed %]
<li><a href="[% c.uri_for_action('waste/request', [ property.id ]) %]">Request a replacement container</a></li>
[% END %]
[% IF services.2238 AND services.2238.request_containers.0 == 35 %]
<li><a href="[% c.uri_for_action('waste/request', [ property.id ]) %]?exchange=1">Request a larger refuse container</a></li>
[% END %]
[% IF show_garden_subscribe %]
<li><a href="[% c.uri_for_action('waste/garden', [ property.id ]) %]">Subscribe to [% c.cobrand.garden_service_name %]</a></li>
[% END %]
Expand Down
13 changes: 13 additions & 0 deletions templates/web/merton/waste/request/intro.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
[% IF form.current_page.name == 'how_much' %]
<p class="govuk-body">
You must not put hazardous clinical waste in your rubbish bin. This includes used syringes, and items contaminated with infectious body fluids.
</p>
<p class="govuk-body">
We provide a separate service for collecting this, please see our
<a href="https://www.merton.gov.uk/rubbish-and-recycling/bulky-hazardous-and-clinical-waste/clinical-waste">Clinical waste</a> page.
</p>
<p class="govuk-body">
You can put non-hazardous items in your rubbish bin, such as sanitary towels, nappies and incontinence pads (also known as sanpro waste).
</p>

[% END %]
29 changes: 29 additions & 0 deletions templates/web/merton/waste/request/static.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
[% USE date(format='%Y%m%d') ~%]
[% PROCESS 'waste/header.html' %]

<h1 class="govuk-heading-xl">Larger black bin request</h1>

[% IF property %]
[% INCLUDE 'waste/_address_display.html' %]
[% END %]

[% IF form.saved_data.how_much == '3more' %]
<p class="govuk-body">
<strong>Clinical waste</strong>
</p>
<p class="govuk-body">
Please visit our
<a href="https://www.merton.gov.uk/rubbish-and-recycling/bulky-hazardous-and-clinical-waste/clinical-waste">Clinical Waste</a>
page to find out about arranging a separate collection of your sanitary waste.
</p>
[% ELSIF form.saved_data.how_many == 'less5' %]
<p class="govuk-body">
<strong>Sorry, you are not eligible for a larger bin</strong>
</p>
<p class="govuk-body">
If you recycle everything you can, including food waste, you should find that you have enough space in your rubbish bin.
<a href="https://www.merton.gov.uk/acceptable">Find out what you can recycle</a>
</p>
[% END %]

[% INCLUDE footer.html %]
15 changes: 6 additions & 9 deletions templates/web/peterborough/waste/summary_request.html
Original file line number Diff line number Diff line change
@@ -1,18 +1,15 @@
[% IF c.get_param('bags_only') %]
[%
[%
IF c.get_param('bags_only');
title = 'Submit food bags request';
thing = 'food bags request';
summary_title = 'Food bag requests';
step1 = 'request';
%]
[% ELSE %]
[%
ELSE;
title = 'Submit bin request';
thing = 'bin request';
summary_title = 'Bin requests';
step1 = 'request';
%]
[% END %]
END;
step1 = first_page;
%]

[% BLOCK answers %]
[% FOR container IN data.keys.grep('^container-') %]
Expand Down

0 comments on commit 91b8b54

Please sign in to comment.