TT#40010 add new call forward type "cfr"

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

Change-Id: I8cbc9888e827a343a2f80970f36de7ee011c7c66
changes/42/22442/2
Kirill Solomko 7 years ago
parent 9210ac0487
commit 62a81f1ec7

@ -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) ' .
return 'Specifies callforward mappings of a subscriber, where multiple mappings can be specified per type (cfu, cfb, cft, cfna, cfs, cfr) ' .
'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>).';
@ -38,6 +38,7 @@ sub documentation_sample {
cft_ringtimeout => "200",
cfu => [],
cfs => [],
cfr => [],
} ;
}

@ -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). For more complex configurations with ' .
' can be specified for each type (cfu, cfb, cft, cfna, cfs, cfr). For more complex configurations with ' .
' multiple combinations of Timesets, Destinationsets and SourceSets see <a href="#cfmappings">CFMappings</a>.';
};
@ -39,6 +39,7 @@ sub documentation_sample {
cft => { "ringtimeout" => "199" },
cfu => {},
cfs => {},
cfr => {},
};
}

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

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

@ -608,7 +608,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/) {
foreach my $type(qw/cfu cfna cft cfb cfs cfr/) {
my $maps = $prov_subscriber->voip_cf_mappings
->search({ type => $type });
$cfs->{$type} = [];
@ -713,7 +713,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
foreach my $pref(qw/cfu cft cfna cfb cfs cfr
speed_dial reminder auto_attendant
voice_mail fax_server/) {
my $preference = $c->model('DB')->resultset('voip_preferences')->find({
@ -858,6 +858,10 @@ sub preferences_callforward :Chained('base') :PathPart('preferences/callforward'
$cf_desc = $c->loc('Call Forward SMS');
last SWITCH;
};
/^cfr$/ && do {
$cf_desc = $c->loc('Call Forward Rerouting');
last SWITCH;
};
# default
NGCP::Panel::Utils::Message::error(
c => $c,
@ -999,7 +1003,6 @@ sub preferences_callforward :Chained('base') :PathPart('preferences/callforward'
new_aa => ($d eq 'autoattendant'),
);
NGCP::Panel::Utils::Subscriber::create_cf_destination(
c => $c,
subscriber => $c->stash->{subscriber},
@ -1090,6 +1093,10 @@ sub preferences_callforward_advanced :Chained('base') :PathPart('preferences/cal
$cf_desc = $c->loc('Call Forward SMS');
last SWITCH;
};
/^cfr$/ && do {
$cf_desc = $c->loc('Call Forward Rerouting');
last SWITCH;
};
# default
NGCP::Panel::Utils::Message::error(
c => $c,
@ -2886,7 +2893,7 @@ sub edit_master :Chained('master') :PathPart('edit') :Args(0) :Does(ACL) :ACLDet
if(keys %old_profile_attributes) {
my $cfs = $c->model('DB')->resultset('voip_preferences')->search({
id => { -in => [ keys %old_profile_attributes ] },
attribute => { -in => [qw/cfu cfb cft cfna cfs/] },
attribute => { -in => [qw/cfu cfb cft cfna cfs cfr/] },
});
$prov_subscriber->voip_usr_preferences->search({
attribute_id => { -in => [ keys %old_profile_attributes ] },

@ -513,7 +513,7 @@ sub profile_edit :Chained('profile_base') :PathPart('edit') :Does(ACL) :ACLDetac
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/] },
attribute => { -in => [qw/cfu cfb cft cfna cfs cfr/] },
});
my @subs = $c->model('DB')->resultset('provisioning_voip_subscribers')
->search({

@ -83,6 +83,20 @@ has_field 'cfs' => (
},
);
has_field 'cfr' => (
type => '+NGCP::Panel::Field::CFSimpleAPICompound',
do_wrapper => 1,
do_label => 0,
required => 0,
element_attr => {
rel => ['tooltip'],
title => ['Call Forward Rerouting, 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 'cft.ringtimeout' => (
type => 'PosInteger',
do_wrapper => 1,
@ -92,7 +106,7 @@ has_field 'cft.ringtimeout' => (
has_block 'fields' => (
tag => 'div',
class => [qw(modal-body)],
render_list => [qw(cfu cfb cft cfna cfs)],
render_list => [qw(cfu cfb cft cfna cfs cfr)],
);
1;

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

@ -73,6 +73,19 @@ has_field 'cfs' => (
},
);
has_field 'cfr' => (
type => 'Repeatable',
do_wrapper => 1,
do_label => 0,
required => 0,
element_attr => {
rel => ['tooltip'],
title => ['Call Forward Rerouting, 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 'cfu.destinationset' => (
type => 'Text',
do_wrapper => 1,
@ -299,6 +312,50 @@ has_field 'cft_ringtimeout' => (
do_label => 0,
);
has_field 'cfr.destinationset' => (
type => 'Text',
do_wrapper => 1,
do_label => 0,
);
has_field 'cfr.destinationset_id' => (
type => 'PosInteger',
do_label => 0,
);
has_field 'cfr.timeset' => (
type => 'Text',
do_wrapper => 1,
do_label => 0,
);
has_field 'cfr.timeset_id' => (
type => 'PosInteger',
do_label => 0,
);
has_field 'cfr.sourceset' => (
type => 'Text',
do_wrapper => 1,
do_label => 0,
);
has_field 'cfr.sourceset_id' => (
type => 'PosInteger',
do_label => 0,
);
has_field 'cfr.bnumberset' => (
type => 'Text',
do_wrapper => 1,
do_label => 0,
);
has_field 'cfr.bnumberset_id' => (
type => 'PosInteger',
do_label => 0,
);
1;
# vim: set tabstop=4 expandtab:

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

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

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

@ -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 => []};
my $resource = { subscriber_id => $item->id, cfu => [], cfb => [], cfna => [], cft => [], cfs => [], cfr => []};
my $b_subs_id = $item->id;
my $p_subs_id = $item->provisioning_voip_subscriber->id;
@ -154,7 +154,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/) {
for my $type ( qw/cfu cfb cft cfna cfs cfr/) {
if (ref $resource->{$type} ne "ARRAY") {
$self->error($c, HTTP_UNPROCESSABLE_ENTITY, "Invalid field '$type'. Must be an array.");
return;
@ -256,7 +256,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/) {
for my $type ( qw/cfu cfb cft cfna cfs cfr/) {
$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/],
pref_list => [qw/cfu cfb cft cfna cfs cfr/],
);
@resource{qw/cfu cfb cft cfna cfs/} = ({}) x 5;
@resource{qw/cfu cfb cft cfna cfs cfr/} = ({}) 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/) {
for my $cf_type (qw/cfu cft cfb cfna cfs cfr/) {
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/],
pref_list => [qw/cfu cfb cft cfna cfs cfr/],
);
return unless $self->validate_form(
@ -139,7 +139,7 @@ sub update_item {
run => 1,
);
for my $type (qw/cfu cfb cft cfna cfs/) {
for my $type (qw/cfu cfb cft cfna cfs cfr/) {
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/) {
for my $type (qw/cfu cfb cft cfna cfs cfr/) {
next unless ($allowed_prefs->{$type});
my $mapping = $c->model('DB')->resultset('voip_cf_mappings')->search_rs({
subscriber_id => $prov_subscriber_id,

@ -156,7 +156,7 @@ sub update_item {
expose_to_customer => 1,
},
{
attribute => { -in => [qw/cfu cft cfna cfb cfs/] },
attribute => { -in => [qw/cfu cft cfna cfb cfs cfr/] },
},
],
});
@ -174,7 +174,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/] },
attribute => { -in => [qw/cfu cfb cft cfna cfs cfr/] },
});
my @subs = $c->model('DB')->resultset('provisioning_voip_subscribers')
->search({

@ -701,7 +701,7 @@ sub update_item {
if(keys %old_profile_attributes) {
my $cfs = $schema->resultset('voip_preferences')->search({
id => { -in => [ keys %old_profile_attributes ] },
attribute => { -in => [qw/cfu cfb cft cfna cfs/] },
attribute => { -in => [qw/cfu cfb cft cfna cfs cfr/] },
});
$prov_subscriber->voip_usr_preferences->search({
attribute_id => { -in => [ keys %old_profile_attributes ] },

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

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

@ -118,7 +118,8 @@ $( document ).ready(function() {
{ type = "cfb", desc = c.loc("Call Forward Busy") },
{ 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 = "cfs", desc = c.loc("Call Forward SMS") },
{ type = "cfr", desc = c.loc("Call Forward Rerouting") } ] -%]
[% 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/);
my @valid_types = (qw/cfu cfb cft cfna cfs cfr/);
my %valid_types;
@valid_types{@valid_types} = ( 1 ) x @valid_types;
foreach my $type(@valid_types){

@ -295,6 +295,7 @@ my %customer_map = ();
cfu => [{ destinationset => $destinationset_2->{name},
timeset => $timeset->{name}}],
cfs => [],
cfr => [],
});
#1. update destination set:

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

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

Loading…
Cancel
Save