MT#64923 callforward sets add own boolean field

* /api/callforwards (per set),
  /api/cfdestinationsets,
  /api/cfsourcesets,
  /api/cfbnumbersets,
  /api/cftimesets
  return "own" field for subscriber and subscriberadmin roles only,
  this field indicates if the call forward set belongs to the same
  subscriber that requests it.
* /api/callforwards fix default value for 'cfr' and 'cfo' cftypes
  from null to {}, to match all the other cftype default values.

Change-Id: I9c5c60dfb16301703341c1ba17c751079f79ae8b
mr26.1
Kirill Solomko 3 months ago
parent d1173ba613
commit ce12aed828

@ -15,6 +15,11 @@ has_field 'name' => (
},
);
has_field 'own' => (
type => 'PosInteger',
do_label => 0,
);
has_field 'mode' => (
type => 'Select',
options => [

@ -17,6 +17,11 @@ has_field 'name' => (
},
);
has_field 'own' => (
type => 'PosInteger',
do_label => 0,
);
has_field 'destinations' => (
type => 'Repeatable',
element_attr => {

@ -15,6 +15,11 @@ has_field 'name' => (
},
);
has_field 'own' => (
type => 'PosInteger',
do_label => 0,
);
has_field 'mode' => (
type => 'Select',
options => [

@ -12,6 +12,11 @@ has_field 'name' => (
required => 1,
);
has_field 'own' => (
type => 'PosInteger',
do_label => 0,
);
has_field 'times' => (
type => 'Repeatable',
do_wrapper => 1,

@ -89,6 +89,10 @@ sub resource_from_item {
}
$resource->{bnumbers} = \@bnumbers;
if ($c->user->roles eq 'subscriber' || $c->user->roles eq 'subscriberadmin') {
$resource->{own} = $item->subscriber_id == $c->user->id ? 1 : 0;
}
return $resource;
}

@ -51,6 +51,10 @@ sub hal_from_item {
my $b_subs_id = $item->subscriber->voip_subscriber->id;
$resource{subscriber_id} = $b_subs_id;
if ($c->user->roles eq 'subscriber' || $c->user->roles eq 'subscriberadmin') {
$resource{own} = $item->subscriber_id == $c->user->id ? 1 : 0;
}
my $hal = Data::HAL->new(
links => [
Data::HAL::Link->new(

@ -41,6 +41,10 @@ sub hal_from_item {
my $b_subs_id = $item->subscriber->voip_subscriber->id;
$resource{subscriber_id} = $b_subs_id;
if ($c->user->roles eq 'subscriber' || $c->user->roles eq 'subscriberadmin') {
$resource{own} = $item->subscriber_id == $c->user->id ? 1 : 0;
}
my $hal = Data::HAL->new(
links => [
Data::HAL::Link->new(

@ -318,6 +318,10 @@ sub hal_from_item {
my $b_subs_id = $item->subscriber->voip_subscriber->id;
$resource{subscriber_id} = $b_subs_id;
if ($c->user->roles eq 'subscriber' || $c->user->roles eq 'subscriberadmin') {
$resource{own} = $item->subscriber_id == $c->user->id ? 1 : 0;
}
my $hal = Data::HAL->new(
links => [
Data::HAL::Link->new(

@ -52,7 +52,7 @@ sub hal_from_item {
prov_subscriber => $prov_subs,
pref_list => [qw/cfu cfb cft cfna cfs cfr cfo/],
);
@resource{qw/cfu cfb cft cfna cfs cfr cfo/} = ({}) x 5;
@resource{qw/cfu cfb cft cfna cfs cfr cfo/} = ({}) x 7;
for my $item_cf ($item->provisioning_voip_subscriber->voip_cf_mappings->all) {
next unless ($allowed_prefs->{$item_cf->type});
$resource{$item_cf->type} = $self->_contents_from_cfm($c, $item_cf, $item);
@ -435,6 +435,24 @@ sub _contents_from_cfm {
my $dset = $dset_item ? { $dset_item->get_inflated_columns } : undef;
my $bnumberset = $bnumberset_item ? { $bnumberset_item->get_inflated_columns } : undef;
my $timeset = $timeset_item ? { $timeset_item->get_inflated_columns } : undef;
if ($dset) {
$dset->{own} =
$dset_item->subscriber_id == $cfm_item->subscriber_id ? 1 : 0;
}
if ($sourceset) {
$sourceset->{own} =
$sourceset_item->subscriber_id == $cfm_item->subscriber_id ? 1 : 0;
}
if ($bnumberset) {
$bnumberset->{own} =
$bnumberset_item->subscriber_id == $cfm_item->subscriber_id ? 1 : 0;
}
if ($timeset) {
$timeset->{own} =
$timeset_item->subscriber_id == $cfm_item->subscriber_id ? 1 : 0;
}
for my $time ($timeset_item ? $timeset_item->voip_cf_periods->all : () ) {
push @times, {$time->get_inflated_columns};
delete @{$times[-1]}{'time_set_id', 'id'};

Loading…
Cancel
Save