From b8e7a0b4859204770dd4463351611d9f12baca3d Mon Sep 17 00:00:00 2001 From: Christian Veigl Date: Fri, 24 Aug 2012 11:12:25 +0000 Subject: [PATCH 01/16] check if peering rule already exists beforehand (mantis:1873) --- lib/admin/Controller/peering.pm | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/lib/admin/Controller/peering.pm b/lib/admin/Controller/peering.pm index 17cffbc..41c9812 100644 --- a/lib/admin/Controller/peering.pm +++ b/lib/admin/Controller/peering.pm @@ -241,10 +241,26 @@ sub save_rule : Local { $c->flash->{rule_caller_pattern_err_detail} = $c->session->{prov_error_object} if ($c->session->{prov_error_object}); } + # check if peering rule already exists beforehand + my $peer_details; + return unless $c->model('Provisioning')->call_prov( $c, 'voip', 'get_peer_group_details', + { id => $group_id }, + \$peer_details + ); + + if (scalar grep ({ + ($_->{callee_prefix} eq $settings->{callee_prefix}) and + ($_->{caller_pattern} eq $settings->{caller_pattern}) + } @{$peer_details->{rules}})) + { + $messages{erulerr} = 'Client.Voip.DuplicatePeeringRule'; + + } + if (keys %messages) { $c->session->{messages} = \%messages; $c->flash->{restore_rule} = $settings; - + if (defined $rule_id and length ($rule_id)) { $c->response->redirect("/peering/detail?group_id=$group_id&reditid=$rule_id"); } @@ -277,12 +293,13 @@ sub save_rule : Local { if ($result) { $messages{erulmsg} = 'Server.Voip.SavedSettings'; $c->session->{messages} = \%messages; - $c->response->redirect("/peering/detail?group_id=$group_id"); - return; } else { + $c->flash->{restore_rule} = $settings; $messages{erulerr} = 'Client.Voip.InputErrorFound'; } + + $c->response->redirect("/peering/detail?group_id=$group_id"); } =head2 delete_rule From e76278425ebf442a74879450065dd4683e04977d Mon Sep 17 00:00:00 2001 From: Christian Veigl Date: Fri, 24 Aug 2012 14:35:11 +0000 Subject: [PATCH 02/16] make $admin::VERSION UNIVERSAL-compatible a packages VERSION variable is subject to a quite strict syntax wich does not really allow to pack SVN revisions and build-numbers in it. add $admin::BUILD_VERSION to enable a more build-oriented version-number/build-identifier that will also be shown in the footer of pages. --- lib/admin.pm | 6 +++++- lib/admin/Controller/Root.pm | 2 ++ root/layout/footer | 2 +- 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/lib/admin.pm b/lib/admin.pm index b634044..294ad11 100644 --- a/lib/admin.pm +++ b/lib/admin.pm @@ -21,7 +21,11 @@ use Catalyst qw/ConfigLoader Static::Simple Unicode Session Session::Store::FastMmap Session::State::Cookie /; -our $VERSION = 'UNRELEASED'; +# $VERSION and $BUILD_VERSION will be set during the build-process of the debian package +# In addition to the known $VERSION the variable $BUILD_VERSION may contain more information +# about the build. A much more relaxed syntax is possible here. See also: debian/rules. +our $VERSION = 'VERSION'; +our $BUILD_VERSION = 'BUILD_VERSION'; # Configure the application. # diff --git a/lib/admin/Controller/Root.pm b/lib/admin/Controller/Root.pm index 468c106..2989355 100644 --- a/lib/admin/Controller/Root.pm +++ b/lib/admin/Controller/Root.pm @@ -31,6 +31,8 @@ Verify user is logged in. sub auto : Private { my ($self, $c) = @_; + $c->stash->{build_version} = $admin::BUILD_VERSION; + if ($c->controller =~ /^admin::Controller::Root\b/ or $c->controller =~ /^admin::Controller::login\b/) { diff --git a/root/layout/footer b/root/layout/footer index 7553d9a..c3675f1 100644 --- a/root/layout/footer +++ b/root/layout/footer @@ -1,7 +1,7 @@