Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/tfl-admin-rename-warning'
Browse files Browse the repository at this point in the history
  • Loading branch information
dracos committed Feb 22, 2021
2 parents 72268f7 + 29fb28a commit a54853e
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 1 deletion.
11 changes: 11 additions & 0 deletions perllib/FixMyStreet/Cobrand/TfL.pm
Original file line number Diff line number Diff line change
Expand Up @@ -461,6 +461,17 @@ sub munge_red_route_categories {
}
}

sub is_hardcoded_category {
my ($self, $category) = @_;

my %cats = (
%{ $self->feature('safety_critical_categories') || {} },
map { $_ => 1 } @{ $self->_tlrn_categories }, @{ $self->_tfl_council_categories }, @{ $self->_tfl_no_resend_categories },
);

return $cats{$category};
}

# Reports in these categories can only be made on a red route
sub _tlrn_categories { [
"All out - three or more street lights in a row",
Expand Down
2 changes: 1 addition & 1 deletion t/Mock/MapIt.pm
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ sub dispatch_request {
$self->output({2508 => {parent_area => undef, id => 2508, name => "Hackney Council", type => "LBO"}});
} elsif ($areas eq 'GRE') {
$self->output({2493 => {parent_area => undef, id => 2493, name => "Greenwich Borough Council", type => "LBO"}});
} elsif ($areas eq 'LBO') {
} elsif ($areas eq 'LBO' || $areas eq 'LBO,UTA,DIS') {
$self->output({
2482 => {parent_area => undef, id => 2482, name => "Bromley Borough Council", type => "LBO"},
2483 => {parent_area => undef, id => 2483, name => "Hounslow Borough Council", type => "LBO"},
Expand Down
9 changes: 9 additions & 0 deletions t/cobrand/tfl.t
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,10 @@ $staffuser->user_body_permissions->create({
body => $body,
permission_type => 'default_to_body',
});
$staffuser->user_body_permissions->create({
body => $body,
permission_type => 'category_edit',
});
my $user = $mech->create_user_ok('londonresident@example.com');

my $bromley = $mech->create_body_ok(2482, 'Bromley');
Expand Down Expand Up @@ -681,6 +685,11 @@ subtest 'TfL staff can access TfL admin' => sub {
$mech->log_in_ok( $staffuser->email );
$mech->get_ok('/admin');
$mech->content_contains( 'This is the administration interface for' );
};

subtest 'TLRN categories cannot be renamed' => sub {
$mech->get_ok('/admin/body/' . $body->id . '/Flooding');
$mech->content_contains('This category name is uneditable');
$mech->log_out_ok;
};

Expand Down
16 changes: 16 additions & 0 deletions templates/web/tfl/admin/bodies/_category_field.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
[% SET hardcoded = c.cobrand.is_hardcoded_category(contact.category) ~%]
<p>
<label for="category">[% loc('Category') %]</label>
<input type="text" class="form-control" id="category" name="category"
size="30" value="[% contact.category %]"
[% hardcoded || contact.category_uneditable ? 'readonly' : 'required' %]>
</p>
[% IF hardcoded %]
<div class="fms-admin-warning">
This category name is uneditable as it is either TLRN-only, a council redirect, or a category marked not to resend.<br>Please contact us to edit the name of this category.
</div>
[% END %]

[% IF contact.in_storage %]
<input type="hidden" name="current_category" value="[% current_contact.category | html %]" >
[% END %]

0 comments on commit a54853e

Please sign in to comment.