Skip to content

Commit

Permalink
squash! [Bexley] Spot open container requests.
Browse files Browse the repository at this point in the history
Separate delivery/collection.
  • Loading branch information
dracos committed Nov 4, 2024
1 parent 903aff9 commit 094b267
Show file tree
Hide file tree
Showing 4 changed files with 75 additions and 34 deletions.
42 changes: 21 additions & 21 deletions perllib/FixMyStreet/Cobrand/Bexley/Waste.pm
Original file line number Diff line number Diff line change
Expand Up @@ -396,24 +396,20 @@ sub bin_services_for_address {
$filtered_service->{schedule} = 'Weekly';
}

my $report_details = $property->{open_reports}{missed}
{ $filtered_service->{service_id} };

if ($report_details) {
$filtered_service->{report_details} = $report_details;
$filtered_service->{report_open} = $report_details->{open};
} else {
$filtered_service->{report_open} = 0;
}

my $request_details = $property->{open_reports}{request}
{ $filtered_service->{service_id} };
foreach (
{ type => 'missed', open => 'report_open', details => 'report_details' },
{ type => 'deliver', open => 'deliver_open', details => 'deliver_details' },
{ type => 'collect', open => 'collect_open', details => 'collect_details' },
) {
my $details = $property->{open_reports}{$_->{type}}
{ $filtered_service->{service_id} };

if ($request_details) {
$filtered_service->{request_details} = $request_details;
$filtered_service->{requests_open} = $request_details->{open};
} else {
$filtered_service->{requests_open} = 0;
if ($details) {
$filtered_service->{$_->{details}} = $details;
$filtered_service->{$_->{open}} = $details->{open};
} else {
$filtered_service->{$_->{open}} = 0;
}
}

$filtered_service->{report_locked_out} = 0;
Expand Down Expand Up @@ -497,7 +493,8 @@ sub _open_reports {
unless $ws->{WorksheetStatusName} eq 'Open'
&& $ws->{WorksheetSubject} =~ /^Missed|Deliver|Collect/;

my $type = $ws->{WorksheetSubject} =~ /^Missed/ ? 'missed' : 'request';
my $type = $ws->{WorksheetSubject} =~ /^Missed/ ? 'missed'
: $ws->{WorksheetSubject} =~ /Deliver/ ? 'deliver' : 'collect';

# Check if it exists in our DB
my $external_id = 'Whitespace-' . $ws->{WorksheetID};
Expand Down Expand Up @@ -1253,7 +1250,8 @@ sub construct_bin_request_form {

my $request_type = $c->get_param('request_type');
my $property = $c->stash->{property};
my $open_reports = $property->{open_reports}{request};
my $open_deliver = $property->{open_reports}{deliver};
my $open_collect = $property->{open_reports}{collect};

if ( $request_type eq 'delivery' ) {
for my $container (
Expand All @@ -1262,7 +1260,7 @@ sub construct_bin_request_form {
if ( $container->{subtypes} ) {
my $id = $container->{name} =~ s/ /-/gr;

my $disabled = grep { $open_reports->{$_->{service_item_name}} } @{ $container->{subtypes} };
my $disabled = grep { $open_deliver->{$_->{service_item_name}} } @{ $container->{subtypes} };
push @$field_list, "parent-$id" => {
type => 'Checkbox',
label => $container->{name},
Expand All @@ -1286,7 +1284,7 @@ sub construct_bin_request_form {
};
} else {
my $id = $container->{service_item_name} =~ s/ /-/gr;
my $disabled = $open_reports->{$container->{service_item_name}} ? 1 : 0;
my $disabled = $open_deliver->{$container->{service_item_name}} ? 1 : 0;

push @$field_list, "container-$id" => {
type => 'Checkbox',
Expand Down Expand Up @@ -1325,11 +1323,13 @@ sub construct_bin_request_form {
= $container->{subtypes}
? $container->{subtypes}[0]{service_item_name}
: $container->{service_item_name};
my $disabled = $open_collect->{$container->{service_item_name}} ? 1 : 0;

push @$field_list, "container-$id" => {
type => 'Checkbox',
label => $container->{name},
option_label => $container->{description},
disable => $disabled,
};
}
}
Expand Down
15 changes: 10 additions & 5 deletions t/app/controller/waste_bexley.t
Original file line number Diff line number Diff line change
Expand Up @@ -378,7 +378,8 @@ FixMyStreet::override_config {
round_schedule => 'RND-8-9 Mon, RND-8-9 Wed',
round => 'RND-8-9',
report_allowed => 0,
requests_open => 0,
deliver_open => 0,
collect_open => 0,
report_open => 1,
report_details => {
id => ignore(),
Expand All @@ -401,7 +402,8 @@ FixMyStreet::override_config {
round_schedule => 'RND-8-9 Mon, RND-8-9 Wed',
round => 'RND-8-9',
report_allowed => 0,
requests_open => 0,
deliver_open => 0,
collect_open => 0,
report_open => 1,
report_details => {
id => ignore(),
Expand All @@ -424,7 +426,8 @@ FixMyStreet::override_config {
round_schedule => 'RND-1 Tue Wk 1',
round => 'RND-1',
report_allowed => 0,
requests_open => 0,
deliver_open => 0,
collect_open => 0,
report_open => 0,
report_locked_out => 1,
report_locked_out_reason => 'Food - Not Out',
Expand All @@ -439,7 +442,8 @@ FixMyStreet::override_config {
round_schedule => 'RND-6 Wed Wk 2',
round => 'RND-6',
report_allowed => 1,
requests_open => 0,
deliver_open => 0,
collect_open => 0,
report_open => 0,
report_locked_out => 0,
report_locked_out_reason => '',
Expand All @@ -454,7 +458,8 @@ FixMyStreet::override_config {
round_schedule => 'RND-6 Wed Wk 2',
round => 'RND-6',
report_allowed => 1,
requests_open => 0,
deliver_open => 0,
collect_open => 0,
report_open => 0,
report_locked_out => 0,
report_locked_out_reason => '',
Expand Down
28 changes: 26 additions & 2 deletions t/app/controller/waste_bexley_container_requests.t
Original file line number Diff line number Diff line change
Expand Up @@ -788,7 +788,7 @@ FixMyStreet::override_config {
};
};

subtest 'Open container requests' => sub {
subtest 'Open container delivery requests' => sub {
$whitespace_mock->mock( 'GetSiteWorksheets', sub{ [
{ WorksheetID => 'ABC',
WorksheetStatusName => 'Open',
Expand All @@ -806,11 +806,35 @@ FixMyStreet::override_config {
$open_container_request->update;

$mech->get_ok('/waste/10001');
$mech->content_contains("A white recycling box container request has been made");
$mech->content_contains("A white recycling box container delivery request has been made");
$mech->get_ok('/waste/10001/request?request_type=delivery');
$mech->submit_form_ok({ with_fields => { household_size => 2 } });
$mech->content_like(qr/name="container-PG-55"[^>]*disabled/, 'PG-55 option is disabled');
};

# subtest 'Open container container request' => sub {
# $whitespace_mock->mock( 'GetSiteWorksheets', sub{ [
# { WorksheetID => 'ABC',
# WorksheetStatusName => 'Open',
# WorksheetSubject => 'Collect a bin',
# WorksheetStartDate => '',
# WorksheetEscallatedDate => '',
# },
# ] } );

# my ($open_container_request) = $mech->create_problems_for_body(1, $body->id, 'Request new container', {
# external_id => "Whitespace-ABC",
# });
# $open_container_request->set_extra_fields(
# { name => 'service_item_name', value => 'PG-55' } );
# $open_container_request->update;

# $mech->get_ok('/waste/10001');
# $mech->content_contains("A white recycling box container container request has been made");
# $mech->get_ok('/waste/10001/request?request_type=removal');
# $mech->submit_form_ok({ with_fields => { household_size => 2 } });
# $mech->content_like(qr/name="container-PG-55"[^>]*disabled/, 'PG-55 option is disabled');
# };
};

sub _site_info {
Expand Down
24 changes: 18 additions & 6 deletions templates/web/bexley/waste/services.html
Original file line number Diff line number Diff line change
@@ -1,16 +1,28 @@
[% PROCESS 'waste/_services_header.html' %]
[% PROCESS 'waste/_service_missed.html' %]

[% IF unit.requests_open %]
[% IF unit.deliver_open %]
<span class="waste-service-descriptor">
A [% unit.service_name FILTER lower %] container request has been made. Check status below:
A [% unit.service_name FILTER lower %] container delivery request has been made. Check status below:
<ul>
<li>Reported on: [% unit.request_details.reported ? date.format(unit.request_details.reported) : 'N/A' %]</li>
<li>Will be completed by: [% unit.request_details.will_be_completed ? date.format(unit.request_details.will_be_completed) : 'N/A' %]</li>
<li>Action: [% unit.request_details.latest_comment %]</li>
<li>Reported on: [% unit.deliver_details.reported ? date.format(unit.deliver_details.reported) : 'N/A' %]</li>
<li>Will be completed by: [% unit.deliver_details.will_be_completed ? date.format(unit.deliver_details.will_be_completed) : 'N/A' %]</li>
<li>Action: [% unit.deliver_details.latest_comment %]</li>
</ul>
</span>
[% END %]

[% IF unit.collect_open %]
<span class="waste-service-descriptor">
A [% unit.service_name FILTER lower %] container collection request has been made. Check status below:
<ul>
<li>Reported on: [% unit.collect_details.reported ? date.format(unit.collect_details.reported) : 'N/A' %]</li>
<li>Will be completed by: [% unit.collect_details.will_be_completed ? date.format(unit.collect_details.will_be_completed) : 'N/A' %]</li>
<li>Action: [% unit.collect_details.latest_comment %]</li>
</ul>
</span>
[% END %]

[% ELSIF unit.delivery_allowed || unit.removal_allowed %]
[% IF unit.delivery_allowed || unit.removal_allowed %]
[% PROCESS 'waste/_services_request.html' %]
[% END %]

0 comments on commit 094b267

Please sign in to comment.