From c44fb8653b10cb4c168c5ae77294bf0f302fde14 Mon Sep 17 00:00:00 2001 From: Julien Simonet Date: Tue, 21 Jan 2014 00:16:26 +0100 Subject: [PATCH] =?UTF-8?q?Nouvel=20affichage=20concernant=20la=20cr=C3=A9?= =?UTF-8?q?ation=20d'une=20zone.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Un message indique si la zone a été créée ou non. - Le if/else de la page mapage.tt n'a pas beaucoup d'intérêt dans l'état actuel des choses. Il servira lorsqu'on qu'on voudra faire la mise en page (avec une mise en page différente en case de succès ou d'échec). Suppression de mapage.tt --- www/lib/DNSManager.pm | 68 ++++++++++++++++++++++++++++++++++--------- www/views/home.tt | 11 +++++++ 2 files changed, 65 insertions(+), 14 deletions(-) diff --git a/www/lib/DNSManager.pm b/www/lib/DNSManager.pm index 592a196..ece6160 100644 --- a/www/lib/DNSManager.pm +++ b/www/lib/DNSManager.pm @@ -67,15 +67,35 @@ get '/home' => sub { my %domains = (); my %zone_properties = (); - my @d = @{$app->get_domains( session('login') )}; - - template home => { - login => session('login') - , domains => $app->get_domains(session('login')) - , zones_domains => \%domains - , zone_properties => \%zone_properties - , admin => session('admin') }; + # my @d = @{$app->get_domains( session('login') )}; + if( session('creationSuccess') || session('creationFailure') ) + { + my $cs = session('creationSuccess'); + session 'creationSuccess' => ''; + my $cf = session('creationFailure'); + session 'creationFailure' => ''; + my $dn = session('domainName'); + session 'domainName' => ''; + template home => + { 'login' => session('login'), + 'domains' => $app->get_domains(session('login')), + 'zones_domains' => \%domains, + 'zone_properties' => \%zone_properties, + 'admin' => session('admin'), + 'creationSuccess' => $cs, + 'creationFailure' => $cf, + 'domainName' => $dn }; + } + else + { + template home => + { 'login' => session('login'), + 'domains' => $app->get_domains(session('login')), + 'zones_domains' => \%domains, + 'zone_properties' => \%zone_properties, + 'admin' => session('admin') }; + } } }; @@ -137,12 +157,32 @@ prefix '/domain' => sub { else { - # Add tld - my $domain = param('domain').$cfg->param('tld'); - $domain =~ s/\.{2,}/\./g; - # create domain - my $app = initco(); - $app->add_domain( session('login'), param('domain') ); + my $creationSuccess = false; + my $creationFailure = false; + if( param('domain') =~ /^[a-zA-Z0-9]+[a-zA-Z0-9-]+[a-zA-Z0-9]+$|^[a-zA-Z0-9]+$/ ) + { + + my $cfg = new Config::Simple(dirname(__FILE__).'/../conf/config.ini'); + my $domain = param('domain').$cfg->param('tld'); + # $domain =~ s/\.{2,}/\./g; + # say "domain after sed : $domain"; + # create domain + my $app = initco(); + # Add tld + # create domain + $app->add_domain( session('login'), $domain ); + $creationSuccess = true; + + } + else + { + # say param('domain')." contains a char not valid"; + $creationFailure = true; + } + + session 'creationSuccess' => $creationSuccess; + session 'creationFailure' => $creationFailure; + session 'domainName' => param('domain'); redirect '/home'; } diff --git a/www/views/home.tt b/www/views/home.tt index 6de350c..896488f 100644 --- a/www/views/home.tt +++ b/www/views/home.tt @@ -16,6 +16,17 @@
+ + <% IF creationSuccess == 1 %> +

+ Le domaine "<% domainName %>" a bien été créée. +

+ <% ELSIF creationFailure == 1 %> +

+ Le domaine "<% domainName %>" n'a pas été créée. +

+ <% END %> + <% IF domains && domains.size %>

Vos domaines :