Skip to content

Commit

Permalink
[Highways England][FMS] Add category checkbox for HE litter
Browse files Browse the repository at this point in the history
Adds a checkbox when creating/editing a category which can be ticked
to indicate that the category should be considered a litter category
when council are responsible for litter on an HE road.

Maintains the status quo with the current default list. This
hopefully removes risk of a council having no checked categories
and so no litter categories showing up.

mysociety/societyworks#3680
  • Loading branch information
MorayMySoc committed Nov 28, 2023
1 parent cf6b2cf commit 97bd53b
Show file tree
Hide file tree
Showing 6 changed files with 75 additions and 81 deletions.
4 changes: 4 additions & 0 deletions docs/_includes/admin-tasks-content.md
Original file line number Diff line number Diff line change
Expand Up @@ -646,6 +646,10 @@ members of staff, not members of the public. This could be used for e.g.
contact centre staff to leave reports in categories that you still want to be
phoned in.

Categories can be marked as a litter category for when the council is responsible
for litter on parts of a Highways England road. This will mean the category
will be included in the Highways England categories for any relevant stretch of road.

You can set up as many or as few categories as you like, and each category can have its own email
address attached to it, so for example, reports about potholes may go to one council email
address, while reports about road signs go to another. More than one category may share the
Expand Down
2 changes: 1 addition & 1 deletion perllib/FixMyStreet/App/Controller/Admin/Bodies.pm
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,7 @@ sub update_contact : Private {
$contact->send_method( $c->get_param('send_method') );

# Set flags in extra to the appropriate values
foreach (qw(photo_required open311_protect updates_disallowed reopening_disallowed assigned_users_only anonymous_allowed prefer_if_multiple phone_required)) {
foreach (qw(photo_required open311_protect updates_disallowed reopening_disallowed assigned_users_only anonymous_allowed prefer_if_multiple phone_required litter_category_for_he)) {
if ( $c->get_param($_) ) {
$contact->set_extra_metadata( $_ => 1 );
} else {
Expand Down
121 changes: 46 additions & 75 deletions perllib/FixMyStreet/Cobrand/HighwaysEngland.pm
Original file line number Diff line number Diff line change
Expand Up @@ -384,81 +384,52 @@ sub dashboard_export_problems_add_columns {

# select distinct category from contacts where category ilike '%litter%' or category ilike '%clean%' or category ilike '%fly%tip%';
# search to find categories in all contacts and then manually edited
sub _cleaning_categories { [
'Accumulated Litter',
'Cleanliness Issue',
'Cleanliness Sub Standard',
'Cleansing',
'Excessive or dangerous littering',
'Fly Tipping on a road, footway, verge or open space',
'Fly Tipping',
'Fly tipping',
'Fly-Tipping',
'Fly-tipping',
'Flytipping and dumped rubbish',
'Flytipping',
'Flytipping/flyposting',
'General (Cleanliness)',
'General Litter / Rubbish Collection',
'General fly tipping',
'Hazardous fly tipping',
'Litter On Road/Street Cleaning',
'Litter and Bins',
'Litter in Parks & Open spaces',
'Litter in the street',
'Litter removal',
'Litter',
'Littering',
'Littering and cleanliness',
'Rubbish or fly tipping on the roads',
'Street Cleaning',
'Street Cleansing',
'Street cleaning and litter',
'Street cleaning',
'Street cleansing',
'Sweeping & Cleansing Hazard',

# Northumberland's litter categories
'Damaged Litter Bin (Litter)',
'Full Litter Bin (Litter)',
'Littering (Litter)',
'Other (Litter)',

#Bench/cycle rack/litter bin/planter,
#Bus Station Cleaning - Floor,
#Bus Station Cleaning - General,
#Bus Station Cleaning - Toilets,
#Bus Station Cleaning - Windows,
#Car Park Cleansing,
#Damage Public Litter Bin,
#Damage to litter bin,
#Dog and litter bins,
#Fly Tipping on a public right of way,
#Fly tipping - Enforcement Request,
#Flytipping (TfL),
#'Flytipping (off-road)',
#'Litter bin damaged',
#'Litter bin full',
#'Litter bin',
#Litter Bin Overflowing,
#Litter Bin on a verge or open space,
#Litter Bin overflow in Parks & Open spaces,
#Litter Bin overflow,
#Litter Bin,
#Litter Bins Full/Damaged/Missing,
#Litter Bins,
#Litter bins,
#Litter or flytipping in a woodland,
#Overflowing Litter Bin / Dog Bin,
#Overflowing Street Litter Bin,
#Overflowing litter bin,
#Pavement cleaning,
#Planter not Clean and Tidy,
#River Piers - Cleaning,
#Shelter needs cleaning (hazardous waste),
#Shelter needs cleaning (not including litter),
#Street Cleaning Enquiry,
] }
sub _cleaning_categories {
my @litter_rs = FixMyStreet::DB->resultset('Contact')->not_deleted->search( { extra => { '@>' => '{"litter_category_for_he":1}' } } )->all;
my @checked_litter_categories = map { $_->category } @litter_rs;
my @default_litter_categories = (
'Accumulated Litter',
'Cleanliness Issue',
'Cleanliness Sub Standard',
'Cleansing',
'Excessive or dangerous littering',
'Fly Tipping on a road, footway, verge or open space',
'Fly Tipping',
'Fly tipping',
'Fly-Tipping',
'Fly-tipping',
'Flytipping and dumped rubbish',
'Flytipping',
'Flytipping/flyposting',
'General (Cleanliness)',
'General Litter / Rubbish Collection',
'General fly tipping',
'Hazardous fly tipping',
'Litter On Road/Street Cleaning',
'Litter and Bins',
'Litter in Parks & Open spaces',
'Litter in the street',
'Litter removal',
'Litter',
'Littering',
'Littering and cleanliness',
'Rubbish or fly tipping on the roads',
'Street Cleaning',
'Street Cleansing',
'Street cleaning and litter',
'Street cleaning',
'Street cleansing',
'Sweeping & Cleansing Hazard',

# Northumberland's litter categories
'Damaged Litter Bin (Litter)',
'Full Litter Bin (Litter)',
'Littering (Litter)',
'Other (Litter)',
);
push(@default_litter_categories, @checked_litter_categories);
return \@default_litter_categories;
}

sub admin_contact_validate_category {
my ( $self, $category ) = @_;
Expand Down
17 changes: 14 additions & 3 deletions t/app/controller/admin/bodies.t
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ $mech->content_contains("http://www.example.org/around");
subtest 'check contact creation' => sub {
$mech->get_ok('/admin/body/' . $body->id);

$mech->submit_form_ok( { with_fields => {
$mech->submit_form_ok( { with_fields => {
category => 'test category',
title_hint => 'example in test category',
email => '[email protected]',
Expand All @@ -54,7 +54,7 @@ subtest 'check contact creation' => sub {
$mech->content_contains( '<td>test note' );
$mech->content_like( qr/<td>\s*unconfirmed\s*<\/td>/ ); # No private

$mech->submit_form_ok( { with_fields => {
$mech->submit_form_ok( { with_fields => {
category => 'private category',
email => '[email protected]',
note => 'test note',
Expand Down Expand Up @@ -152,7 +152,7 @@ subtest 'check contact updating' => sub {
$mech->content_like(qr{test2\@example.com[^<]*</td>[^<]*<td><strong>confirmed}s);
};

$body->update({ send_method => undef });
$body->update({ send_method => undef });

subtest 'check open311 configuring' => sub {
$mech->get_ok('/admin/body/' . $body->id);
Expand Down Expand Up @@ -337,6 +337,17 @@ subtest 'reopen disabling' => sub {
is $contact->get_extra_metadata('reopening_disallowed'), 1, 'Reopening disallowed flag set';
};

subtest 'set HE litter category' => sub {
$mech->get_ok('/admin/body/' . $body->id . '/test%20category');
$mech->submit_form_ok( { with_fields => {
litter_category_for_he => 1,
note => 'Setting litter category for Highways England filtering',
} } );
$mech->content_contains('Values updated');
my $contact = $body->contacts->find({ category => 'test category' });
is $contact->get_extra_metadata('litter_category_for_he'), 1, 'Litter category set for Highways England filtering';
};

subtest 'allow anonymous reporting' => sub {
$mech->get_ok('/admin/body/' . $body->id . '/test%20category');
$mech->content_lacks('Allow anonymous reports');
Expand Down
6 changes: 4 additions & 2 deletions t/cobrand/fixmystreet.t
Original file line number Diff line number Diff line change
Expand Up @@ -465,6 +465,7 @@ FixMyStreet::override_config {
my $he = $mech->create_body_ok(2227, 'National Highways');
$mech->create_contact_ok(body_id => $hampshire->id, category => 'Flytipping', email => 'foo@bexley');
$mech->create_contact_ok(body_id => $hampshire->id, category => 'Trees', email => 'foo@bexley');
$mech->create_contact_ok(body_id => $hampshire->id, category => 'Messy roads', email => 'foo@bexley', extra => {litter_category_for_he => 1});
$mech->create_contact_ok(body_id => $he->id, category => 'Slip Roads (NH)', email => 'litter@he', group => 'Litter');
$mech->create_contact_ok(body_id => $he->id, category => 'Main Carriageway (NH)', email => 'litter@he', group => 'Litter');
$mech->create_contact_ok(body_id => $he->id, category => 'Potholes (NH)', email => 'potholes@he');
Expand Down Expand Up @@ -526,8 +527,9 @@ FixMyStreet::override_config {
my $j = $mech->get_ok_json("/report/new/ajax?w=1&longitude=-0.912160&latitude=51.015143&he_referral=1");
my $tree = HTML::TreeBuilder->new_from_content($j->{category});
my @elements = $tree->find('input');
is @elements, 1, 'Only one category in National Highways category';
is $elements[0]->attr('value') eq 'Flytipping', 1, 'Subcategory is Flytipping';
is @elements, 2, 'Two categories in National Highways category';
is $elements[0]->attr('value') eq 'Flytipping', 1, 'Subcategory is Flytipping - default litter category';
is $elements[1]->attr('value') eq 'Messy roads', 1, 'Subcategory is Messy roads - checkbox selected litter category';
};

subtest "check things redacted appropriately" => sub {
Expand Down
6 changes: 6 additions & 0 deletions templates/web/base/admin/bodies/contact-form.html
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,12 @@
<label for="phone_required">[% loc('Require a phone number to be provided') %]</label>
</p>

<p class="form-check">
<input type="checkbox" name="litter_category_for_he" value="1" id="litter_category_for_he" [% ' checked' IF contact.extra.litter_category_for_he %]>
<label for="litter_category_for_he">[% loc('Is a litter category for the purposes of receiving reports on National Highways roads') %]</label>
<span class='form-hint'>[% loc('Use this if a category should be considered a litter category where a council is responsible for litter on a section of Highways England road') %]</span>
</p>

[% IF body.can_be_devolved %]
<div class="admin-hint">
<p>
Expand Down

0 comments on commit 97bd53b

Please sign in to comment.