Fix config paths and dbalias creation.

In case a subscriber is created from within the customer view, then also
clear the created objects and write a dbalias.
agranig/1_0_subfix
Andreas Granig 13 years ago
parent aa33e91147
commit ab79afbb67

@ -30,14 +30,13 @@ extends 'Catalyst';
our $VERSION = '0.01';
# Configure the application.
#
# Note that settings in ngcp_panel.conf (or other external
# configuration file that you set up manually) take precedence
# over this when using ConfigLoader. Thus configuration
# details given here can function as a default configuration,
# with an external configuration file acting as an override for
# local deployment.
my $panel_config;
for my $path(qw#/etc/ngcp-panel/ngcp_panel.conf etc/ngcp_panel.conf ngcp_panel.conf#) {
if(-f $path) {
$panel_config = $path;
}
}
$panel_config //= 'ngcp_panel.conf';
__PACKAGE__->config(
name => 'NGCP::Panel',
@ -46,7 +45,7 @@ __PACKAGE__->config(
enable_catalyst_header => 1, # Send X-Catalyst header
encoding => 'UTF-8',
'Plugin::ConfigLoader' => {
file => '/etc/ngcp-panel/ngcp_panel.conf',
file => $panel_config,
},
'View::HTML' => {
INCLUDE_PATH => [
@ -92,26 +91,6 @@ __PACKAGE__->config(
}
}
},
subscriber => {
credential => {
class => 'Password',
password_field => 'password',
password_type => 'clear'
},
store => {
class => 'Minimal',
users => {
subscriberadmin => {
password => 'subscriberadmin',
roles => [qw/subscriberadmin subscriber/],
},
subscriber => {
password => 'subscriber',
roles => [qw/subscriber/],
},
}
}
},
reseller => {
credential => {
class => 'Password',

@ -141,9 +141,12 @@ sub subscriber_create :Chained('base') :PathPart('subscriber/create') :Args(0) {
my ($self, $c) = @_;
my $form = NGCP::Panel::Form::CustomerSubscriber->new;
my $params = {};
$params = $params->merge($c->session->{created_objects});
$form->process(
posted => ($c->request->method eq 'POST'),
params => $c->request->params,
item => $params,
);
NGCP::Panel::Utils::Navigation::check_form_buttons(
c => $c,
@ -244,6 +247,18 @@ sub subscriber_create :Chained('base') :PathPart('subscriber/create') :Args(0) {
password => sprintf("%04d", int(rand 10000)),
email => '',
});
if($number) {
$schema->resultset('dbaliases')->create({
alias_username => $number->cc .
($number->ac || '').
$number->sn,
alias_domain => $prov_subscriber->domain->domain,
username => $prov_subscriber->username,
domain => $prov_subscriber->domain->domain,
});
}
delete $c->session->{created_objects}->{domain};
});
$c->flash(messages => [{type => 'success', text => 'Subscriber successfully created!'}]);

@ -27,8 +27,12 @@ sub index :Path Form {
my ( $self, $c, $realm ) = @_;
$c->log->debug("*** Login::index");
=pod
$realm = 'subscriber'
unless($realm and ($realm eq 'admin' or $realm eq 'reseller'));
=cut
$realm = 'admin'
unless($realm and ($realm eq 'reseller'));
my $form = NGCP::Panel::Form::Login->new;
$form->process(

@ -46,7 +46,7 @@ sub auto :Private {
}
$c->log->debug("*** Root::auto do login, target='$target'");
$c->session(target => $target);
$c->response->redirect($c->uri_for('/login'));
$c->response->redirect($c->uri_for('/login/admin'));
return;
}

@ -472,9 +472,9 @@ sub preferences_callforward :Chained('base') :PathPart('preferences/callforward'
my $cf_form;
if($cf_type eq "cft") {
$cf_form = NGCP::Panel::Form::SubscriberCFTSimple->new;
$cf_form = NGCP::Panel::Form::SubscriberCFTSimple->new(ctx => $c);
} else {
$cf_form = NGCP::Panel::Form::SubscriberCFSimple->new;
$cf_form = NGCP::Panel::Form::SubscriberCFSimple->new(ctx => $c);
}
$cf_form->process(

@ -8,7 +8,7 @@ has_field 'id' => (
do_label => 0,
do_wrapper => 0,
required => 1,
template => '/usr/share/ngcp-panel/templates/helpers/datatables_field.tt',
template => 'helpers/datatables_field.tt',
ajax_src => '/billing/ajax',
table_titles => ['#', 'Profile'],
table_fields => ['id', 'name'],

@ -8,7 +8,7 @@ has_field 'id' => (
do_label => 0,
do_wrapper => 0,
required => 1,
template => '/usr/share/ngcp-panel/templates/helpers/datatables_field.tt',
template => 'helpers/datatables_field.tt',
ajax_src => '../zones/ajax', # /billing/<id>/zones/ajax
table_titles => ['#', 'Zone', 'Zone Detail'],
table_fields => ['id', 'zone', 'detail'],

@ -8,7 +8,7 @@ has_field 'id' => (
do_label => 0,
do_wrapper => 0,
required => 1,
template => '/usr/share/ngcp-panel/templates/helpers/datatables_field.tt',
template => 'helpers/datatables_field.tt',
ajax_src => '/contact/ajax',
table_titles => ['#', 'Reseller', 'First Name', 'Last Name', 'Email'],
table_fields => ['id', 'reseller_name', 'firstname', 'lastname', 'email'],

@ -8,7 +8,7 @@ has_field 'id' => (
do_label => 0,
do_wrapper => 0,
required => 1,
template => '/usr/share/ngcp-panel/templates/helpers/datatables_field.tt',
template => 'helpers/datatables_field.tt',
ajax_src => '/contract/peering/ajax',
table_titles => ['#', 'Status', 'Billing Profile'],
table_fields => ['id', 'status', 'billing_mappings_billing_profile_name'],

@ -8,7 +8,7 @@ has_field 'id' => (
do_label => 0,
do_wrapper => 0,
required => 1,
template => '/usr/share/ngcp-panel/templates/helpers/datatables_field.tt',
template => 'helpers/datatables_field.tt',
ajax_src => '/contract/customer/ajax',
table_titles => ['#', 'Reseller', 'Contact Email', 'External #', 'Status'],
table_fields => ['id', 'contact_reseller_name', 'contact_email', 'external_id', 'status'],

@ -6,8 +6,7 @@ extends 'HTML::FormHandler::Field';
has '+widget' => (default => ''); # leave this empty, as there is no widget ...
has 'template' => ( isa => 'Str',
is => 'rw',
# TODO: not found in real environment!
default => '/usr/share/ngcp-panel/templates/helpers/datatables_field.tt' );
default => 'helpers/datatables_field.tt' );
has 'ajax_src' => ( isa => 'Str', is => 'rw' );
has 'table_fields' => ( isa => 'ArrayRef', is => 'rw' );
has 'table_titles' => ( isa => 'ArrayRef', is => 'rw' );
@ -29,7 +28,13 @@ sub render_element {
table_titles => $self->table_titles,
errors => $self->errors,
};
my $t = new Template({ ABSOLUTE => 1, });
my $t = new Template({
ABSOLUTE => 1,
INCLUDE_PATH => [
'/usr/share/ngcp-panel/templates',
'share/templates',
],
});
$t->process($self->template, $vars, \$output) or
die "Failed to process Datatables field template: ".$t->error();

@ -8,7 +8,7 @@ has_field 'id' => (
do_label => 0,
do_wrapper => 0,
required => 1,
template => '/usr/share/ngcp-panel/templates/helpers/datatables_field.tt',
template => 'helpers/datatables_field.tt',
ajax_src => '/domain/ajax',
table_titles => ['#', 'Reseller', 'Domain'],
table_fields => ['id', 'domain_resellers_reseller_name', 'domain'],

@ -8,7 +8,7 @@ has_field 'id' => (
do_label => 0,
do_wrapper => 0,
required => 1,
template => '/usr/share/ngcp-panel/templates/helpers/datatables_field.tt',
template => 'helpers/datatables_field.tt',
ajax_src => '/reseller/ajax',
table_titles => ['#', 'Name', 'Contract #', 'Status'],
table_fields => ['id', 'name', 'contract_id', 'status'],

@ -8,7 +8,7 @@ has_field 'id' => (
do_label => 0,
do_wrapper => 0,
required => 1,
template => '/usr/share/ngcp-panel/templates/helpers/datatables_field.tt',
template => 'helpers/datatables_field.tt',
ajax_src => '/reseller/ajax_contract',
table_titles => ['#', 'Contact Email', 'External #', 'Status'],
table_fields => ['id', 'contact_email', 'external_id', 'status'],

@ -38,15 +38,7 @@ has_field 'destination.destination' => (
widget => 'RadioGroup',
label => 'Destination',
do_label => 1,
options => [
{ label => 'Voicemail', value => 'voicebox' },
{ label => 'Conference', value => 'conference' },
{ label => 'Fax2Mail', value => 'fax2mail' },
{ label => 'Calling Card', value => 'callingcard' },
{ label => 'Call Trough', value => 'callthrough' },
{ label => 'Local Subscriber', value => 'localuser' },
{ label => 'URI/Number', value => 'uri' },
],
options_method => \&build_destinations,
default => 'uri',
tags => {
before_element => '<div class="ngcp-destination-row">',
@ -54,6 +46,29 @@ has_field 'destination.destination' => (
},
);
sub build_destinations {
my ($self) = @_;
my @options = ();
push @options, { label => 'Voicemail', value => 'voicebox' };
my $c = $self->form->ctx;
if(defined $c) {
push @options, { label => 'Conference', value => 'conference' }
if($c->config->{features}->{conference});
push @options, { label => 'Fax2Mail', value => 'fax2mail' }
if($c->config->{features}->{faxserver});
push @options, { label => 'Calling Card', value => 'callingcard' }
if($c->config->{features}->{callingcard});
push @options, { label => 'Call Trough', value => 'callthrough' }
if($c->config->{features}->{callthrough});
push @options, { label => 'Local Subscriber', value => 'localuser' }
if($c->config->{features}->{callthrough} || $c->config->{features}->{callingcard} );
}
push @options, { label => 'URI/Number', value => 'uri' };
return \@options;
}
has_field 'destination.uri' => (
type => 'Compound',
do_label => 0,

@ -27,18 +27,33 @@ has_field 'destination.destination' => (
widget => 'RadioGroup',
label => 'Destination',
do_label => 1,
options => [
{ label => 'Voicemail', value => 'voicebox' },
{ label => 'Conference', value => 'conference' },
{ label => 'Fax2Mail', value => 'fax2mail' },
{ label => 'Calling Card', value => 'callingcard' },
{ label => 'Call Trough', value => 'callthrough' },
{ label => 'Local Subscriber', value => 'localuser' },
{ label => 'URI/Number', value => 'uri' },
],
options_method => \&build_destionations,
default => 'uri',
);
sub build_destinations {
my ($self) = @_;
my @options = ();
push @options, { label => 'Voicemail', value => 'voicebox' };
my $c = $self->form->ctx;
if(defined $c) {
push @options, { label => 'Conference', value => 'conference' }
if($c->config->{features}->{conference});
push @options, { label => 'Fax2Mail', value => 'fax2mail' }
if($c->config->{features}->{faxserver});
push @options, { label => 'Calling Card', value => 'callingcard' }
if($c->config->{features}->{callingcard});
push @options, { label => 'Call Trough', value => 'callthrough' }
if($c->config->{features}->{callthrough});
push @options, { label => 'Local Subscriber', value => 'localuser' }
if($c->config->{features}->{callthrough} || $c->config->{features}->{callingcard} );
}
push @options, { label => 'URI/Number', value => 'uri' };
return \@options;
}
has_field 'destination.uri' => (
type => 'Compound',
do_label => 0,

@ -14,6 +14,14 @@ log4perl.appender.Default.layout.ConversionPattern=%d{ISO8601} [%p] [%F +%L] %m{
schema_class NGCP::Schema
</Model::DB>
<features>
faxserver 0
callthrough 0
callingcard 0
faxserver 0
conference 1
</features>
<fees_csv>
element_order source
element_order destination

@ -9,7 +9,7 @@
<div class="login-extra">
Go to
[%
realms = ['subscriber', 'admin', 'reseller'];
realms = ['admin', 'reseller'];
links = [];
FOREACH r IN realms;
UNLESS realm == r;

@ -1,6 +1,6 @@
[% META title = 'System Statistics' -%]
<!--[if IE]><script language="javascript" type="text/javascript" src="/js/jsrrd/flot/excanvas.min.js"></script><![endif]-->
<!--[if lte IE 9]><script language="javascript" type="text/javascript" src="/js/jsrrd/flot/excanvas.min.js"></script><![endif]-->
<script type="text/javascript" src="/js/libs/jsrrd/jsrrd/binaryXHR.js"></script>
<script type="text/javascript" src="/js/libs/jsrrd/jsrrd/rrdFile.js"></script>
<script type="text/javascript" src="/js/libs/jsrrd/jsrrd/rrdMultiFile.js"></script>

Loading…
Cancel
Save