Skip to content

Commit

Permalink
[SLWP] Separate out two admins.
Browse files Browse the repository at this point in the history
  • Loading branch information
dracos committed Dec 15, 2023
1 parent 3050787 commit 7eedd59
Show file tree
Hide file tree
Showing 5 changed files with 4 additions and 78 deletions.
3 changes: 2 additions & 1 deletion perllib/FixMyStreet/App/Controller/Waste/Echo.pm
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,8 @@ sub receive_echo_event_notification : Path('/waste/echo') : Args(0) {

my @bodies = ($body);
if ($c->cobrand->moniker eq 'kingston') {
push @bodies, $c->cobrand->dashboard_extra_bodies;
my $sutton = FixMyStreet::Cobrand::Sutton->new->body;
push @bodies, $sutton;
}

foreach my $b (@bodies) {
Expand Down
8 changes: 1 addition & 7 deletions perllib/FixMyStreet/Cobrand/Kingston.pm
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,7 @@ sub council_area_id { return 2480; }
sub council_area { return 'Kingston'; }
sub council_name { return 'Kingston upon Thames Council'; }
sub council_url { return 'kingston'; }

sub admin_user_domain { ('kingston.gov.uk', 'sutton.gov.uk') }

sub dashboard_extra_bodies {
my $sutton = FixMyStreet::Cobrand::Sutton->new->body;
return $sutton;
}
sub admin_user_domain { 'kingston.gov.uk' }

=head2 waste_on_the_day_criteria
Expand Down
8 changes: 1 addition & 7 deletions perllib/FixMyStreet/Cobrand/Sutton.pm
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,7 @@ sub council_area_id { return 2498; }
sub council_area { return 'Sutton'; }
sub council_name { return 'Sutton Council'; }
sub council_url { return 'sutton'; }

sub admin_user_domain { ('kingston.gov.uk', 'sutton.gov.uk') }

sub dashboard_extra_bodies {
my $kingston = FixMyStreet::Cobrand::Kingston->new->body;
return $kingston;
}
sub admin_user_domain { 'sutton.gov.uk' }

=head2 waste_on_the_day_criteria
Expand Down
45 changes: 0 additions & 45 deletions perllib/FixMyStreet/Roles/CobrandSLWP.pm
Original file line number Diff line number Diff line change
Expand Up @@ -52,18 +52,6 @@ around problems_restriction => sub {
return $rs;
};

sub problems_on_dashboard {
my ($self, $rs) = @_;

my $bodies = [ $self->body->id ];
my $extra = $self->dashboard_extra_bodies;
push @$bodies, $extra->id if $extra;
$rs = FixMyStreet::DB->resultset('Problem')->to_body($bodies)->search({
"me.cobrand_data" => 'waste',
});
return $rs;
}

=item * When a garden subscription is sent to Echo, we include payment details
=cut
Expand Down Expand Up @@ -141,39 +129,6 @@ around updates_disallowed => sub {
return $orig->($self, $problem);
};

=item * Allow both Kingston and Sutton users access to the cobrand admin
=cut

sub admin_allow_user {
my ( $self, $user ) = @_;
return 1 if $user->is_superuser;
return undef unless defined $user->from_body;
my $user_cobrand = $user->from_body->get_extra_metadata('cobrand', '');
return $user_cobrand =~ /kingston|sutton/;
}

# Let Kingston/Sutton staff users share permissions
sub permission_body_override {
my ($self, $body_ids) = @_;

my $kingston = FixMyStreet::Cobrand::Kingston->new->body;
my $sutton = FixMyStreet::Cobrand::Sutton->new->body;
return unless $kingston && $sutton;

my @out = map {
if ($kingston->id == $_) {
($_, $sutton->id);
} elsif ($sutton->id == $_) {
($_, $kingston->id);
} else {
$_;
}
} @$body_ids;

return \@out;
}

sub state_groups_admin {
[
[ New => [ 'confirmed' ] ],
Expand Down
18 changes: 0 additions & 18 deletions t/app/controller/waste_sutton_r.t
Original file line number Diff line number Diff line change
Expand Up @@ -287,24 +287,6 @@ FixMyStreet::override_config {
};
};

FixMyStreet::override_config {
ALLOWED_COBRANDS => ['kingston', 'sutton'],
MAPIT_URL => 'http://mapit.uk/',
}, sub {
subtest 'Kingston staff can see Sutton admin' => sub {
$mech->host('sutton.example.org');
$mech->log_in_ok($staff->email);
$mech->get_ok('/admin/reports');
$mech->follow_link_ok({ text => "Edit" });
};
subtest 'Kingston staff can see Sutton data on their dashboard' => sub {
$mech->host('kingston.example.org');
$mech->get_ok('/dashboard?body=' . $body->id);
$mech->content_like(qr{<th scope="row">Total</th>\s*<td>4</td>});
$mech->submit_form_ok;
};
};

sub shared_echo_mocks {
my $e = Test::MockModule->new('Integrations::Echo');
$e->mock('GetPointAddress', sub {
Expand Down

0 comments on commit 7eedd59

Please sign in to comment.