MT#60119 allow pbxfielddeveicepreferences to subscriberadmin role

* subscriberadmin role can now CRUD preferences for
  devices that are assigned to the customer.

Change-Id: I09fe3c3b2ed670f0411970dc6402486a3cf6d4be
mr12.4
Kirill Solomko 1 year ago
parent 941c75ebe1
commit f2478178f0

@ -6,7 +6,7 @@ use Sipwise::Base;
use parent qw/NGCP::Panel::Role::Entities NGCP::Panel::Role::API::Preferences/;
__PACKAGE__->set_config({
allowed_roles => [qw/admin reseller/],
allowed_roles => [qw/admin reseller subscriberadmin/],
});
sub allowed_methods{

@ -8,7 +8,7 @@ use parent qw/NGCP::Panel::Role::EntitiesItem NGCP::Panel::Role::API::Preference
__PACKAGE__->set_config({
PATCH => { ops => [qw/add replace remove copy/] },
allowed_roles => {
Default => [qw/admin reseller/],
Default => [qw/admin reseller subscriberadmin/],
Journal => [qw/admin reseller/],
}
});

@ -73,6 +73,8 @@ sub _item_rs {
my $item_rs;
my $type = $self->container_resource_type;
print "TYPE: $type\n";
if($type eq "domains") {
# we actually return the domain rs here, as we can easily
# go to dom_preferences from there
@ -167,12 +169,19 @@ sub _item_rs {
} elsif($type eq "pbxdevices") {
if($c->user->roles eq "admin") {
$item_rs = $c->model('DB')->resultset('autoprov_field_devices');
} else {
} elsif ($c->user->roles eq "reseller") {
$item_rs = $c->model('DB')->resultset('autoprov_field_devices')->search({
'device.reseller_id' => $c->user->reseller_id
},{
'join' => {'profile' => {'config' => 'device'}},
});
} elsif ($c->user->roles eq "subscriberadmin") {
$item_rs = $c->model('DB')->resultset('autoprov_field_devices')->search({
'device.reseller_id' => $c->user->contract->contact->reseller_id,
'me.contract_id' => $c->user->account_id,
},{
'join' => {'profile' => {'config' => 'device'}},
});
}
} elsif($type eq "contracts") {
if ($c->user->roles eq "admin" || $c->user->roles eq "ccareadmin") {

Loading…
Cancel
Save