Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Merton] Bin not being returned correctly and waste spillage #5252

Merged
merged 1 commit into from
Dec 11, 2024
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
3 changes: 3 additions & 0 deletions perllib/FixMyStreet/App/Controller/Waste.pm
Original file line number Diff line number Diff line change
Expand Up @@ -1098,6 +1098,9 @@ sub enquiry : Chained('property') : Args(0) {
} elsif ($datatype eq 'multivaluelist') {
my @options = map { { label => $_->{name}, value => $_->{key} } } @{$_->{values}};
%config = (type => 'Multiple', widget => 'CheckboxGroup', options => \@options);
} elsif ($datatype eq 'singlevaluelist') {
my @options = map { { label => $_->{name}, value => $_->{key} } } @{$_->{values}};
%config = (type => 'Select', widget => 'RadioGroup', options => \@options);
}

my $required = $_->{required} eq 'true' ? 1 : 0;
Expand Down
11 changes: 9 additions & 2 deletions perllib/FixMyStreet/Cobrand/Merton/Waste.pm
Original file line number Diff line number Diff line change
Expand Up @@ -370,8 +370,15 @@ sub waste_munge_enquiry_data {
$data->{title} = $data->{category};

my $detail;
foreach (sort grep { /^extra_/ } keys %$data) {
$detail .= "$data->{$_}\n\n";
if ($data->{category} eq 'Bin not returned') {
$detail .= ($data->{'extra_Report_Type'} eq '1' ? 'Bin position' : 'Lid not closed') . "\n\n";
$detail .= ($data->{'extra_Crew_Required_to_Return?'} eq '1' ? 'Request bin collectors return'
: 'No request for bin collectors return') ."\n\n";
$detail .= ($data->{'extra_Notes'} ? $data->{'extra_Notes'} : '') . "\n\n";
} else {
foreach (sort grep { /^extra_/ } keys %$data) {
$detail .= "$data->{$_}\n\n";
}
}
$detail .= $address;
$data->{detail} = $detail;
Expand Down
76 changes: 76 additions & 0 deletions t/app/controller/waste_merton.t
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,23 @@ create_contact({ category => 'Request additional collection', email => 'addition
{ code => 'service_id', required => 1, automated => 'hidden_field' },
{ code => 'fixmystreet_id', required => 1, automated => 'hidden_field' },
);
create_contact({ category => 'Bin not returned', email => '1570' }, 'Waste',
{ code => 'Report_Type', required => 1, datatype => 'singlevaluelist',
values => [
{ 'name' => 'Bin Position', 'key' => '1'},
{ 'name' => 'Lid Not Closed', 'key' => '2'}
] },
{ code => 'Crew_Required_to_Return?', required => 1, datatype => 'singlevaluelist',
values => [
{ 'name' => 'Yes', 'key' => '1'},
{ 'name' => 'No', 'key' => '0'}
] },
{ code => 'Notes', description => 'Details', required => 0, datatype => 'text' },
);
create_contact({ category => 'Waste spillage', email => '1545' }, 'Waste',
{ code => 'Notes', description => 'Details', required => 0, datatype => 'text' },
);

my $no_echo_contact = $mech->create_contact_ok(
body => $merton,
category => 'No Echo',
Expand Down Expand Up @@ -552,6 +569,65 @@ FixMyStreet::override_config {
$e->mock('GetEventsForObject', sub { [] }); # reset
};

subtest 'test report a problem' => sub {
dracos marked this conversation as resolved.
Show resolved Hide resolved
FixMyStreet::Script::Reports::send();
$mech->clear_emails_ok;
$mech->get_ok('/waste/12345');
$mech->content_contains('Report a problem with a non-recyclable waste collection', 'Can report a problem with non-recyclable waste');
$mech->content_contains('Report a problem with a food waste collection', 'Can report a problem with food waste');
my $root = HTML::TreeBuilder->new_from_content($mech->content());
my $panel = $root->look_down(id => 'panel-2240');
is $panel->as_text =~ /.*Please note that missed collections can only be reported.*/, 1, "Paper and card past reporting deadline";
$mech->content_lacks('Report a problem with a paper and card collection', 'Can not report a problem with paper and card as past reporting deadline');
$mech->content_lacks('Report a problem with a textiles and shoes collection', 'Can not report a problem with a textiles collection as orange bags');
$mech->content_lacks('Report a problem with a batteries collection', 'Can not report a problem with a batteries collection as orange bagss');
$mech->follow_link_ok({ text => 'Report a problem with a non-recyclable waste collection' });
$mech->submit_form_ok( { with_fields => { category => 'Bin not returned' } });
$mech->submit_form_ok( { with_fields => { extra_Report_Type => '1', 'extra_Crew_Required_to_Return?' => '0' } });
$mech->submit_form_ok( { with_fields => { name => 'Joe Schmoe', email => '[email protected]' } });
$mech->submit_form_ok( { with_fields => { submit => '1' } });
$mech->content_contains('Your enquiry has been submitted');
$mech->content_contains('Show upcoming bin days');
$mech->content_contains('/waste/12345"');
my $report = FixMyStreet::DB->resultset("Problem")->search(undef, { order_by => { -desc => 'id' } })->first;
is $report->get_extra_field_value('Notes'), '', "Blank notes field is empty string";
is $report->detail, "Bin position\n\nNo request for bin collectors return\n\n2 Example Street, Merton, KT1 1AA", "Details of report contain information about problem";
is $report->user->email, '[email protected]', 'User details added to report';
is $report->name, 'Joe Schmoe', 'User details added to report';
is $report->category, 'Bin not returned', "Correct category";
FixMyStreet::Script::Reports::send();
my $email = $mech->get_email;
is $mech->get_text_body_from_email($email) =~ /Your report over the problem with your bin collection has been made to the council/, 1, 'Other problem text included in email';
my $req = Open311->test_req_used;
my $cgi = CGI::Simple->new($req->content);
is $cgi->param('api_key'), 'KEY';
is $cgi->param('attribute[Report_Type]'), '1', "Report_Type added to open311 data for Echo";
is $cgi->param('attribute[Crew_Required_to_Return?]'), '0', "Crew_Required_to_Return? added to open311 data for Echo";
$mech->get_ok('/waste/12345');
$mech->follow_link_ok({ text => 'Report a problem with a non-recyclable waste collection' });
$mech->submit_form_ok( { with_fields => { category => 'Waste spillage' } });
$mech->submit_form_ok( { with_fields => { extra_Notes => 'Rubbish left on driveway' } });
$mech->submit_form_ok( { with_fields => { name => 'Joe Schmoe', email => '[email protected]' } });
$mech->submit_form_ok( { with_fields => { submit => '1' } });
$mech->content_contains('Your enquiry has been submitted');
$mech->content_contains('Show upcoming bin days');
$mech->content_contains('/waste/12345"');
$report = FixMyStreet::DB->resultset("Problem")->search(undef, { order_by => { -desc => 'id' } })->first;
is $report->category, 'Waste spillage', "Correct category";
is $report->get_extra_field_value('Notes'), 'Rubbish left on driveway', "Notes filled in";
is $report->detail, "Rubbish left on driveway\n\n2 Example Street, Merton, KT1 1AA", "Details of report contain information about problem";
is $report->user->email, '[email protected]', 'User details added to report';
is $report->name, 'Joe Schmoe', 'User details added to report';
$mech->clear_emails_ok;
FixMyStreet::Script::Reports::send();
$email = $mech->get_email;
is $mech->get_text_body_from_email($email) =~ /Your report over the problem with your bin collection has been made to the council/, 1, 'Other problem text included in email';
$req = Open311->test_req_used;
$cgi = CGI::Simple->new($req->content);
is $cgi->param('api_key'), 'KEY';
is $cgi->param('attribute[Notes]'), 'Rubbish left on driveway', "Notes added to open311 data for Echo";
};

subtest 'test staff-only additional collection' => sub {
$mech->log_in_ok($staff_user->email);
$mech->get_ok('/waste/12345');
Expand Down
5 changes: 5 additions & 0 deletions templates/email/default/waste/other-reported.html
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,11 @@ <h1 style="[% h1_style %]">Your report has been&nbsp;logged</h1>
<strong>Use track your request link to check for your scheduled delivery date.</strong>
</p>

[% ELSIF cobrand.moniker == 'merton' AND (report.category == 'Waste spillage' OR report.category == 'Bin not returned') %]
<p style="[% p_style %]">
Your report over the problem with your bin collection has been made to the council.
</p>

[% ELSE %]

[% IF report.category == 'Report missed collection' %]
Expand Down
3 changes: 3 additions & 0 deletions templates/email/default/waste/other-reported.txt
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@ On delivery day - You do not need to be home for our crew to deliver the bin.
Collecting your old bin - If you've requested a collection of your old bin, we'll schedule a specific date for our
crew to remove it. We aim for this to be the same day as we deliver your new bin, but it could be a different day.

[% ELSIF cobrand.moniker == 'merton' AND (report.category == 'Waste spillage' OR report.category == 'Bin not returned') %]
Your report over the problem with your bin collection has been made to the council.

[% ELSE %]

[% IF report.category == 'Report missed collection' %]
Expand Down
5 changes: 4 additions & 1 deletion templates/web/base/waste/services.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
A [% unit.service_name FILTER lower %] container request has been made
</span>

[% IF c.cobrand.moniker == 'merton' %]
[% IF c.cobrand.moniker == 'merton' %]
[% IF NOT (property_time_banded AND unit.service_id == 2242) %]
<a href="[% c.uri_for_action('waste/enquiry', [ property.id ]) %]?category=Failure+to+deliver&amp;service_id=[% unit.service_id %]" class="waste-service-link waste-service-descriptor">Report a failure to deliver a [% unit.service_name FILTER lower %] container</a>
[% END %]
Expand All @@ -28,6 +28,9 @@
[% IF is_staff AND NOT unit.orange_bag %]
<a href="[% c.uri_for_action('waste/report', [ property.id ]) %]?additional=1&amp;service-[% unit.service_id %]=1" class="waste-service-link waste-service-descriptor">Request an additional [% unit.service_name FILTER lower %] collection</a>
[% END %]
[% IF NOT unit.orange_bag AND unit.report_allowed %]
<a href="[% c.uri_for_action('waste/enquiry', [ property.id ]) %]?template=problem&amp;service_id=[% unit.service_id %]" class="waste-service-link waste-service-descriptor">Report a problem with a [% unit.service_name FILTER lower %] collection</a>
[% END %]
[% END %]

[% IF unit.garden_waste %]
Expand Down
7 changes: 7 additions & 0 deletions templates/web/merton/waste/enquiry-problem.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
[% PROCESS waste/enquiry.html
title = 'Report a problem'
field_options = [
{ value = 'Bin not returned', label = 'Bin not returned correctly' },
{ value = 'Waste spillage', label = 'Waste spillage' },
]
%]
Loading