TT#158003 make subscriber location mappings 'location' optional

* 'location' field is now optional, if not filled it it will always
default to an empty string instead of null. This is required for the
new mode 'forward' that has no use for this field. If the field
is empty in any other mode like 'add' or 'replace', the entry
will be skiped by the logic.

Change-Id: Ia964c3bb272c9772c51b836ac2418ee4cd7b7f42
mr10.3
Kirill Solomko 3 years ago
parent dcce2b83a1
commit 9dd50e8427

@ -136,6 +136,10 @@ sub POST :Allow {
}
$resource->{subscriber_id} = $sub->provisioning_voip_subscriber->id;
$resource->{location} //= '';
$resource->{caller_pattern} //= '.+';
$resource->{callee_pattern} //= '.+';
my $item;
try {
$item = $c->model('DB')->resultset('voip_subscriber_location_mappings')->create($resource);

@ -5824,7 +5824,7 @@ sub create_location_map :Chained('base') :PathPart('preferences/locationmap/crea
try {
$location_map_rs->create({
subscriber_id => $c->stash->{subscriber}->provisioning_voip_subscriber->id,
location => $form->field('location')->value,
location => $form->field('location')->value // '',
caller_pattern => $form->field('caller_pattern')->value // '.+',
callee_pattern => $form->field('callee_pattern')->value // '.+',
mode => $form->field('mode')->value,
@ -5882,7 +5882,7 @@ sub edit_location_map :Chained('location_map_base') :PathPart('edit') {
my $location_map = $c->stash->{location_map};
my $params = {};
if(!$posted && $location_map) {
if (!$posted && $location_map) {
$params = {
'location' => $location_map->location,
'caller_pattern' => $location_map->caller_pattern,
@ -5908,7 +5908,7 @@ sub edit_location_map :Chained('location_map_base') :PathPart('edit') {
if($posted && $form->validated) {
try {
$location_map->update({
location => $form->field('location')->value,
location => $form->field('location')->value // '',
caller_pattern => $form->field('caller_pattern')->value // '.+',
callee_pattern => $form->field('callee_pattern')->value // '.+',
mode => $form->field('mode')->value,

@ -19,7 +19,7 @@ has_field 'subscriber_id' => (
has_field 'location' => (
type => 'Text',
label => 'Location URI',
required => 1,
required => 0,
element_attr => {
rel => ['tooltip'],
title => ['Location entry SIP-URI.']

@ -110,7 +110,7 @@ sub update_item {
return;
}
$resource->{subscriber_id} = $sub->provisioning_voip_subscriber->id;
$resource->{location} //= '';
$resource->{caller_pattern} //= '.+';
$resource->{callee_pattern} //= '.+';

Loading…
Cancel
Save