MT#19821 subsciber profile edit drops random voip_usr_prefs

a map used by the profile_edit logic mistakenly used
  voip_subscriber_profile_attributes.id
as keys instead of
  voip_preferences.id
keys.

so editing a subscriber profile seems to drop arbitrary
voip_usr_preferences values (and also cf mappings),
even when just changing the profile's name.

in addition, the resseller_edit config option is made
working as expected.

Change-Id: I75a60ee3e1e3889bdb16ccc0fa7d5661305f351c
changes/25/6325/3
Rene Krenn 10 years ago
parent 1c2c8cf4fd
commit e8ab9036a8

@ -42,7 +42,7 @@ sub set_list :Chained('/') :PathPart('subscriberprofile') :CaptureArgs(0) {
{ name => 'name', search => 1, title => $c->loc('Name') },
{ name => 'description', search => 1, title => $c->loc('Description') },
]);
$c->stash(template => 'subprofile/set_list.tt');
}
@ -131,7 +131,7 @@ sub set_create :Chained('set_list') :PathPart('create') :Args(0) :Does(ACL) :ACL
}
delete $form->values->{reseller};
$c->stash->{set_rs}->create($form->values);
delete $c->session->{created_objects}->{reseller};
});
NGCP::Panel::Utils::Message::info(
@ -194,7 +194,7 @@ sub set_edit :Chained('set_base') :PathPart('edit') :Does(ACL) :ACLDetachTo('/de
}
delete $form->values->{reseller};
$set->update($form->values);
delete $c->session->{created_objects}->{reseller};
});
NGCP::Panel::Utils::Message::info(
@ -220,7 +220,7 @@ sub set_delete :Chained('set_base') :PathPart('delete') :Does(ACL) :ACLDetachTo(
$c->detach('/denied_page')
if($c->user->roles eq "reseller" && !$c->config->{profile_sets}->{reseller_edit});
try {
my $schema = $c->model('DB');
$schema->txn_do(sub{
@ -334,7 +334,7 @@ sub profile_list :Chained('set_base') :PathPart('profile') :CaptureArgs(0) {
{ name => 'description', search => 1, title => $c->loc('Description') },
{ name => 'set_default', search => 0, title => $c->loc('Default') },
]);
$c->stash(template => 'subprofile/profile_list.tt');
}
@ -416,7 +416,7 @@ sub profile_create :Chained('profile_list') :PathPart('create') :Args(0) :Does(A
$form->values->{set_default} = 1;
}
my $profile = $c->stash->{set}->voip_subscriber_profiles->create($form->values);
# TODO: should we rather take the name and load the id from db,
# instead of trusting the id coming from user input?
foreach my $attr(keys %{ $attributes }) {
@ -485,20 +485,20 @@ sub profile_edit :Chained('profile_base') :PathPart('edit') :Does(ACL) :ACLDetac
# no previous default profile, make this one default
$form->values->{set_default} = 1;
}
if($c->user->roles eq "reseller" && !$c->config->{profile_sets}->{reseller_edit}) {
# only allow generic fields to be updated
delete $form->values->{attribute};
}
$profile->update($form->values);
if($c->user->roles eq "reseller" && !$c->config->{profile_sets}->{reseller_edit}) {
# only allow generic fields to be updated
return;
}
my %old_attributes = map { $_->id => $_->attribute->attribute }
my %old_attributes = map { $_->attribute->id => $_->attribute->attribute }
$profile->profile_attributes->all;
# TODO: reuse attributes for efficiency reasons?
$profile->profile_attributes->delete;
# TODO: should we rather take the name and load the id from db,
# instead of trusting the id coming from user input?
foreach my $attr(keys %{ $attributes }) {
@ -537,7 +537,7 @@ sub profile_edit :Chained('profile_base') :PathPart('edit') :Does(ACL) :ACLDetac
if($v eq "rewrite_rule_set") {
$profile->voip_prof_preferences->search({
'attribute.attribute' => { -in => [qw/
rewrite_rule_set
rewrite_rule_set
rewrite_caller_in_dpid rewrite_caller_out_dpid
rewrite_callee_in_dpid rewrite_callee_out_dpid
rewrite_callee_lnp_dpid rewrite_caller_lnp_dpid/] },
@ -586,7 +586,7 @@ sub profile_delete :Chained('profile_base') :PathPart('delete') :Does(ACL) :ACLD
$c->detach('/denied_page')
if($c->user->roles eq "reseller" && !$c->config->{profile_sets}->{reseller_edit});
try {
my $schema = $c->model('DB');
$schema->txn_do(sub{

Loading…
Cancel
Save