Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion perllib/FixMyStreet/App/Controller/Waste.pm
Original file line number Diff line number Diff line change
Expand Up @@ -1339,7 +1339,7 @@ sub add_report : Private {
$c->forward('/report/new/redirect_or_confirm_creation', [ 1 ]);
}

$c->cobrand->call_hook('waste_post_report_creation', $report);
$c->cobrand->call_hook('waste_post_report_creation', $report, $data);

$c->user->update({ name => $original_name }) if $original_name;

Expand Down
38 changes: 32 additions & 6 deletions perllib/FixMyStreet/App/Form/Waste/Request/Brent.pm
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,6 @@ has_page about_you => (
next => 'summary',
);

has_page request_refuse_call_us => (
fields => [],
template => 'waste/refuse_call_us.html',
);

has_page request_extra_refusal => (
fields => [],
template => 'waste/refuse_extra_container.html',
Expand All @@ -70,6 +65,10 @@ has_page replacement => (
my $choice = $data->{"container-choice"};
my $reason = $data->{request_reason};

if ($choice == $CONTAINER_GREY_BIN && $reason eq 'extra') {
return 'request_extra_refusal' if $data->{refuse_outcome};
return 'request_refuse_container';
}
return 'about_you' if $choice == $CONTAINER_CLEAR_SACK;
return 'how_long_lived' if $reason eq 'new_build';
return 'request_extra_refusal' if $reason eq 'extra' && $data->{ordered_previously};
Expand Down Expand Up @@ -146,7 +145,7 @@ sub options_request_reason {
push @options, { value => 'damaged', label => 'My container is damaged' };
push @options, { value => 'missing', label => 'My container is missing' };
} else {
push @options, { value => 'new_build', label => 'I am a new resident without a container' };
push @options, { value => 'new_build', label => 'I am a new resident without a container' } unless $choice == $CONTAINER_GREY_BIN;
push @options, { value => 'damaged', label => 'My container is damaged' };
push @options, { value => 'missing', label => 'My container is missing' };
push @options, { value => 'extra', label => 'I would like an extra container' };
Expand All @@ -171,6 +170,33 @@ has_field how_long_lived => (
],
);

has_page request_refuse_container => (
title => 'Household details',
intro => 'refuse_call_us.html',
fields => [ 'property_people', 'property_children', 'continue'],
next => 'about_you',
);

has_field property_people =>(
required => 1,
type => 'Select',
label => 'How many people live at your property?',
options => [
{ value => '1', label => 'Up to 5' },
{ value => '6', label => '6 or more' }
],
);

has_field property_children =>(
required => 1,
type => 'Select',
label => 'Do any children live at the property?',
options => [
{ value => 'No', label => 'No' },
{ value => 'Yes', label => 'Yes' }
],
);

has_field submit => (
type => 'Submit',
value => 'Request container',
Expand Down
60 changes: 58 additions & 2 deletions perllib/FixMyStreet/Cobrand/Brent.pm
Original file line number Diff line number Diff line change
Expand Up @@ -1228,6 +1228,9 @@ sub waste_munge_request_form_fields {
next unless $key =~ /^container-(\d+)/;
my $id = $1;
my ($cost, $hint) = $self->request_cost($id);
if (!$hint) {
$hint = $id == $CONTAINER_IDS{rubbish_grey_bin} ? 'Chargeable - Subject to approval' : '';
}
push @radio_options, {
value => $id,
label => $self->{c}->stash->{containers}->{$id},
Expand Down Expand Up @@ -1291,7 +1294,7 @@ sub waste_munge_request_data {

my $c = $self->{c};

for (qw(how_long_lived contamination_reports ordered_previously)) {
for (qw(how_long_lived contamination_reports ordered_previously property_people property_children)) {
$c->set_param("request_$_", $data->{$_} || '');
}
if (request_referral($id, $data)) {
Expand Down Expand Up @@ -1357,6 +1360,20 @@ sub request_referral {
# return 1 if ($data->{contamination_reports} || 0) >= 3; # Will be present on missing only
return 1 if ($data->{how_long_lived} || '') eq '3more'; # Will be present on new build only
return 1 if $data->{ordered_previously};

if (
( ($data->{'container-choice'} && $data->{'container-choice'} == $CONTAINER_IDS{rubbish_grey_bin})
|| $data->{'container-' . $CONTAINER_IDS{rubbish_grey_bin}}
)
) {
if ($data->{request_reason} eq 'extra') {
if ($data->{property_people} == 6 || $data->{property_children} eq 'Yes') {
return 1;
}
} else {
return 1;
}
}
}

sub waste_request_form_first_title { 'Which container do you need?' }
Expand All @@ -1366,7 +1383,26 @@ sub waste_request_form_first_next {
return sub {
my $data = shift;
my $choice = $data->{"container-choice"};
return 'request_refuse_call_us' if $choice == $CONTAINER_IDS{rubbish_grey_bin};
if ($choice == $CONTAINER_IDS{rubbish_grey_bin}) {
my $date = DateTime->now()->subtract( weeks => 2 );
my $parser = DateTime::Format::Strptime->new( pattern => '%Y-%m-%d');
my $c = $self->{c};
$data->{refuse_outcome} = $c->cobrand->problems->search(
{
category => 'Request new container',
title => ['Request new General rubbish bin (grey bin)'],
confirmed => { '>=', $parser->format_datetime($date) },
uprn => $c->stash->{property}{uprn},
}
)->first;
};
if ($data->{refuse_outcome}) {
if ($data->{refuse_outcome}->get_extra_field_value('request_referral')) {
$data->{refuse_outcome} = 'referral';
} else {
$data->{refuse_outcome} = 'capacity';
}
};
return 'replacement';
};
}
Expand Down Expand Up @@ -1493,6 +1529,26 @@ sub waste_garden_mod_params {
}
}


sub waste_post_report_creation {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the detail parts of this would be better done in waste_munge_request_data which sets the detail in the first place.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This one hasn't been done, but don't think it really matters, happy to leave it here for now.

my ($self, $report, $data) = @_;

if (
$report->title =~ /Request new General rubbish bin \(grey bin\)/
&& $data->{request_reason} eq 'extra'
) {

if ($report->get_extra_field_value('request_referral')) {
$report->detail('Request forwarded to Brent Council by email');
} else {
$self->{c}->stash->{brent_request_automatic} = 1;
$report->detail('Request automatically calculated');
$report->state('fixed - council');
}
$report->update;
}
};

=item * Uses custom text for the title field for new reports.

=cut
Expand Down
78 changes: 74 additions & 4 deletions t/cobrand/brent.t
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,8 @@ create_contact({ category => 'Request new container', email => 'request@example.
{ code => 'request_how_long_lived', required => 0, automated => 'hidden_field' },
{ code => 'request_ordered_previously', required => 0, automated => 'hidden_field' },
{ code => 'request_contamination_reports', required => 0, automated => 'hidden_field' },
{ code => 'request_property_people', required => 0, automated => 'hidden_field' },
{ code => 'request_property_nappies', required => 0, automated => 'hidden_field' },
);
create_contact({ category => 'Assisted collection add', email => 'Echo-assisted' },
{ code => 'Notes', description => 'Additional notes', required => 0, datatype => 'text' },
Expand Down Expand Up @@ -1281,10 +1283,6 @@ FixMyStreet::override_config {
$mech->content_contains('Request a recycling container');
$mech->follow_link_ok({url => 'http://brent.fixmystreet.com/waste/12345/request'});

$mech->submit_form_ok({ with_fields => { 'container-choice' => 16 } }, "Choose refuse bin");
$mech->content_contains('Apply for a new/replacement refuse bin');
$mech->back;

$mech->submit_form_ok({ with_fields => { 'container-choice' => 13 } }, "Choose garden bin");
$mech->content_contains("Why do you need a replacement container?");
$mech->content_contains("My container is damaged", "Can report damaged container");
Expand Down Expand Up @@ -1343,6 +1341,78 @@ FixMyStreet::override_config {
restore_time();
};

subtest 'test requesting a replacement refuse container' => sub {
$mech->get_ok('/waste/12345');
$mech->follow_link_ok({url => 'http://brent.fixmystreet.com/waste/12345/request'});
$mech->submit_form_ok({ with_fields => { 'container-choice' => 16 } }, "Choose refuse bin");
$mech->submit_form_ok({ with_fields => { 'request_reason' => 'damaged' } }, "Request replacement for damaged refuse container");
$mech->submit_form_ok({ with_fields => { name => "Test McTest", email => $user1->email } });
$mech->submit_form_ok({ with_fields => { 'process' => 'summary' } });
$mech->content_contains('Your container request has been sent');
my ($report) = FixMyStreet::DB->resultset('Problem')->search(
{
category => 'Request new container',
title => ['Request new General rubbish bin (grey bin)'],
}
);
is $report->get_extra_field_value('request_referral'), 1, "Damaged refuse container is a referral";
$report->delete;
};

subtest 'test requesting an extra refuse container' => sub {
for my $test (
{ children => 'Yes', detail => 'Request forwarded to Brent Council by email', referral => 1},
{ children => 'No', detail => 'Request automatically calculated', referral => ''},
) {
FixMyStreet::DB->resultset('Problem')->search(
{
category => 'Request new container',
title => ['Request new General rubbish bin (grey bin)'],
}
)->delete;
$mech->get_ok('/waste/12345');
$mech->follow_link_ok({url => 'http://brent.fixmystreet.com/waste/12345/request'});
$mech->submit_form_ok({ with_fields => { 'container-choice' => 16 } }, "Choose refuse bin");
$mech->content_contains("Why do you need a replacement container?");
$mech->content_contains("My container is damaged", "Can report damaged container");
$mech->content_contains("I would like an extra container", "Can not request an extra container");
$mech->content_contains("My container is missing", "Can report missing container");
$mech->content_lacks("I am a new resident without a container", "Can not request new container as new resident");
$mech->submit_form_ok({ with_fields => { 'request_reason' => 'extra' } }, "Request extra container");
$mech->content_contains('Household details', "Questions for extra refuse container");
$mech->submit_form_ok({ with_fields =>
{
'property_people' => 'Up to 5' ,
'property_children' => $test->{children},
},
}, "Request extra container");
$mech->submit_form_ok({ with_fields => { name => "Test McTest", email => $user1->email } });
$mech->submit_form_ok({ with_fields => { 'process' => 'summary' } });
if ($test->{referral}) {
$mech->content_contains('Your container request has been sent');
$mech->content_contains('contact you to let you know if your request has been approved');
} else {
$mech->content_lacks('Your container request');
$mech->content_lacks('contact you to let you know if your request has been approved');
$mech->content_contains('Your property meets current general waste bin capacity requirements');
}
$mech->content_lacks('A copy has been sent to your email address');
my ($report) = FixMyStreet::DB->resultset('Problem')->search({ category => 'Request new container' })->order_by('-id')->first;
is $report->detail, $test->{detail};
is $report->get_extra_field_value('request_referral'), $test->{referral}, "Correct referral status";
is $report->state, $test->{referral} ? 'confirmed' : 'fixed - council';
$mech->get_ok('/waste/12345');
$mech->follow_link_ok({url => 'http://brent.fixmystreet.com/waste/12345/request'});
$mech->submit_form_ok({ with_fields => { 'container-choice' => 16 } }, "Choose refuse bin");
$mech->submit_form_ok({ with_fields => { 'request_reason' => 'extra' } }, "Request extra container");
if ($test->{referral}) {
$mech->content_contains('We are unable to complete your request because our records show a similar container');
} else {
$mech->content_contains('Your property meets current general waste bin capacity requirements');
}
};
};

subtest 'test requesting a container with payment' => sub {
for my $test (
# { id => 11, name => 'food waste caddy', service_id => 316, pence_cost => 500 },
Expand Down
19 changes: 19 additions & 0 deletions templates/web/base/waste/confirmation.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
IF report.category == 'Request new container' || report.category == 'Request container removal';
IF cobrand.moniker == 'bexley';
title = 'Your bin request has been sent';
ELSIF cobrand.moniker == 'brent' AND brent_request_automatic;
title = '';
ELSE;
title = 'Your container request has been sent';
END;
Expand All @@ -14,11 +16,27 @@
END ~%]
[% PROCESS 'waste/header.html' %]

[% IF report.category == 'Request new container' && c.cobrand.moniker == 'brent' && brent_request_automatic %]
<div class="govuk-panel govuk-panel--warning">
[% ELSE %]
<div class="govuk-panel govuk-panel--confirmation">
[% END %]
<h1 class="govuk-panel__title">
[% title %]
</h1>
<div class="govuk-panel__body">
[% IF report.category == 'Request new container' && c.cobrand.moniker == 'brent' %]
[% IF NOT brent_request_automatic %]
<p class="govuk-body">Your application has been sent to Brent Council who will
contact you to let you know if your request has been approved. If it has, they will need
to take payment before any bins can be delivered.
</p>
[% ELSE %]
<p class="govuk-body">
Your property meets current general waste bin capacity requirements.
</p>
[% END %]
[% ELSE %]
<p>
[% IF report.user.email && report.get_extra_metadata('contributed_as') != 'anonymous_user' %]
A copy has been sent to your email address, [% report.user.email %].
Expand All @@ -30,6 +48,7 @@ <h1 class="govuk-panel__title">
[% END %]
[% INCLUDE 'waste/_report_ids.html' %]
</p>
[% END %]
</div>
</div>

Expand Down
25 changes: 23 additions & 2 deletions templates/web/base/waste/summary_request.html
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,29 @@
[% IF data.$removal_key %][% data.$removal_key %] to remove[% END %]
</dd>
[% END %]
</div>
[% END %]
</div>
[% IF c.cobrand.moniker == 'brent' AND containers.$container_id == 'General rubbish bin (grey bin)' AND data.request_reason == 'extra' %]
<div class="govuk-summary-list__row">
<dt class="govuk-summary-list__key">Household details</dt>
<dd class="govuk-summary-list__value"></dd>
<dd class="govuk-summary-list__actions">
<form method="post">
<input type="hidden" name="saved_data" value="[% form.fif.saved_data %]">
<input type="hidden" name="goto" value="request_refuse_container">
<input type="submit" class="govuk-button govuk-button--secondary govuk-!-margin-bottom-0" value="Change answers">
</form>
</dd>
</div>
<div class="govuk-summary-list__row">
<dt class="govuk-summary-list__key govuk-summary-list__key--sub">People at propery</dt>
<dd class="govuk-summary-list__value">[% label_for_field(form, 'property_people', data.property_people) %]</dd>
</div>
<div class="govuk-summary-list__row">
<dt class="govuk-summary-list__key govuk-summary-list__key--sub">Children at property</dt>
<dd class="govuk-summary-list__value">[% label_for_field(form, 'property_children', data.property_children) %]</dd>
</div>
[% END %]
[% END %]
[% FOR removal IN data.keys.grep('^removal-') %]
[% SET container_key = removal.replace('removal-', 'container-') %]
[% SET container_id = removal.replace('removal-', '') %]
Expand Down
12 changes: 0 additions & 12 deletions templates/web/brent/waste/refuse_call_us.html
Original file line number Diff line number Diff line change
@@ -1,11 +1,3 @@
[% USE date(format='%Y%m%d') ~%]
[% PROCESS 'waste/header.html' %]
[% IF property %]
[% INCLUDE 'waste/_address_display.html' %]
[% END %]

<h1 class="govuk-heading-xl">Please complete this form to apply for a new/replacement refuse bin</h1>

<p class="govuk-body">New and replacement rubbish bins cost:</p>
<ul class="govuk-list govuk-list--bullet">
<li>£65 for a 140 litre bin</li>
Expand All @@ -21,7 +13,3 @@ <h1 class="govuk-heading-xl">Please complete this form to apply for a new/replac
<a href="https://www.legislation.gov.uk/ukpga/1990/43/section/46" target="_blank">Section 46 of the Environmental Protection Act 1990</a>.
</p>

<p class="govuk-body"><a class="btn" href="https://brent-self.achieveservice.com/en/AchieveForms/?form_uri=sandbox-publish://AF-Form-cbd6c86f-4b36-47e5-b571-c86e6fcefaef/definition.json&redirectlink=%2Fen&cancelRedirectLink=%2Fen&consentMessage=yes">Apply for a new/replacement refuse bin</a>
</p>

[% INCLUDE footer.html %]
8 changes: 6 additions & 2 deletions templates/web/brent/waste/refuse_extra_container.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,12 @@
<h1 class="govuk-heading-xl">Request new container</h1>

<p class="govuk-body">
We are unable to complete your request because our records show a similar container was recently ordered to this address.
If you require further assistance, please email [% c.cobrand.feature('open311_email').item("Request new container") %].
[% IF form.saved_data.refuse_outcome AND form.saved_data.refuse_outcome == 'capacity' %]
Your property meets current general waste bin capacity requirements.
[% ELSE %]
We are unable to complete your request because our records show a similar container was recently ordered to this address.
If you require further assistance, please email [% c.cobrand.feature('open311_email').item("Request new container") %].
[% END %]
</p>

[% INCLUDE footer.html %]
Loading
Loading