[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

SF.net SVN: ledger-smb:[3812] branches/1.3



Revision: 3812
          http://ledger-smb.svn.sourceforge.net/ledger-smb/?rev=3812&view=rev
Author:   einhverfr
Date:     2011-10-07 23:46:20 +0000 (Fri, 07 Oct 2011)
Log Message:
-----------
Successful upgrade using database management wizard
fixing setup wizard bug 3417335

Modified Paths:
--------------
    branches/1.3/LedgerSMB/Template/TXT.pm
    branches/1.3/UI/setup/new_user.html
    branches/1.3/scripts/setup.pl

Modified: branches/1.3/LedgerSMB/Template/TXT.pm
===================================================================
--- branches/1.3/LedgerSMB/Template/TXT.pm	2011-10-07 22:17:28 UTC (rev 3811)
+++ branches/1.3/LedgerSMB/Template/TXT.pm	2011-10-07 23:46:20 UTC (rev 3812)
@@ -45,9 +45,19 @@
 use Template;
 use LedgerSMB::Template::TTI18N;
 
+sub get_extension {
+    my ($parent) = shift;
+    if ($parent->{format_args}->{extension}){
+        return $parent->{format_args}->{extension};
+    } else {
+        return 'txt';
+    }
+}
+
 sub get_template {
-    my $name = shift;
-    return "${name}.txt";
+    my ($name, $parent) = @_;
+    my $extension;
+    return "${name}.". get_extension($parent);
 }
 
 sub preprocess {
@@ -61,9 +71,8 @@
 	my $template;
 	my $source;
 	my $output;
-
 	if ($parent->{outputfile}) {
-		$output = "$parent->{outputfile}.txt";
+		$output = "$parent->{outputfile}.". get_extension($parent);
 	} else {
 		$output = \$parent->{output};
 	}
@@ -72,7 +81,7 @@
 	} elsif (ref $parent->{template} eq 'ARRAY') {
 		$source = join "\n", @{$parent->{template}};
 	} else {
-		$source = get_template($parent->{template});
+		$source = get_template($parent->{template}, $parent);
 	}
 	$template = Template->new({
 		INCLUDE_PATH => $parent->{include_path},
@@ -95,7 +104,7 @@
 
 sub postprocess {
     my $parent = shift;
-    $parent->{rendered} = "$parent->{outputfile}.txt" if $parent->{outputfile};
+    $parent->{rendered} = "$parent->{outputfile}.". get_extension($parent) if $parent->{outputfile};
     return $parent->{rendered};
 }
 

Modified: branches/1.3/UI/setup/new_user.html
===================================================================
--- branches/1.3/UI/setup/new_user.html	2011-10-07 22:17:28 UTC (rev 3811)
+++ branches/1.3/UI/setup/new_user.html	2011-10-07 23:46:20 UTC (rev 3812)
@@ -11,6 +11,9 @@
    value = database
 } ?>
 <div class="form">
+<?lsmb- IF notice -?>
+<div class="notice"><?lsmb notice ?></div>
+<?lsmb- END # IF notice -?>
 <div class="input_row">
 <?lsmb INCLUDE input element_data = {
                             name  = 'username'

Modified: branches/1.3/scripts/setup.pl
===================================================================
--- branches/1.3/scripts/setup.pl	2011-10-07 22:17:28 UTC (rev 3811)
+++ branches/1.3/scripts/setup.pl	2011-10-07 23:46:20 UTC (rev 3812)
@@ -476,7 +476,32 @@
                                    $creds->{login},
                                    $creds->{password});
     my $user = LedgerSMB::DBObject::Admin->new({base => $request});
-    $user->save_user;
+    if (8 == $user->save_user){ # Told not to import but user exists in db
+        $request->{notice} = $request->{_locale}->text(
+                       'User already exists. Import?'
+        );
+
+
+       @{$request->{salutations}} 
+        = $request->call_procedure(procname => 'person__list_salutations' ); 
+          
+       @{$request->{countries}} 
+        = $request->call_procedure(procname => 'location_list_country' ); 
+
+       my $locale = $request->{_locale};
+
+       @{$request->{perm_sets}} = (
+           {id => '0', label => $locale->text('Manage Users')},
+           {id => '1', label => $locale->text('Full Permissions')},
+       );
+        my $template = LedgerSMB::Template->new(
+                path => 'UI/setup',
+                template => 'new_user',
+         format => 'HTML',
+        );
+        $template->render($request);
+        exit;        
+    }
     if ($request->{perms} == 1){
          for my $role (
                 $request->call_procedure(procname => 'admin__get_roles')
@@ -533,8 +558,8 @@
     $dbh->do('CREATE SCHEMA PUBLIC');
     # Copying contrib script loading for now
     my $rc = 0;
-    my $temp = $LedgerSMB::Sysconfig::temp;
-     my @contrib_scripts = qw(pg_trgm tsearch2 tablefunc);
+    my $temp = $LedgerSMB::Sysconfig::tempdir;
+     my @contrib_scripts = qw(tsearch2 tablefunc);
 
      for my $contrib (@contrib_scripts){
          my $rc2;
@@ -546,14 +571,33 @@
      $rc ||= $rc2;
 
     $database->load_modules('LOADORDER');
+    $database->process_roles('Roles.sql');
     my $dbtemplate = LedgerSMB::Template->new(
         user => {}, 
-        template => 'sql/upgrade/1.2-1.3.sql',
+        path => 'sql/upgrade',
+        template => '1.2-1.3',
         no_auto_output => 1,
-        format => 'text' );
+        format_options => {extension => 'sql'},
+        output_file => '1.2-1.3-upgrade',
+        format => 'TXT' );
     $dbtemplate->render($request);
-    $rc2 = system("psql -f $dbtemplate->{rendered} >> $temp/dblog_stdout 2>>$temp/dblog_stderr");
+    $rc2 = system("psql -f $temp/1.2-1.3-upgrade.sql >> $temp/dblog_stdout 2>>$temp/dblog_stderr");
     $rc ||= $rc2;
+
+    $request->{dbh} = DBI->connect("dbi:Pg:dbname=$request->{database}");
+
+   @{$request->{salutations}} 
+    = $request->call_procedure(procname => 'person__list_salutations' ); 
+          
+   @{$request->{countries}} 
+    = $request->call_procedure(procname => 'location_list_country' ); 
+
+   my $locale = $request->{_locale};
+
+   @{$request->{perm_sets}} = (
+       {id => '0', label => $locale->text('Manage Users')},
+       {id => '1', label => $locale->text('Full Permissions')},
+   );
     my $template = LedgerSMB::Template->new(
                    path => 'UI/setup',
                    template => 'new_user',

This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.