[vhffs-dev] [539] Modified CVS creation interface so it uses only one page and allows easier modifications .

[ Thread Index | Date Index | More vhffs.org/vhffs-dev Archives ]


Revision: 539
Author:   beuss
Date:     2007-04-05 07:12:46 +0000 (Thu, 05 Apr 2007)

Log Message:
-----------
Modified CVS creation interface so it uses only one page and allows easier modifications.

Modified Paths:
--------------
    branches/vhffs_4.1/vhffs-panel/cvs/create.pl
    branches/vhffs_4.1/vhffs-panel/panel.pl
    branches/vhffs_4.1/vhffs-panel/templates/cvs/create.tmpl
    branches/vhffs_4.1/vhffs-panel/templates/group/info.tmpl
    branches/vhffs_4.1/vhffs-panel/themes/vhffs-ng/main.css

Removed Paths:
-------------
    branches/vhffs_4.1/vhffs-panel/cvs/cvs_submit.pl


Modified: branches/vhffs_4.1/vhffs-panel/cvs/create.pl
===================================================================
--- branches/vhffs_4.1/vhffs-panel/cvs/create.pl	2007-04-01 12:14:46 UTC (rev 538)
+++ branches/vhffs_4.1/vhffs-panel/cvs/create.pl	2007-04-05 07:12:46 UTC (rev 539)
@@ -56,18 +56,46 @@
 my $maintemplate = $panel->{'template'};
 my $user = $panel->{'user'};
 my $group = $panel->{'group'};
+my $cgi = $panel->{cgi};
+my $submitted = defined($cgi->param('cvs_submit'));
 
+my $repo_name = $cgi->param('REPOSITORY_NAME');
+my $description = $cgi->param('DESCRIPTION');
+
 my $templatedir = $vhffs->get_config->get_templatedir;
 
-my $template = new HTML::Template( filename => $templatedir."/cvs/create.tmpl" );
+if($submitted) {
+    if( $repo_name !~ /^[a-z0-9]+$/ ) {
+        $panel->add_error( gettext('Your repository name is not correct. It must contains only caracter and numbers') );
+    } elsif( length( $repo_name ) < 3 ) {
+        $panel->add_error( gettext('Your repository name is not correct. It must contains at least 3 caracters') );
+    } elsif( $description =~ /^\s*$/ ) {
+        $panel->add_error( gettext('You must enter a description') );
+    } else {
+        #Create CVS
+        my $cvs = Vhffs::Panel::Cvs::create_cvs( $vhffs, $repo_name, $description, $user , $group );
+        if( defined $cvs ) {
+            my $url = '/panel.pl?project='.$panel->{groupname}.'&msg='.gettext('The CVS object was successfully created !');
+            $panel->redirect($url);
+        } else {
+            $panel->add_error( gettext( 'An error occured while creating the object.It probably already exists' ) );
+        }
+    }
+}
 
-$template->param( TITLE => gettext("Create a CVS Repository") );
-$template->param( REPOSITORY_NAME => gettext("Repository Name") );
-$template->param( GROUP_NAME => gettext("Group owning this CVS") );
+if(!$submitted || $panel->has_errors()) {
+    my $template = new HTML::Template( filename => $templatedir."/cvs/create.tmpl" );
+    
+    $panel->set_title( gettext('Create a CVS Repository') );
 
+    $template->param( REPOSITORY_NAME => gettext("Repository Name") );
+    $template->param( REPOSITORY_VALUE => $repo_name );
+    $template->param( GROUP_NAME => gettext("Group owning this CVS") );
 
-$template->param( GROUP => $group->get_groupname );
-$template->param( SEND => gettext("Send") );
-$template->param( DESCRIPTION => gettext("Description") );
+    $template->param( GROUP => $group->get_groupname );
+    $template->param( SEND => gettext("Send") );
+    $template->param( DESCRIPTION => gettext("Description") );
+    $template->param( DESCRIPTION_VALUE => $description);
 
-display Vhffs::Panel::Main($panel, $template->output);
+    display Vhffs::Panel::Main($panel, $template->output);
+}

