[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
SF.net SVN: ledger-smb:[3445] trunk
- Subject: SF.net SVN: ledger-smb:[3445] trunk
- From: ..hidden..
- Date: Tue, 05 Jul 2011 13:01:31 +0000
Revision: 3445
http://ledger-smb.svn.sourceforge.net/ledger-smb/?rev=3445&view=rev
Author: einhverfr
Date: 2011-07-05 13:01:30 +0000 (Tue, 05 Jul 2011)
Log Message:
-----------
Changes made to admin__save_user to support importing existing users, and adding support for application-handling of database exceptions
Minor UI tweaks for manual tax lines
Modified Paths:
--------------
trunk/LedgerSMB/DBObject/Admin.pm
trunk/LedgerSMB/DBObject.pm
trunk/LedgerSMB/IR.pm
trunk/LedgerSMB/IS.pm
trunk/bin/ir.pl
trunk/sql/modules/Roles.sql
trunk/sql/modules/admin.sql
trunk/t/40-dbsetup.t
trunk/tools/prepare-company-database.sh
Modified: trunk/LedgerSMB/DBObject/Admin.pm
===================================================================
--- trunk/LedgerSMB/DBObject/Admin.pm 2011-07-05 11:17:56 UTC (rev 3444)
+++ trunk/LedgerSMB/DBObject/Admin.pm 2011-07-05 13:01:30 UTC (rev 3445)
@@ -36,6 +36,7 @@
'password',
'is_a_user',
'user_id',
+ 'import',
]
);
$user->{entity_id} = $employee->{entity_id};
Modified: trunk/LedgerSMB/DBObject.pm
===================================================================
--- trunk/LedgerSMB/DBObject.pm 2011-07-05 11:17:56 UTC (rev 3444)
+++ trunk/LedgerSMB/DBObject.pm 2011-07-05 13:01:30 UTC (rev 3445)
@@ -21,11 +21,20 @@
use any subclass of that. The per-session dbh is passed between the objects
this way as is any information that is needed.
-=item exec_method ($self, procname => $function_name, args => ..hidden..)
+=item exec_method
+($self, procname => $function_name, [args => ..hidden.., schema => $schema,
+continue_on_error=>$continue_on_error])
+
Provides the basic mapping of parameters to the SQL stored procedure function
arguments.
+If ..hidden.. is not defined, args are mapped from the object's properties,
+stripping them of their in_ prefix. If schema is provided, that is used
+instead of PostgreSQL's search path. If continue_on_error is provided and true,
+the operation will not raise an exception in the event of a database error, and
+it will be up to the application to handle any exceptions.
+
=item __validate__ is called on every new() invocation. It is blank in this
module but can be overridden in decendant modules.
@@ -159,10 +168,18 @@
for (@in_args) { push @call_args, $_ } ;
$self->{call_args} = ..hidden..;
$logger->debug("exec_method: \$self = " . Data::Dumper::Dumper($self));
- return $self->call_procedure( procname => $funcname, args => ..hidden.., order_by => $self->{_order_method}->{"$funcname"}, schema=>$schema);
+ return $self->call_procedure( procname => $funcname,
+ args => ..hidden..,
+ order_by => $self->{_order_method}->{"$funcname"},
+ schema=>$schema,
+ continue_on_error => $args{continue_on_error});
}
else {
- return $self->call_procedure( procname => $funcname, args => ..hidden.., order_by => $self->{_order_method}->{"$funcname"}, schema=>$schema);
+ return $self->call_procedure( procname => $funcname,
+ args => ..hidden..,
+ order_by => $self->{_order_method}->{"$funcname"},
+ schema=>$schema,
+ continue_on_error => $args{continue_on_error});
}
}
Modified: trunk/LedgerSMB/IR.pm
===================================================================
--- trunk/LedgerSMB/IR.pm 2011-07-05 11:17:56 UTC (rev 3444)
+++ trunk/LedgerSMB/IR.pm 2011-07-05 13:01:30 UTC (rev 3445)
@@ -595,8 +595,6 @@
VALUES (currval('acc_trans_entry_id_seq'), ?, ?)"
);
for $taccno (split / /, $form->{taxaccounts}){
- $form->error('Must enter tax amount')
- unless $form->{"mt_amount_$taccno"};
my $taxamount;
my $taxbasis;
my $fx = $form->{exchangerate} || 1;
Modified: trunk/LedgerSMB/IS.pm
===================================================================
--- trunk/LedgerSMB/IS.pm 2011-07-05 11:17:56 UTC (rev 3444)
+++ trunk/LedgerSMB/IS.pm 2011-07-05 13:01:30 UTC (rev 3445)
@@ -1326,8 +1326,6 @@
VALUES (currval('acc_trans_entry_id_seq'), ?, ?)"
);
for $taccno (split / /, $form->{taxaccounts}){
- $form->error('Must enter tax amount')
- unless $form->{"mt_amount_$taccno"};
my $taxamount;
my $taxbasis;
my $fx = $form->{exchangerate} || 1;
Modified: trunk/bin/ir.pl
===================================================================
--- trunk/bin/ir.pl 2011-07-05 11:17:56 UTC (rev 3444)
+++ trunk/bin/ir.pl 2011-07-05 13:01:30 UTC (rev 3445)
@@ -532,7 +532,7 @@
if ( !$form->{taxincluded} ) {
if ($form->{manual_tax}){
$tax .= qq|
- <table><tr class="listtop">
+ <tr class="listtop">
<td> </td>
<th align="center">|.$locale->text('Amount').qq|</th>
<th align="center">|.$locale->text('Rate').qq|</th>
@@ -597,9 +597,6 @@
|;
}
}
- if ($form->{manual_tax}){
- $tax .= "</table>";
- }
$form->{invsubtotal} =
$form->format_amount( \%myconfig, $form->{invsubtotal}, 2, 0 );
Modified: trunk/sql/modules/Roles.sql
===================================================================
--- trunk/sql/modules/Roles.sql 2011-07-05 11:17:56 UTC (rev 3444)
+++ trunk/sql/modules/Roles.sql 2011-07-05 13:01:30 UTC (rev 3445)
@@ -1451,7 +1451,7 @@
TO "lsmb_<?lsmb dbname ?>__users_manage";
GRANT EXECUTE ON FUNCTION admin__get_roles_for_user(INT)
TO "lsmb_<?lsmb dbname ?>__users_manage";
-GRANT EXECUTE ON FUNCTION admin__save_user(int, INT, text, TEXT)
+GRANT EXECUTE ON FUNCTION admin__save_user(int, INT, text, TEXT, BOOL)
TO "lsmb_<?lsmb dbname ?>__users_manage";
GRANT EXECUTE ON FUNCTION admin__create_group(TEXT)
TO "lsmb_<?lsmb dbname ?>__users_manage";
Modified: trunk/sql/modules/admin.sql
===================================================================
--- trunk/sql/modules/admin.sql 2011-07-05 11:17:56 UTC (rev 3444)
+++ trunk/sql/modules/admin.sql 2011-07-05 13:01:30 UTC (rev 3445)
@@ -314,7 +314,8 @@
in_id int,
in_entity_id INT,
in_username text,
- in_password TEXT
+ in_password TEXT,
+ in_import BOOL
) returns int AS $$
DECLARE
@@ -327,6 +328,13 @@
-- WARNING TO PROGRAMMERS: This function runs as the definer and runs
-- utility statements via EXECUTE.
-- PLEASE BE VERY CAREFUL ABOUT SQL-INJECTION INSIDE THIS FUNCTION.
+
+ IF in_import IS NOT TRUE THEN
+ PERFORM rolname FROM pg_roles WHERE rolname = in_username;
+ IF FOUND THEN
+ RAISE EXCEPTION 'Duplicate user';
+ END IF;
+ END IF;
if admin__is_user(in_username) then
@@ -335,7 +343,7 @@
|| $e$ valid until $e$ || quote_literal(now() + '1 day'::interval);
else
if in_password IS NULL THEN
- RAISE EXCEPTION 'Must create password when adding new users!';
+ RAISE EXCEPTION 'No password';
end if;
-- create an actual user
@@ -380,7 +388,8 @@
in_id int,
in_entity_id INT,
in_username text,
- in_password TEXT
+ in_password TEXT,
+ in_import bool
) FROM public;
create view role_view as
Modified: trunk/t/40-dbsetup.t
===================================================================
--- trunk/t/40-dbsetup.t 2011-07-05 11:17:56 UTC (rev 3444)
+++ trunk/t/40-dbsetup.t 2011-07-05 13:01:30 UTC (rev 3445)
@@ -78,6 +78,7 @@
first_name => $ENV{LSMB_ADMIN_FNAME},
last_name => $ENV{LSMB_ADMIN_LNAME},
country_id => $id,
+ import => 't',
});
my $user = LedgerSMB::DBObject::Admin->new({base => $lsmb});
ok($user->save_user, 'User saved');
Modified: trunk/tools/prepare-company-database.sh
===================================================================
--- trunk/tools/prepare-company-database.sh 2011-07-05 11:17:56 UTC (rev 3444)
+++ trunk/tools/prepare-company-database.sh 2011-07-05 13:01:30 UTC (rev 3445)
@@ -256,7 +256,8 @@
(SELECT id FROM country
WHERE short_name = 'US')),
'$ADMIN_USERNAME',
- '$ADMIN_PASSWORD');
+ '$ADMIN_PASSWORD',
+ TRUE);
SELECT admin__add_user_to_role('$ADMIN_USERNAME', rolname)
FROM pg_roles
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.