TT#62269 add new call forward type "cfo"

* "cfo" is for Call Forward Rerouting
    * "cfo" was not added into the "Secretary Manager" part

Change-Id: I3c9eed1329ef93a1e643ace5f7b8c2db172f406d
changes/53/31653/6
Marco Capetta 6 years ago
parent 5e919b54c9
commit 5b39645647

@ -15,7 +15,7 @@ sub allowed_methods{
}
sub api_description {
return 'Specifies callforward mappings of a subscriber, where multiple mappings can be specified per type (cfu, cfb, cft, cfna, cfs, cfr) ' .
return 'Specifies callforward mappings of a subscriber, where multiple mappings can be specified per type (cfu, cfb, cft, cfna, cfs, cfr, cfo) ' .
'Each mapping consists of a destinationset name (see <a href="#cfdestinationsets">CFDestinationSets</a>), a timeset name ' .
'(see <a href="#cftimesets">CFTimeSets</a>), a sourceset name (see <a href="#cfsourcesets">CFSourceSets</a>), ' .
'and a bnumberset name (see <a href="#cfbnumbersets">CFBnumberSets</a>).';
@ -39,6 +39,7 @@ sub documentation_sample {
cfu => [],
cfs => [],
cfr => [],
cfo => [],
} ;
}

@ -16,7 +16,7 @@ sub allowed_methods{
sub api_description {
return 'Specifies basic callforwards of a subscriber, where a number of destinations, times and sources ' .
' can be specified for each type (cfu, cfb, cft, cfna, cfs, cfr). For more complex configurations with ' .
' can be specified for each type (cfu, cfb, cft, cfna, cfs, cfr, cfo). For more complex configurations with ' .
' multiple combinations of Timesets, Destinationsets and SourceSets see <a href="#cfmappings">CFMappings</a>.';
};
@ -40,6 +40,7 @@ sub documentation_sample {
cfu => {},
cfs => {},
cfr => {},
cfo => {},
};
}