Deleted: branches/vhffs_4.1/vhffs-panel/cvs/cvs_submit.pl
===================================================================
--- branches/vhffs_4.1/vhffs-panel/cvs/cvs_submit.pl	2007-04-01 12:14:46 UTC (rev 538)
+++ branches/vhffs_4.1/vhffs-panel/cvs/cvs_submit.pl	2007-04-05 07:12:46 UTC (rev 539)
@@ -1,100 +0,0 @@
-#!/usr/bin/perl -w
-# Copyright (c) vhffs project and its contributors
-# All rights reserved.
-#
-# Redistribution and use in source and binary forms, with or without 
-# modification, are permitted provided that the following conditions 
-# are met:
-#
-# 1. Redistributions of source code must retain the above copyright 
-#   notice, this list of conditions and the following disclaimer.
-#2. Redistributions in binary form must reproduce the above copyright
-#   notice, this list of conditions and the following disclaimer in 
-#   the documentation and/or other materials provided with the 
-#   distribution.
-#3. Neither the name of vhffs nor the names of its contributors 
-#   may be used to endorse or promote products derived from this 
-#   software without specific prior written permission.
-#
-#THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 
-#"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 
-#LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 
-#FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 
-#COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 
-#INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 
-#BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 
-#LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 
-#CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 
-# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 
-# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 
-# POSSIBILITY OF SUCH DAMAGE.
-
-
-# This file is a part of VHFFS project
-# Please consider the entire project
-
-# Author: sod
-
-use POSIX qw(locale_h);
-use HTML::Template;
-use locale;
-use Locale::gettext;
-use CGI;
-use CGI::Session;
-use strict;
-
-use lib "/usr/share/vhffs/api/";
-use Vhffs::User;
-use Vhffs::Group;
-use Vhffs::Main;
-use Vhffs::Panel::Main;
-use Vhffs::Panel::Menu;
-use Vhffs::Panel::Group;
-
-my $panel = new Vhffs::Panel::Main;
-if(!$panel)  {
-        exit 0;
-}
-
-my $vhffs = $panel->{'vhffs'};
-my $session = $panel->{'session'};
-my $maintemplate = $panel->{'template'};
-my $user = $panel->{'user'};
-my $group = $panel->{'group'};
-my $groupname = $panel->{'groupname'};
-my $cgi = $panel->{'cgi'};
-my $message;
-
-my $repo_name = $cgi->param("REPOSITORY_NAME");
-my $description = $cgi->param("DESCRIPTION");
-
-my $templatedir = $vhffs->get_config->get_templatedir;
-
-
-if( ! ( $repo_name =~ /^[a-z0-9]+$/ ) )
-{
-	$message = gettext("Your repository name is not correct. It must contains only caracter and numbers");
-}
-elsif( length( $repo_name ) < 3 )
-{
-	$message = gettext("Your repository name is not correct. It must contains at least 3 caracters");
-}
-else
-{
-    #Create CVS
-    my $cvs = Vhffs::Panel::Cvs::create_cvs( $vhffs, $repo_name, $description, $user , $group );
-    if( defined $cvs )
-    {
-	$message = gettext("The CVS object was successfully created !");
-    }
-    else
-    {
-	$message = gettext( "An error occured while creating the object.It probably already exists" );
-    }
-}
-
-my $template = new HTML::Template( filename => $templatedir."/misc/simplemsg.tmpl" );
-$template->param( MESSAGE => $message );
-
-set_refresh_url Vhffs::Panel::Main($panel, "/panel.pl?project=$groupname", 0);
-display Vhffs::Panel::Main($panel, $template->output);

