MT#6295 API: fix failing customers and contracts requests

validate max_subscribers (like in earlier versions) but don't
require product to be set
and typo
agranig/subprof
Gerhard Jungwirth 12 years ago
parent e4d2a22ef6
commit 6d17b70ab0

@ -0,0 +1,30 @@
package NGCP::Panel::Form::Contract::ProductOptional;
use HTML::FormHandler::Moose;
extends 'NGCP::Panel::Form::Contract::Basic';
has_field 'product' => (
type => '+NGCP::Panel::Field::Product',
label => 'Product',
required => 0,
);
has_field 'max_subscribers' => (
type => 'PosInteger',
label => 'Max Subscribers',
required => 0,
element_attr => {
rel => ['tooltip'],
title => ['Optionally set the maximum number of subscribers for this contract. Leave empty for unlimited.']
},
);
has_block 'fields' => (
tag => 'div',
class => [qw/modal-body/],
render_list => [qw/contact billing_profile product max_subscribers status external_id/],
);
1;
# vim: set tabstop=4 expandtab:

@ -41,7 +41,7 @@ sub hal_from_contract {
my ($self, $c, $contract, $form) = @_;
my $billing_mapping = $contract->billing_mappings->find($contract->get_column('bmid'));
my $billing_profile_id = $billing_mapping->billing_profile->id;
my $billing_profile_id = $billing_mapping->billing_profile_id;
my $stime = NGCP::Panel::Utils::DateTime::current_local()->truncate(to => 'month');
my $etime = $stime->clone->add(months => 1);
my $contract_balance = $contract->contract_balances
@ -57,7 +57,7 @@ sub hal_from_contract {
contract => $contract,
);
} catch($e) {
$self->log->error("Failed to create current contract balance for contract id '".$contract->id."': $e");
$c->log->error("Failed to create current contract balance for contract id '".$contract->id."': $e");
$self->error($c, HTTP_INTERNAL_SERVER_ERROR, "Internal Server Error.");
return;
}

@ -14,7 +14,7 @@ use HTTP::Status qw(:constants);
use NGCP::Panel::Utils::DateTime;
use NGCP::Panel::Utils::Contract;
use NGCP::Panel::Utils::Preferences;
use NGCP::Panel::Form::Contract::ProductSelect qw();
use NGCP::Panel::Form::Contract::ProductOptional;
sub item_rs {
my ($self, $c) = @_;
@ -49,7 +49,7 @@ sub item_rs {
sub get_form {
my ($self, $c) = @_;
return NGCP::Panel::Form::Contract::PeeringReseller->new;
return NGCP::Panel::Form::Contract::ProductOptional->new;
}
sub hal_from_customer {
@ -184,11 +184,11 @@ sub update_customer {
}
}
my $old_ext_id = $customer->external_id;
my $old_ext_id = $customer->external_id // '';
$customer->update($resource);
if($customer->external_id ne $old_ext_id) {
if(($customer->external_id // '') ne $old_ext_id) {
foreach my $sub($customer->voip_subscribers->all) {
my $prov_sub = $sub->provisioning_voip_subscriber;
next unless($prov_sub);

Loading…
Cancel
Save