@ -130,7 +130,7 @@ sub query_params {
},
{
param => 'type',
description => 'Filter for calls with a specific type. One of "call", "cfu", "cfb", "cft", "cfna", "cfs", "cfr".',
description => 'Filter for calls with a specific type. One of "call", "cfu", "cfb", "cft", "cfna", "cfs", "cfr", "cfo".',
query => {
first => sub {
my $q = shift;
@ -143,7 +143,7 @@ sub query_params {
},
{
param => 'type_ne',
description => 'Filter for calls not having a specific type. One of "call", "cfu", "cfb", "cft", "cfna", "cfs", "cfr".',
description => 'Filter for calls not having a specific type. One of "call", "cfu", "cfb", "cft", "cfna", "cfs", "cfr", "cfo".',
query => {
first => sub {
my $q = shift;

@ -181,7 +181,7 @@ sub POST :Allow {
expose_to_customer => 1,
},
{
attribute => { -in => [qw/cfu cft cfna cfb cfs cfr/] },
attribute => { -in => [qw/cfu cft cfna cfb cfs cfr cfo/] },
},
],
});

@ -616,7 +616,7 @@ sub preferences :Chained('base') :PathPart('preferences') :Args(0) {
my $prov_subscriber = $c->stash->{subscriber}->provisioning_voip_subscriber;
my $cfs = {};
foreach my $type(qw/cfu cfna cft cfb cfs cfr/) {
foreach my $type(qw/cfu cfna cft cfb cfs cfr cfo/) {
my $maps = $prov_subscriber->voip_cf_mappings
->search({ type => $type });
$cfs->{$type} = [];
@ -721,7 +721,7 @@ sub preferences :Chained('base') :PathPart('preferences') :Args(0) {
$c->stash->{pref_groups} = \@newprefgroups;
my $special_prefs = { check => 1 };
foreach my $pref(qw/cfu cft cfna cfb cfs cfr
foreach my $pref(qw/cfu cft cfna cfb cfs cfr cfo
speed_dial reminder auto_attendant
voice_mail fax_server/) {
my $preference = $c->model('DB')->resultset('voip_preferences')->find({
@ -869,7 +869,11 @@ sub preferences_callforward :Chained('base') :PathPart('preferences/callforward'
last SWITCH;
};
/^cfr$/ && do {
$cf_desc = $c->loc('Call Forward Rerouting');
$cf_desc = $c->loc('Call Forward on Response');
last SWITCH;
};
/^cfo$/ && do {
$cf_desc = $c->loc('Call Forward on Overflow');
last SWITCH;
};
# default
@ -1103,7 +1107,11 @@ sub preferences_callforward_advanced :Chained('base') :PathPart('preferences/cal
last SWITCH;
};
/^cfr$/ && do {
$cf_desc = $c->loc('Call Forward Rerouting');
$cf_desc = $c->loc('Call Forward on Response');
last SWITCH;
};
/^cfo$/ && do {
$cf_desc = $c->loc('Call Forward on Overflow');
last SWITCH;
};
# default

@ -521,7 +521,7 @@ sub profile_edit :Chained('profile_base') :PathPart('edit') {
if(keys %old_attributes) {
my $cfs = $c->model('DB')->resultset('voip_preferences')->search({
id => { -in => [ keys %old_attributes ] },
attribute => { -in => [qw/cfu cfb cft cfna cfs cfr/] },
attribute => { -in => [qw/cfu cfb cft cfna cfs cfr cfo/] },
});
my @subs = $c->model('DB')->resultset('provisioning_voip_subscribers')
->search({

@ -90,7 +90,21 @@ has_field 'cfr' => (
required => 0,
element_attr => {
rel => ['tooltip'],
title => ['Call Forward Rerouting, Contains the keys "destinations", "times" and "sources". "destinations" is an Array of Objects ' .
title => ['Call Forward on Response, Contains the keys "destinations", "times" and "sources". "destinations" is an Array of Objects ' .
'having a "destination", "priority" and "timeout" field. "times" is an Array of Objects having the fields ' .
'"minute", "hour", "wday", "mday", "month", "year". "times" can be empty, then the CF is applied always. ' .
'"sources" is an Array of Objects having one field "source". "sources" can be empty.'],
},
);
has_field 'cfo' => (
type => '+NGCP::Panel::Field::CFSimpleAPICompound',
do_wrapper => 1,
do_label => 0,
required => 0,
element_attr => {
rel => ['tooltip'],
title => ['Call Forward on Overflow, Contains the keys "destinations", "times" and "sources". "destinations" is an Array of Objects ' .
'having a "destination", "priority" and "timeout" field. "times" is an Array of Objects having the fields ' .
'"minute", "hour", "wday", "mday", "month", "year". "times" can be empty, then the CF is applied always. ' .
'"sources" is an Array of Objects having one field "source". "sources" can be empty.'],
@ -106,7 +120,7 @@ has_field 'cft.ringtimeout' => (
has_block 'fields' => (
tag => 'div',
class => [qw(modal-body)],
render_list => [qw(cfu cfb cft cfna cfs cfr)],
render_list => [qw(cfu cfb cft cfna cfs cfr cfo)],
);
1;

@ -438,10 +438,11 @@ has_field 'call_type' => (
{ label => 'cfna', value => 'cfna' },
{ label => 'cfs', value => 'cfs' },
{ label => 'cfr', value => 'cfr' },
{ label => 'cfo', value => 'cfo' },
],
element_attr => {
rel => ['tooltip'],
title => ['The type of call, one of call, cfu, cfb, cft, cfna, cfs, cfr.']
title => ['The type of call, one of call, cfu, cfb, cft, cfna, cfs, cfr, cfo.']
},
);

@ -80,7 +80,20 @@ has_field 'cfr' => (
required => 0,
element_attr => {
rel => ['tooltip'],
title => ['Call Forward Rerouting, Number of Objects, each containing the keys ' .
title => ['Call Forward on Response, Number of Objects, each containing the keys ' .
'"destinationset", "timeset" and "sourceset". The values must be the name of ' .
'a corresponding set which belongs to the same subscriber.'],
},
);
has_field 'cfo' => (
type => 'Repeatable',
do_wrapper => 1,
do_label => 0,
required => 0,
element_attr => {
rel => ['tooltip'],
title => ['Call Forward on Overflow, Number of Objects, each containing the keys ' .
'"destinationset", "timeset" and "sourceset". The values must be the name of ' .
'a corresponding set which belongs to the same subscriber.'],
},
@ -356,6 +369,50 @@ has_field 'cfr.bnumberset_id' => (
do_label => 0,
);
has_field 'cfo.destinationset' => (
type => 'Text',
do_wrapper => 1,
do_label => 0,
);
has_field 'cfo.destinationset_id' => (
type => 'PosInteger',
do_label => 0,
);
has_field 'cfo.timeset' => (
type => 'Text',
do_wrapper => 1,
do_label => 0,
);
has_field 'cfo.timeset_id' => (
type => 'PosInteger',
do_label => 0,
);
has_field 'cfo.sourceset' => (
type => 'Text',
do_wrapper => 1,
do_label => 0,
);
has_field 'cfo.sourceset_id' => (
type => 'PosInteger',
do_label => 0,
);
has_field 'cfo.bnumberset' => (
type => 'Text',
do_wrapper => 1,
do_label => 0,
);
has_field 'cfo.bnumberset_id' => (
type => 'PosInteger',
do_label => 0,
);
1;
# vim: set tabstop=4 expandtab:

@ -91,10 +91,11 @@ has_field 'type' => (
{ label => 'cfna', value => 'cfna' },
{ label => 'cfs', value => 'cfs' },
{ label => 'cfr', value => 'cfr' },
{ label => 'cfo', value => 'cfo' },
],
element_attr => {
rel => ['tooltip'],
title => ['The type of call, one of call, cfu, cfb, cft, cfna, cfs, cfr.']
title => ['The type of call, one of call, cfu, cfb, cft, cfna, cfs, cfr, cfo.']
},
);

@ -17,7 +17,7 @@ has_field 'call_id' => (
has_field 'call_type' => (
type => 'Text',
label => 'One of the "call","cfu","cft","cfb","cfna","cfs","cfr".',
label => 'One of the "call","cfu","cft","cfb","cfna","cfs","cfr","cfo".',
required => 1,
);

@ -80,7 +80,7 @@ sub field_list {
expose_to_customer => 1,
},
{
attribute => { -in => [qw/cfu cft cfna cfb cfs cfr/] },
attribute => { -in => [qw/cfu cft cfna cfb cfs cfr cfo/] },
}
],
});

@ -24,7 +24,7 @@ sub hal_from_item {
my ($self, $c, $item, $type) = @_;
my $form;
my $resource = { subscriber_id => $item->id, cfu => [], cfb => [], cfna => [], cft => [], cfs => [], cfr => []};
my $resource = { subscriber_id => $item->id, cfu => [], cfb => [], cfna => [], cft => [], cfs => [], cfr => [], cfo => []};
my $b_subs_id = $item->id;
my $p_subs_id = $item->provisioning_voip_subscriber->id;
@ -155,7 +155,7 @@ sub update_item {
my $ssets_rs = $c->model('DB')->resultset('voip_cf_source_sets');
my $bsets_rs = $c->model('DB')->resultset('voip_cf_bnumber_sets');
for my $type ( qw/cfu cfb cft cfna cfs cfr/) {
for my $type ( qw/cfu cfb cft cfna cfs cfr cfo/) {
if (ref $resource->{$type} ne "ARRAY") {
$self->error($c, HTTP_UNPROCESSABLE_ENTITY, "Invalid field '$type'. Must be an array.");
return;
@ -257,7 +257,7 @@ sub update_item {
$autoattendant_count += NGCP::Panel::Utils::Subscriber::check_dset_autoattendant_status($map->destination_set);
}
$mappings_rs->delete;
for my $type ( qw/cfu cfb cft cfna cfs cfr/) {
for my $type ( qw/cfu cfb cft cfna cfs cfr cfo/) {
$cf_preferences{$type}->delete;
}
for my $mapping ( @new_mappings ) {

@ -50,9 +50,9 @@ sub hal_from_item {
my $allowed_prefs = NGCP::Panel::Utils::Preferences::get_subscriber_allowed_prefs(
c => $c,
prov_subscriber => $prov_subs,
pref_list => [qw/cfu cfb cft cfna cfs cfr/],
pref_list => [qw/cfu cfb cft cfna cfs cfr cfo/],
);
@resource{qw/cfu cfb cft cfna cfs cfr/} = ({}) x 5;
@resource{qw/cfu cfb cft cfna cfs cfr cfo/} = ({}) x 5;
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);
@ -73,7 +73,7 @@ sub hal_from_item {
run => 0,
);
for my $cf_type (qw/cfu cft cfb cfna cfs cfr/) {
for my $cf_type (qw/cfu cft cfb cfna cfs cfr cfo/) {
unless ($allowed_prefs->{$cf_type}) {
delete $resource{$cf_type};
}
@ -129,7 +129,7 @@ sub update_item {
my $allowed_prefs = NGCP::Panel::Utils::Preferences::get_subscriber_allowed_prefs(
c => $c,
prov_subscriber => $prov_subs,
pref_list => [qw/cfu cfb cft cfna cfs cfr/],
pref_list => [qw/cfu cfb cft cfna cfs cfr cfo/],
);
return unless $self->validate_form(
@ -139,7 +139,7 @@ sub update_item {
run => 1,
);
for my $type (qw/cfu cfb cft cfna cfs cfr/) {
for my $type (qw/cfu cfb cft cfna cfs cfr cfo/) {
next unless "ARRAY" eq ref $resource->{$type}{destinations};
next unless ($allowed_prefs->{$type});
for my $d (@{ $resource->{$type}{destinations} }) {
@ -172,7 +172,7 @@ sub update_item {
}
}
for my $type (qw/cfu cfb cft cfna cfs cfr/) {
for my $type (qw/cfu cfb cft cfna cfs cfr cfo/) {
next unless ($allowed_prefs->{$type});
my $mapping = $c->model('DB')->resultset('voip_cf_mappings')->search_rs({
subscriber_id => $prov_subscriber_id,

@ -161,7 +161,7 @@ sub update_item {
expose_to_customer => 1,
},
{
attribute => { -in => [qw/cfu cft cfna cfb cfs cfr/] },
attribute => { -in => [qw/cfu cft cfna cfb cfs cfr cfo/] },
},
],
});
@ -179,7 +179,7 @@ sub update_item {
if(keys %old_attributes) {
my $cfs = $c->model('DB')->resultset('voip_preferences')->search({
id => { -in => [ keys %old_attributes ] },
attribute => { -in => [qw/cfu cfb cft cfna cfs cfr/] },
attribute => { -in => [qw/cfu cfb cft cfna cfs cfo/] },
});
my @subs = $c->model('DB')->resultset('provisioning_voip_subscribers')
->search({

@ -292,7 +292,7 @@ sub get_dummy_data {
start_time => time,
source_customer_cost => int( (rand()-1/2) * rand(1000000)),
duration => int(rand(7200)) + 10,
call_type => (qw/cfu cfb cft cfna cfs cfr/)[int(rand 4)],
call_type => (qw/cfu cfb cft cfna cfs cfr cfo/)[int(rand 4)],
zone => "Zone $_",
zone_detail => "Detail $_",
}}(1 .. 50)

@ -23,7 +23,8 @@ sub _get_cf_type_descriptions {
cft => $c->loc("Call Forward Timeout"),
cfna => $c->loc("Call Forward Unavailable"),
cfs => $c->loc("Call Forward SMS"),
cfr => $c->loc("Call Forward Rerouting"), };
cfr => $c->loc("Call Forward on Response"), };
cfo => $c->loc("Call Forward on Overflow"), };
}
sub cfs {
@ -33,7 +34,7 @@ sub cfs {
my $cfs = {};
my $descriptions = $self->_get_cf_type_descriptions($c);
foreach my $type (qw/cfu cfna cft cfb cfs cfr/) {
foreach my $type (qw/cfu cfna cft cfb cfs cfr cfo/) {
my $maps = $prov_subscriber->voip_cf_mappings
->search({ type => $type });
my @mappings = ();

@ -121,7 +121,8 @@ $( document ).ready(function() {
{ type = "cft", desc = c.loc("Call Forward Timeout") },
{ type = "cfna", desc = c.loc("Call Forward Unavailable") },
{ type = "cfs", desc = c.loc("Call Forward SMS") },
{ type = "cfr", desc = c.loc("Call Forward Rerouting") } ] -%]
{ type = "cfr", desc = c.loc("Call Forward on Response") },
{ type = "cfo", desc = c.loc("Call Forward on Overflow") } ] -%]
[% IF c.user.roles == "subscriber" || c.user.roles == "subscriberadmin" -%]
[% NEXT IF special_prefs.check && !special_prefs.callforward.${cf.type} -%]
[% END -%]

@ -96,7 +96,7 @@ SKIP:{
#check cf structure
delete $cf1single->{_links};
is(ref $cf1single, "HASH", "cf should be hash");
my @valid_types = (qw/cfu cfb cft cfna cfs cfr/);
my @valid_types = (qw/cfu cfb cft cfna cfs cfr cfo/);
my %valid_types;
@valid_types{@valid_types} = ( 1 ) x @valid_types;
foreach my $type(@valid_types){

@ -296,6 +296,7 @@ goto SKIP;
timeset => $timeset->{name}}],
cfs => [],
cfr => [],
cfo => [],
});
#1. update destination set:

@ -890,6 +890,8 @@ sub test_callforwards {
times => $cftimeset->{times}},
cfr => { destinations => $cfdestinationset->{destinations},
times => $cftimeset->{times}},
cfo => { destinations => $cfdestinationset->{destinations},
times => $cftimeset->{times}},
}));
$res = $ua->request($req);
is($res->code, 200, _get_request_test_message("PUT test callforwards"));
@ -955,6 +957,8 @@ sub test_cfmapping {
timeset => $cftimeset->{name}}],
cfr => [{ destinationset => $cfdestinationset->{name},
timeset => $cftimeset->{name}}],
cfo => [{ destinationset => $cfdestinationset->{name},
timeset => $cftimeset->{name}}],
}));
$res = $ua->request($req);
is($res->code, 200, _get_request_test_message("PUT test cfmappings"));

@ -142,6 +142,7 @@ my $cf_map = $test->resource(
cfna => [],
cfs => [],
cfr => [],
cfo => [],
cft_ringtimeout => undef,
}
);

Loading…
Cancel
Save