[open-ils-commits] r14882 - in trunk/Open-ILS: src/perlmods/OpenILS/Application src/perlmods/OpenILS/Application/Actor web/js/ui/default/actor/user (erickson)
svn at svn.open-ils.org
svn at svn.open-ils.org
Thu Nov 12 12:04:01 EST 2009
Author: erickson
Date: 2009-11-12 12:03:58 -0500 (Thu, 12 Nov 2009)
New Revision: 14882
Modified:
trunk/Open-ILS/src/perlmods/OpenILS/Application/Actor.pm
trunk/Open-ILS/src/perlmods/OpenILS/Application/Actor/Stage.pm
trunk/Open-ILS/web/js/ui/default/actor/user/register.js
Log:
Added ability to retrieve/edit a staged user and subsequently save as a "real" user.
importing Stage module into Actor.pm
Added retrieve by username API to Stage.pm
Modified: trunk/Open-ILS/src/perlmods/OpenILS/Application/Actor/Stage.pm
===================================================================
--- trunk/Open-ILS/src/perlmods/OpenILS/Application/Actor/Stage.pm 2009-11-12 14:37:02 UTC (rev 14881)
+++ trunk/Open-ILS/src/perlmods/OpenILS/Application/Actor/Stage.pm 2009-11-12 17:03:58 UTC (rev 14882)
@@ -62,7 +62,7 @@
my $stage_ids = $e->search_staging_user_stage(
[
- { home_ou => $org_id},
+ { home_ou => $org_id, complete => 'f'},
{ limit => $limit,
offset => $offset,
order_by => {stgu => 'row_id'}
@@ -88,7 +88,29 @@
}
+__PACKAGE__->register_method (
+ method => 'user_stage_by_uname',
+ api_name => 'open-ils.actor.user.stage.retrieve.by_username',
+);
+sub user_stage_by_uname {
+ my($self, $conn, $auth, $username) = @_;
+
+ my $e = new_editor(authtoken => $auth);
+ return $e->event unless $e->checkauth;
+
+ my $user = $e->search_staging_user_stage({
+ usrname => $username,
+ complete => 'f'
+ })->[0] or return $e->event;
+
+ return $e->event unless $e->allowed('VIEW_USER', $user->home_ou);
+ return flesh_user_stage($e, $user->row_id);
+}
+
+
+
+
__PACKAGE__->register_method (
method => 'delete_user_stage',
api_name => 'open-ils.actor.user.stage.delete',
Modified: trunk/Open-ILS/src/perlmods/OpenILS/Application/Actor.pm
===================================================================
--- trunk/Open-ILS/src/perlmods/OpenILS/Application/Actor.pm 2009-11-12 14:37:02 UTC (rev 14881)
+++ trunk/Open-ILS/src/perlmods/OpenILS/Application/Actor.pm 2009-11-12 17:03:58 UTC (rev 14882)
@@ -30,6 +30,7 @@
use OpenILS::Application::Actor::ClosedDates;
use OpenILS::Application::Actor::UserGroups;
use OpenILS::Application::Actor::Friends;
+use OpenILS::Application::Actor::Stage;
use OpenILS::Utils::CStoreEditor qw/:funcs/;
use OpenILS::Utils::Penalty;
Modified: trunk/Open-ILS/web/js/ui/default/actor/user/register.js
===================================================================
--- trunk/Open-ILS/web/js/ui/default/actor/user/register.js 2009-11-12 14:37:02 UTC (rev 14881)
+++ trunk/Open-ILS/web/js/ui/default/actor/user/register.js 2009-11-12 17:03:58 UTC (rev 14882)
@@ -39,6 +39,7 @@
var cgi;
var cloneUser;
var cloneUserObj;
+var stageUser;
if(!window.xulG) var xulG = null;
@@ -50,6 +51,7 @@
cgi = new openils.CGI();
cloneUser = cgi.param('clone');
var userId = cgi.param('usr');
+ var stageUname = cgi.param('stage');
if(xulG) {
if(xulG.ses) openils.User.authtoken = xulG.ses;
@@ -81,9 +83,13 @@
if(userId) {
patron = uEditLoadUser(userId);
} else {
- patron = uEditNewPatron();
- if(cloneUser)
- uEditCopyCloneData(patron);
+ if(stageUname) {
+ patron = uEditLoadStageUser(stageUname);
+ } else {
+ patron = uEditNewPatron();
+ if(cloneUser)
+ uEditCopyCloneData(patron);
+ }
}
@@ -113,6 +119,76 @@
checkClaimsNoCheckoutCountPerm();
}
+
+/**
+ * Loads a staged user and turns them into something the editor can understand
+ */
+function uEditLoadStageUser(stageUname) {
+
+ var data = fieldmapper.standardRequest(
+ ['open-ils.actor', 'open-ils.actor.user.stage.retrieve.by_username'],
+ { params : [openils.User.authtoken, stageUname] }
+ );
+
+ stageUser = data.user;
+ patron = uEditNewPatron();
+
+ // copy the data into our new user object
+ for(var key in fieldmapper.IDL.fmclasses.stgu.field_map) {
+ if(fieldmapper.IDL.fmclasses.au.field_map[key] && !fieldmapper.IDL.fmclasses.stgu.field_map[key].virtual) {
+ if(data.user[key]() !== null)
+ patron[key]( data.user[key]() );
+ }
+ }
+
+ // copy the data into our new address objects
+ // TODO: uses the first mailing address only
+ if(data.mailing_addresses.length) {
+
+ var mail_addr = new fieldmapper.aua();
+ mail_addr.id(-1); // virtual ID
+ mail_addr.usr(-1);
+ mail_addr.isnew(1);
+ patron.mailing_address(mail_addr);
+ patron.addresses().push(mail_addr);
+
+ for(var key in fieldmapper.IDL.fmclasses.stgma.field_map) {
+ if(fieldmapper.IDL.fmclasses.aua.field_map[key] && !fieldmapper.IDL.fmclasses.stgma.field_map[key].virtual) {
+ if(data.mailing_addresses[0][key]() !== null)
+ mail_addr[key]( data.mailing_addresses[0][key]() );
+ }
+ }
+ }
+
+ // copy the data into our new address objects
+ // TODO uses the first billing address only
+ if(data.billing_addresses.length) {
+
+ var bill_addr = new fieldmapper.aua();
+ bill_addr.id(-2); // virtual ID
+ bill_addr.usr(-1);
+ bill_addr.isnew(1);
+ patron.billing_address(bill_addr);
+ patron.addresses().push(bill_addr);
+
+ for(var key in fieldmapper.IDL.fmclasses.stgba.field_map) {
+ if(fieldmapper.IDL.fmclasses.aua.field_map[key] && !fieldmapper.IDL.fmclasses.stgba.field_map[key].virtual) {
+ if(data.billing_addresses[0][key]() !== null)
+ bill_addr[key]( data.billing_addresses[0][key]() );
+ }
+ }
+ }
+
+ // TODO: uses the first card only
+ if(data.cards.length) {
+ var card = new fieldmapper.ac();
+ card.id(-1); // virtual ID
+ patron.card().barcode(data.cards[0].barcode());
+ }
+
+ return patron;
+}
+
/*
* clone the home org, phone numbers, and billing/mailing address
*/
@@ -763,6 +839,7 @@
newPatron = openils.Util.readResponse(r);
if(newPatron) {
uEditUpdateUserSettings(newPatron.id());
+ if(stageUser) uEditRemoveStage();
uEditFinishSave(newPatron, doClone);
}
}
@@ -770,6 +847,13 @@
);
}
+function uEditRemoveStage() {
+ var resp = fieldmapper.standardRequest(
+ ['open-ils.actor', 'open-ils.actor.user.stage.delete'],
+ { params : [openils.User.authtoken, stageUser.row_id()] }
+ )
+}
+
function uEditFinishSave(newPatron, doClone) {
if(doClone && cloneUser == null)
More information about the open-ils-commits
mailing list