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

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






On Wed, Jan 2, 2013 at 4:51 AM, <..hidden..> wrote:
Revision: 5458
     http://ledger-smb.svn.sourceforge.net/ledger-smb/?rev=5458&view=rev
Author: Â einhverfr
Date: Â Â 2013-01-02 03:51:08 +0000 (Wed, 02 Jan 2013)
Log Message:
-----------
Merging setup.pl enhancements to 1.3

Modified Paths:
--------------
  branches/1.3/Changelog
  branches/1.3/LedgerSMB/Database.pm
  branches/1.3/UI/setup/confirm_operation.html
  branches/1.3/scripts/setup.pl

Added Paths:
-----------
  branches/1.3/UI/setup/list_databases.html

Property Changed:
----------------
  branches/1.3/
  branches/1.3/scripts/setup.pl


Property changes on: branches/1.3
___________________________________________________________________
Modified: svn:mergeinfo
 Â- /trunk:3711-3712,5424
 Â+ /trunk:3711-3712,5424,5446-5448,5457

Modified: branches/1.3/Changelog
===================================================================
--- branches/1.3/Changelog   Â2013-01-02 03:48:47 UTC (rev 5457)
+++ branches/1.3/Changelog   Â2013-01-02 03:51:08 UTC (rev 5458)
@@ -2,6 +2,11 @@
ÂInitial Release: ÂMonday, Oct 12 2011
ÂSupported Presently

+Changelog for 1.3.28
+* Added db list to setup.pl when no db is entered and credentials allow login
+ Âto "postgres" db. (Chris T)
+* Added copy db utility to setup.pl for testing dbs (Chris T)
+
ÂChangelog for 1.3.27
Â* Detect whether ledgersmb.conf exists during Makefile.PL run and create if
 Ânot (Chris T)

Modified: branches/1.3/LedgerSMB/Database.pm
===================================================================
--- branches/1.3/LedgerSMB/Database.pm Â2013-01-02 03:48:47 UTC (rev 5457)
+++ branches/1.3/LedgerSMB/Database.pm Â2013-01-02 03:51:08 UTC (rev 5458)
@@ -22,6 +22,7 @@
Â# Methods are documented inline.

Âpackage LedgerSMB::Database;
+use DBI;

Âour $VERSION = '1';

@@ -273,7 +274,6 @@
Â=cut

Âsub get_info {
- Â Âuse DBI;
  Âuse LedgerSMB::Auth;
  Âmy $self = shift @_;
  Âmy $retval = { # defaults
@@ -393,6 +393,39 @@
  Âreturn $retval;
Â}

+=item $db->list()
+
+Lists available databases except for those named "postgres" or starting with
+"template"
+
+Returns a list of strings of db names.
+
+=cut
+
+sub list {
+ Â Âmy ($self) = @_;
+ Â Âmy $creds = LedgerSMB::Auth->get_credentials();
+ Â Âmy $dbh = DBI->connect(
+ Â Â Â Â"dbi:Pg:dbname=postgres",
+ Â Â Â Â "$creds->{login}", "$creds->{password}", { AutoCommit => 0 }
+ Â Â);
+ Â Âmy $resultref = $dbh->selectall_arrayref(
+ Â Â Â Â"SELECT datname FROM pg_database
+ Â Â Â Â ÂWHERE datname <> 'postgres' AND datname NOT LIKE 'template%'
+ Â Â Â ORDER BY datname"
+ Â Â);
+ Â Âmy @results;
+ Â Âfor my $r (@$resultref){
+ Â Â Â Âpush @results, values @$r;
+ Â Â}
+
+ Â Â$dbh->disconnect;
+ Â Âuse Data::Dumper;
+ Â Âreturn @results;
+}
+
+
+
Â=item $db->create();

ÂCreates a database and loads the contrib files. ÂThis is done from template0,
@@ -420,7 +453,6 @@
  Â#
  Â# Hat tip: Âirc user nwnw -- CT

- Â Âuse DBI;
  Âmy $dbh = DBI->connect('dbi:Pg:dbname=template1');

  Â$dbh->{RaiseError} = 1;
@@ -454,6 +486,25 @@
   return $rc;
Â}

+=item $db->copy('new_name')
+
+Copies the existing database to a new name.
+
+=cut
+
+sub copy {
+ Â Âmy ($self, $new_name) = @_;
+ Â Âmy $dbh = DBI->connect('dbi:Pg:dbname=postgres',
+ Â Â Â Â $self->{username}, $self->{password},
+ Â Â Â Â { AutoCommit => 1, PrintError => 1, }
+ Â Â);
+ Â Âmy $dbname = $dbh->quote_identifier($self->{company_name});
+ Â Â$new_name = $dbh->quote_identifier($new_name);
+ Â Âmy $rc = $dbh->do("CREATE DATABASE $new_name WITH TEMPLATE $dbname");
+ Â Â$dbh->disconnect;
+ Â Âreturn $rc;
+}
+
Â=item $db->load_modules($loadorder)

ÂLoads or reloads sql modules from $loadorder

