Skip to content

Commit

Permalink
[Sutton] Bin not being returned and waste spillage
Browse files Browse the repository at this point in the history
  • Loading branch information
dracos committed Jan 22, 2025
1 parent c348828 commit 9720e0d
Show file tree
Hide file tree
Showing 6 changed files with 110 additions and 8 deletions.
19 changes: 19 additions & 0 deletions perllib/FixMyStreet/Cobrand/Sutton.pm
Original file line number Diff line number Diff line change
Expand Up @@ -441,6 +441,25 @@ sub request_cost {
}
}

sub waste_munge_enquiry_data {
my ($self, $data) = @_;
my $address = $self->{c}->stash->{property}->{address};
$data->{title} = $data->{category};

my $detail;
if ($data->{category} eq 'Bin not returned') {
#if ($assisted) {
# if ($not_returned) {
# $data->{extra_Notes} = 'Property is on assisted list';
# }
#}
} elsif ($data->{category} eq 'Waste spillage') {
$detail = "$data->{extra_Notes}\n\n";
}
$detail .= $address;
$data->{detail} = $detail;
}

=head2 Bulky waste collection
Sutton starts collections at 6am, and lets you cancel up until 6am.
Expand Down
71 changes: 71 additions & 0 deletions t/app/controller/waste_sutton_r.t
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ FixMyStreet::App->log->disable('info');
END { FixMyStreet::App->log->enable('info'); }

my $mech = FixMyStreet::TestMech->new;
my $sample_file = path(__FILE__)->parent->child("sample.jpg");

my $bin_data = decode_json(path(__FILE__)->sibling('waste_sutton_4443082.json')->slurp_utf8);
my $bin_140_data = decode_json(path(__FILE__)->sibling('waste_sutton_4443082_140.json')->slurp_utf8);
Expand Down Expand Up @@ -59,6 +60,15 @@ create_contact({ category => 'Request new container', email => '1635' }, 'Waste'
{ code => 'payment_method', required => 0, automated => 'hidden_field' },
{ code => 'payment', required => 0, automated => 'hidden_field' },
);
create_contact({ category => 'Bin not returned', email => '3135' }, 'Waste',
{ code => 'Image', description => 'Image', required => 0, datatype => 'image' },
{ code => 'Exact_Location', description => 'Exact location', required => 0, datatype => 'text' },
{ code => 'Notes', required => 0, automated => 'hidden_field' },
);
create_contact({ category => 'Waste spillage', email => '3227' }, 'Waste',
{ code => 'Image', description => 'Image', required => 0, datatype => 'image' },
{ code => 'Notes', description => 'Details of the spillage', required => 0, datatype => 'text' },
);

my $sent_params;

Expand Down Expand Up @@ -425,6 +435,67 @@ FixMyStreet::override_config {
$mech->content_contains('Put your bags out between 6pm and 8pm');
$e->mock('GetServiceUnitsForObject', sub { $bin_data });
};

subtest 'test report a problem' => sub {
FixMyStreet::Script::Reports::send();
$mech->clear_emails_ok;
$mech->get_ok('/waste/12345');
$mech->content_contains('Report a problem with a non-recyclable refuse 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-948');
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->follow_link_ok({ text => 'Report a problem with a non-recyclable refuse collection' });
$mech->submit_form_ok( { with_fields => { category => 'Bin not returned' } });
$mech->submit_form_ok( { with_fields => { extra_Exact_Location => 'hello' } } );
$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('Return to property details');
$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, "2 Example Street, Sutton, SM1 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[Exact_Location]'), 'hello';
is $cgi->param('attribute[Notes]'), '';
$mech->get_ok('/waste/12345');
$mech->follow_link_ok({ text => 'Report a problem with a non-recyclable refuse collection' });
$mech->submit_form_ok( { with_fields => { category => 'Waste spillage' } });
$mech->submit_form_ok( { with_fields => {
extra_Notes => 'Rubbish left on driveway',
extra_Image => [ $sample_file, undef, Content_Type => 'image/jpeg' ],
} });
$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('Return to property details');
$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, Sutton, SM1 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";
};

};

sub get_report_from_redirect {
Expand Down
10 changes: 5 additions & 5 deletions templates/email/default/waste/other-reported.html
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,11 @@ <h1 style="[% h1_style %]">Your report has been&nbsp;logged</h1>

[%# Nothing here at present %]

[% ELSIF (cobrand.moniker == 'merton' OR cobrand.moniker == 'sutton') 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>

[% ELSIF cobrand.moniker == 'sutton' %]
[% IF report.category == 'Request new container' %]
<p style="[% p_style %]">Due to the current high demand, please allow up to
Expand Down Expand Up @@ -60,11 +65,6 @@ <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
6 changes: 3 additions & 3 deletions templates/email/default/waste/other-reported.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ Your [% subject_type %] to [% report.body %] has been logged.

[%# Nothing here at present %]

[% ELSIF (cobrand.moniker == 'merton' OR cobrand.moniker == 'sutton') 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.

[% ELSIF cobrand.moniker == 'sutton' %]

[% IF report.category == 'Request new container' %]
Expand All @@ -43,9 +46,6 @@ 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: 5 additions & 0 deletions templates/web/base/waste/services.html
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,11 @@
<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 c.cobrand.moniker == 'sutton' %]
[% IF 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/sutton/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' },
]
%]

0 comments on commit 9720e0d

Please sign in to comment.