Modified: branches/vhffs_4.1/vhffs-panel/panel.pl
===================================================================
--- branches/vhffs_4.1/vhffs-panel/panel.pl	2007-04-01 12:14:46 UTC (rev 538)
+++ branches/vhffs_4.1/vhffs-panel/panel.pl	2007-04-05 07:12:46 UTC (rev 539)
@@ -102,6 +102,7 @@
 	if( defined $projectname )
 	{
 		$template = project_info Vhffs::Panel::Main($vhffs, $panel->{group});
+        $template->param( MESSAGE => $cgi->param('msg') ) if(defined $cgi->param('msg'));
 	}
 	else
 	{

Modified: branches/vhffs_4.1/vhffs-panel/templates/cvs/create.tmpl
===================================================================
--- branches/vhffs_4.1/vhffs-panel/templates/cvs/create.tmpl	2007-04-01 12:14:46 UTC (rev 538)
+++ branches/vhffs_4.1/vhffs-panel/templates/cvs/create.tmpl	2007-04-05 07:12:46 UTC (rev 539)
@@ -1,6 +1,6 @@
 <h1><TMPL_VAR NAME="TITLE"></h1>
 
-<form method="post" action="cvs_submit.pl">
+<form method="post" action="create.pl">
 	<p>
 		<label>		
 			<TMPL_VAR NAME="GROUP_NAME">: 
@@ -11,15 +11,15 @@
 		<label for="REPOSITORY_NAME">		
 			<TMPL_VAR NAME="REPOSITORY_NAME">: 
 		</label>	
-		<input type="text" name="REPOSITORY_NAME" id="REPOSITORY_NAME"/>
+		<input type="text" name="REPOSITORY_NAME" id="REPOSITORY_NAME" value="<tmpl_var name="REPOSITORY_VALUE">"/>
 	</p>
 	<p>
 		<label for="PROJECT_USAGE">		
 			<TMPL_VAR NAME="DESCRIPTION">:
 		</label>	
-		<textarea name="DESCRIPTION" cols="45" rows="7"></textarea>
+		<textarea name="DESCRIPTION" cols="45" rows="15"><tmpl_var name="DESCRIPTION_VALUE"></textarea>
 	</p>
 	<p class="button" id="buttonSend">
-		<input type="submit" value="<TMPL_VAR NAME="SEND">" />
+		<input type="submit" value="<TMPL_VAR NAME="SEND">" id="cvs_submit" name="cvs_submit" />
 	</p>
 </form>

Modified: branches/vhffs_4.1/vhffs-panel/templates/group/info.tmpl
===================================================================
--- branches/vhffs_4.1/vhffs-panel/templates/group/info.tmpl	2007-04-01 12:14:46 UTC (rev 538)
+++ branches/vhffs_4.1/vhffs-panel/templates/group/info.tmpl	2007-04-05 07:12:46 UTC (rev 539)
@@ -5,6 +5,7 @@
 		<tmpl_var name="QUOTA_VALUE">
 	</div>
 
+    <p class="info"><tmpl_var name="MESSAGE"></p>
 	<h2><tmpl_var name="WEBAREA"></h2>
 	<ul>
 		<tmpl_var name="WEBAREA_VALUES">

Modified: branches/vhffs_4.1/vhffs-panel/themes/vhffs-ng/main.css
===================================================================
--- branches/vhffs_4.1/vhffs-panel/themes/vhffs-ng/main.css	2007-04-01 12:14:46 UTC (rev 538)
+++ branches/vhffs_4.1/vhffs-panel/themes/vhffs-ng/main.css	2007-04-05 07:12:46 UTC (rev 539)
@@ -300,10 +300,14 @@
 	margin-bottom:5px;
 }
 
-form input, form select, form textarea
+form input, form select
 {
 	width:200px;
 }
+form textarea {
+    width:350px;
+}
+
 form input[type="checkbox"], form input[type="radio"]
 {
 	width:auto;


Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/