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

[Notts Police] Allow staff to manage available states #5254

Merged
merged 1 commit into from
Dec 5, 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
32 changes: 32 additions & 0 deletions perllib/FixMyStreet/Cobrand/NottinghamshirePolice.pm
Original file line number Diff line number Diff line change
Expand Up @@ -190,4 +190,36 @@ sub example_places {
return [ 'NG2 3DZ', 'Meadows Way, Nottingham' ];
}

=head2 available_permissions
Add the manage_states permission to the list of available permissions.
=cut

sub available_permissions {
my $self = shift;
my $perms = $self->next::method();
$perms->{Problems}->{manage_states} = "Add/remove states";
return $perms;
}

=head2 admin_pages
Users with the manage_states permission can access the states admin page.
=cut

sub admin_pages {
my $self = shift;
my $pages = $self->next::method();

if ( $self->{c}->user->has_body_permission_to('manage_states') ) {
$pages->{states} = [ _('States'), 102 ];
};

return $pages;
}



1;
19 changes: 19 additions & 0 deletions t/cobrand/nottinghamshirepolice.t
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,25 @@ FixMyStreet::override_config {
$report->discard_changes;
is $report->get_extra_metadata('sent_to_council'), 'Gedling Borough Council';
};

subtest 'check new permission is available' => sub {
$mech->log_in_ok($staff->email);
$staff->user_body_permissions->create({ body => $notts_police, permission_type => 'user_edit' });
$staff->user_body_permissions->create({ body => $notts_police, permission_type => 'user_manage_permissions' });

$mech->get("/admin/users/" . $staff->id);
$mech->content_contains('Add/remove states');
};

subtest 'check states page behind permission' => sub {
$mech->log_in_ok($staff->email);

$mech->get("/admin/states");
is $mech->status, 404, "Staff user can't access states page without permission";

$staff->user_body_permissions->create({ body => $notts_police, permission_type => 'manage_states' });
$mech->get_ok("/admin/states");
};
};

subtest 'Permissions for report updates' => sub {
Expand Down
Loading