Modified: branches/1.3/UI/setup/confirm_operation.html
===================================================================
--- branches/1.3/UI/setup/confirm_operation.html    Â2013-01-02 03:48:47 UTC (rev 5457)
+++ branches/1.3/UI/setup/confirm_operation.html    Â2013-01-02 03:51:08 UTC (rev 5458)
@@ -27,7 +27,23 @@
Â</div>
Â<div id="sep" class="listheading"><?lsmb text('Other Actions') ?></div>
Â<?lsmb IF next_action == 'rebuild_modules' ?>
+<div id="copy database">
+<?lsmb INCLUDE input element_data = {
+ Â Âname = 'new_name'
+ Â Âtype = 'text'
+ Â class = 'dbname'
+ Â label = text('Copy to New Name') #'
+}; ?>
+<?lsmb INCLUDE button element_data = {
+ Â Âname = 'action'
+ Â value = 'copy_db'
+ Â Âtype = 'submit'
+ Â class = 'submit'
+ Â Âtext = text('Copy') #'
+}; ?>
+
Â<div id="user">
+<div><?lsmb text('Users') ?></div>
Â<?lsmb INCLUDE button element_data = {
  Âname = 'action'
  value = 'skip_coa'

Copied: branches/1.3/UI/setup/list_databases.html (from rev 5448, trunk/UI/setup/list_databases.html)
===================================================================
--- branches/1.3/UI/setup/list_databases.html              (rev 0)
+++ branches/1.3/UI/setup/list_databases.html  2013-01-02 03:51:08 UTC (rev 5458)
@@ -0,0 +1,17 @@
+<?lsmb INCLUDE "ui-header.html"
+stylesheet="ledgersmb.css"
+include_stylesheet=["UI/setup/stylesheet.css"];
+ Â Â Â PROCESS "elements.html";
+ Â Â Â PROCESS "dynatable.html"; ?>
+<body>
+<div class="listtop"><?lsmb text('Available Databases') ?></div>
+<?lsmb
+ Â ÂINCLUDE dynatable
+ Â Â Â Â Â Âcolumns = [{col_id = 'db',
+ Â Â Â Â Â Â Â Â Â Â Â name = text('Database'),
+ Â Â Â Â Â Â Â Â Â Â Â type = 'href'
+ Â Â Â Â Â Â Â Â Âhref_base = 'setup.pl?action="">}]
+ Â Â Â Â Â Âtbody = {rows = dbs}
+ Â Â Â Â Â Â Âid = 'db_list' ?>
+</body>
+</html>

Modified: branches/1.3/scripts/
setup.pl
===================================================================
--- branches/1.3/scripts/setup.pl    2013-01-02 03:48:47 UTC (rev 5457)
+++ branches/1.3/scripts/setup.pl    2013-01-02 03:51:08 UTC (rev 5458)
@@ -50,7 +50,8 @@
  Â#$request->{_locale}->new('en'); why not continue to use already set $request->{_locale}
  Âmy $creds = LedgerSMB::Auth::get_credentials();
  Âif (!$request->{database}){
- Â Â Â Â$request->error($request->{_locale}->text('No database specified'));
+ Â Â Â Âlist_databases($request);
+ Â Â Â Âreturn;
  Â}
  Âmy $database = LedgerSMB::Database->new(
        {username => $creds->{login},
@@ -157,6 +158,57 @@

Â}

+=item list_databases
+Lists all databases as hyperlinks to continue operations.
+
+=cut
+
+sub list_databases {
+ Â Âmy ($request) = @_;
+ Â Âmy $creds = LedgerSMB::Auth::get_credentials('setup');
+ Â Âmy $database = LedgerSMB::Database->new(
+ Â Â Â Â Â Â Â {username => $creds->{login},
+ Â Â Â Â Â Âcompany_name => $request->{database},
+ Â Â Â Â Â Â Â Âpassword => $creds->{password}}
+ Â Â);
+ Â Âmy @results = $database->list;
+ Â Â$request->{dbs} = [];
+ Â Âfor my $r (@results){
+ Â Â Â push @{$request->{dbs}}, {row_id => $r, db => $r };
+ Â Â}
+ Â Âmy $template = LedgerSMB::Template->new(
+ Â Â Â Â Â Âpath => 'UI/setup',
+ Â Â Â Â Â Âtemplate => 'list_databases',
+ Â Â Â Â Â format => 'HTML',
+ Â Â);
+ Â Â$template->render($request);
+}
+
+=item copy_db
+
+Copies db to the name of $request->{new_name}
+
+=cut
+
+sub copy_db {
+ Â Âmy ($request) = @_;
+ Â Âmy $creds = LedgerSMB::Auth::get_credentials('setup');
+ Â Âmy $database = LedgerSMB::Database->new(
+ Â Â Â Â Â Â Â {username => $creds->{login},
+ Â Â Â Â Â Âcompany_name => $request->{database},
+ Â Â Â Â Â Â Â Âpassword => $creds->{password}}
+ Â Â);
+ Â Âmy $rc = $database->copy($request->{new_name})
+ Â Â Â Â Â || die 'An error occurred. Please check your database logs.' ;
+ Â Âmy $template = LedgerSMB::Template->new(
+ Â Â Â Â Â Âpath => 'UI/setup',
+ Â Â Â Â Â Âtemplate => 'complete',
+ Â Â Â Â Â Âformat => 'HTML',
+ Â Â);
+ Â Â$template->render($request);
+}
+
+
Â=item backup_db

ÂBacks up a full db


Property changes on: branches/1.3/scripts/setup.pl
___________________________________________________________________
Added: svn:mergeinfo
 Â+ /trunk/LedgerSMB/Scripts/setup.pm:5446-5448
/trunk/scripts/setup.pl:3711-3712,5424,5446-5448

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


------------------------------------------------------------------------------
Master Java SE, Java EE, Eclipse, Spring, Hibernate, _javascript_, jQuery
and much more. Keep your Java skills current with LearnJavaNow -
200+ hours of step-by-step video tutorials by Java experts.
SALE $49.99 this month only -- learn more at:
http://p.sf.net/sfu/learnmore_122612
_______________________________________________
Ledger-smb-commits mailing list
..hidden..
https://lists.sourceforge.net/lists/listinfo/ledger-smb-commits