MT#18499 added customer location filter by contract_location_pref

Change-Id: I112b51fbaf7dbe14fef06b2f27a4bcfc88f429e5
changes/58/5258/1
Kirill Solomko 10 years ago
parent 2d4bb1c175
commit eec01acae4

@ -2122,7 +2122,7 @@ sub location_preferences_edit :Chained('location_preferences_base') :PathPart('e
my @enums = $c->stash->{preference_meta}
->voip_preferences_enums
->search({contract_pref => 1})
->search({contract_pref => 1, contract_location_pref => 1})
->all;
my $pref_rs = $contract->voip_contract_preferences(
@ -2225,6 +2225,7 @@ sub load_preference_list :Private {
NGCP::Panel::Utils::Preferences::load_preference_list( c => $c,
pref_values => \%pref_values,
contract_pref => 1,
contract_location_pref => $c->stash->{location}{id} ? 1 : 0,
customer_view => ($c->user->roles eq 'subscriberadmin' ? 1 : 0),
);
}

@ -39,6 +39,7 @@ sub load_preference_list {
my $prof_pref = $params{prof_pref};
my $usr_pref = $params{usr_pref};
my $contract_pref = $params{contract_pref};
my $contract_location_pref = $params{contract_location_pref};
my $profile = $params{sub_profile};
my $customer_view = $params{customer_view} // 0;
@ -50,6 +51,9 @@ sub load_preference_list {
$contract_pref ? ('voip_preferences.contract_pref' => 1,
-or => ['voip_preferences_enums.contract_pref' => 1,
'voip_preferences_enums.contract_pref' => undef]) : (),
$contract_location_pref ? ('voip_preferences.contract_location_pref' => 1,
-or => ['voip_preferences_enums.contract_location_pref' => 1,
'voip_preferences_enums.contract_location_pref' => undef]) : (),
$peer_pref ? ('voip_preferences.peer_pref' => 1,
-or => ['voip_preferences_enums.peer_pref' => 1,
'voip_preferences_enums.peer_pref' => undef]) : (),
@ -846,7 +850,9 @@ sub get_contract_preference_rs {
my $location_id = $params{location_id} || undef;
my $preference = $c->model('DB')->resultset('voip_preferences')->find({
attribute => $attribute, 'contract_pref' => 1,
attribute => $attribute,
contract_pref => 1,
contract_location_pref => $location_id ? 1 : 0,
});
return unless($preference);
return $preference->voip_contract_preferences->search_rs({
@ -949,7 +955,7 @@ sub api_preferences_defs{
for my $pref($preferences->all) {
my $fields = { $pref->get_inflated_columns };
# remove internal fields
for my $del(qw/type attribute expose_to_customer internal peer_pref usr_pref dom_pref contract_pref prof_pref voip_preference_groups_id id modify_timestamp/) {
for my $del(qw/type attribute expose_to_customer internal peer_pref usr_pref dom_pref contract_pref contract_location_pref prof_pref voip_preference_groups_id id modify_timestamp/) {
delete $fields->{$del};
}
$fields->{max_occur} = int($fields->{max_occur});
@ -961,7 +967,7 @@ sub api_preferences_defs{
$fields->{enum_values} = [];
foreach my $enum(@enums) {
my $efields = { $enum->get_inflated_columns };
for my $del(qw/id preference_id usr_pref prof_pref dom_pref peer_pref contract_pref/) {
for my $del(qw/id preference_id usr_pref prof_pref dom_pref peer_pref contract_pref contract_location_pref/) {
delete $efields->{$del};
}
$efields->{default_val} = JSON::Types::bool($efields->{default_val});

Loading…
Cancel
Save