[open-ils-commits] [GIT] Evergreen ILS branch master updated. ba6ffe0fe4140cc6761f2a9fff65e38649b8925c

Evergreen Git git at git.evergreen-ils.org
Fri Jun 10 16:34:32 EDT 2011


This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "Evergreen ILS".

The branch, master has been updated
       via  ba6ffe0fe4140cc6761f2a9fff65e38649b8925c (commit)
       via  131d700ded4b50fe70bc86b81d588f4db07e4fe8 (commit)
      from  103056569ab01d7c7232643a5bcb5591178b58b7 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit ba6ffe0fe4140cc6761f2a9fff65e38649b8925c
Author: Jason Etheridge <jason at esilibrary.com>
Date:   Fri Jun 10 16:40:46 2011 -0400

    add the patron opt-in settings
    
    Signed-off-by: Jason Etheridge <jason at esilibrary.com>

diff --git a/Open-ILS/src/sql/Pg/002.schema.config.sql b/Open-ILS/src/sql/Pg/002.schema.config.sql
index 7b34e66..9b5bffb 100644
--- a/Open-ILS/src/sql/Pg/002.schema.config.sql
+++ b/Open-ILS/src/sql/Pg/002.schema.config.sql
@@ -86,7 +86,7 @@ CREATE TRIGGER no_overlapping_deps
     BEFORE INSERT OR UPDATE ON config.db_patch_dependencies
     FOR EACH ROW EXECUTE PROCEDURE evergreen.array_overlap_check ('deprecates');
 
-INSERT INTO config.upgrade_log (version, applied_to) VALUES ('0549', :eg_version); -- phasefx/berick
+INSERT INTO config.upgrade_log (version, applied_to) VALUES ('0550', :eg_version); -- phasefx/jamesrf
 
 CREATE TABLE config.bib_source (
 	id		SERIAL	PRIMARY KEY,
diff --git a/Open-ILS/src/sql/Pg/950.data.seed-values.sql b/Open-ILS/src/sql/Pg/950.data.seed-values.sql
index e07160a..35651d2 100644
--- a/Open-ILS/src/sql/Pg/950.data.seed-values.sql
+++ b/Open-ILS/src/sql/Pg/950.data.seed-values.sql
@@ -2730,7 +2730,19 @@ INSERT into config.org_unit_setting_type
 ( 'opac.fully_compressed_serial_holdings',
     oils_i18n_gettext('opac.fully_compressed_serial_holdings', 'OPAC: Use fully compressed serial holdings', 'coust', 'label'),
     oils_i18n_gettext('opac.fully_compressed_serial_holdings', 'Show fully compressed serial holdings for all libraries at and below the current context unit', 'coust', 'description'),
-    'bool')
+    'bool'),
+
+( 'org.patron_opt_boundary',
+    oils_i18n_gettext( 'org.patron_opt_boundary', 'Circ: Patron Opt-In Boundary', 'coust', 'label'),
+    oils_i18n_gettext( 'org.patron_opt_boundary', 'This determines at which depth above which patrons must be opted in, and below which patrons will be assumed to be opted in.', 'coust', 'label'),
+    'integer'),
+
+( 'org.patron_opt_default',
+    oils_i18n_gettext( 'org.patron_opt_default', 'Circ: Patron Opt-In Default', 'coust', 'label'),
+    oils_i18n_gettext( 'org.patron_opt_default', 'This is the default depth at which a patron is opted in; it is calculated as an org unit relative to the current workstation.', 'coust', 'label'),
+    'integer');
+
+COMMIT;
 ;
 
 UPDATE config.org_unit_setting_type
diff --git a/Open-ILS/src/sql/Pg/upgrade/0550.data.patron_opt_in_settings.sql b/Open-ILS/src/sql/Pg/upgrade/0550.data.patron_opt_in_settings.sql
new file mode 100644
index 0000000..58a4169
--- /dev/null
+++ b/Open-ILS/src/sql/Pg/upgrade/0550.data.patron_opt_in_settings.sql
@@ -0,0 +1,40 @@
+BEGIN;
+
+-- check whether patch can be applied
+SELECT evergreen.upgrade_deps_block_check('0550', :eg_version);
+
+INSERT INTO config.org_unit_setting_type ( name, label, description, datatype ) VALUES (
+    'org.patron_opt_boundary',
+    oils_i18n_gettext( 
+        'org.patron_opt_boundary',
+        'Circ: Patron Opt-In Boundary',
+        'coust',
+        'label'
+    ),
+    oils_i18n_gettext( 
+        'org.patron_opt_boundary',
+        'This determines at which depth above which patrons must be opted in, and below which patrons will be assumed to be opted in.',
+        'coust',
+        'label'
+    ),
+    'integer'
+);
+
+INSERT INTO config.org_unit_setting_type ( name, label, description, datatype ) VALUES (
+    'org.patron_opt_default',
+    oils_i18n_gettext( 
+        'org.patron_opt_default',
+        'Circ: Patron Opt-In Default',
+        'coust',
+        'label'
+    ),
+    oils_i18n_gettext( 
+        'org.patron_opt_default',
+        'This is the default depth at which a patron is opted in; it is calculated as an org unit relative to the current workstation.',
+        'coust',
+        'label'
+    ),
+    'integer'
+);
+
+COMMIT;

commit 131d700ded4b50fe70bc86b81d588f4db07e4fe8
Author: Jason Etheridge <jason at esilibrary.com>
Date:   Tue Mar 29 11:31:58 2011 -0400

    patch from James Fournie re: https://bugs.launchpad.net/evergreen/+bug/510959 for improved patron opt-in
    
    Signed-off-by: Jason Etheridge <jason at esilibrary.com>

diff --git a/Open-ILS/src/perlmods/lib/OpenILS/Application/Actor.pm b/Open-ILS/src/perlmods/lib/OpenILS/Application/Actor.pm
index 8d6659e..5e704b4 100644
--- a/Open-ILS/src/perlmods/lib/OpenILS/Application/Actor.pm
+++ b/Open-ILS/src/perlmods/lib/OpenILS/Application/Actor.pm
@@ -1222,14 +1222,19 @@ __PACKAGE__->register_method(
 );
 sub patron_adv_search {
 	my( $self, $client, $auth, $search_hash, 
-        $search_limit, $search_sort, $include_inactive, $search_depth ) = @_;
+        $search_limit, $search_sort, $include_inactive, $search_ou ) = @_;
 
 	my $e = new_editor(authtoken=>$auth);
 	return $e->event unless $e->checkauth;
 	return $e->event unless $e->allowed('VIEW_USER');
+
+	# depth boundary outside of which patrons must opt-in, default to 0
+	my $opt_boundary = 0;
+	$opt_boundary = $U->ou_ancestor_setting_value($e->requestor->ws_ou,'org.patron_opt_boundary') if user_opt_in_enabled($self);
+
 	return $U->storagereq(
 		"open-ils.storage.actor.user.crazy_search", $search_hash, 
-            $search_limit, $search_sort, $include_inactive, $e->requestor->ws_ou, $search_depth);
+            $search_limit, $search_sort, $include_inactive, $e->requestor->ws_ou, $search_ou, $opt_boundary);
 }
 
 
@@ -2988,16 +2993,24 @@ sub user_opt_in_at_org {
 
 	my $e = new_editor(authtoken => $auth);
 	return $e->event unless $e->checkauth;
-    my $org_id = $e->requestor->ws_ou;
 
     my $user = $e->retrieve_actor_user($user_id) or return $e->event;
 	return $e->event unless $e->allowed('VIEW_USER', $user->home_ou);
 
-    # user is automatically opted-in at the home org
-    return 1 if $user->home_ou eq $org_id;
+    my $ws_org = $e->requestor->ws_ou;
+    # user is automatically opted-in if they are from the local org
+    return 1 if $user->home_ou eq $ws_org;
+
+    # get the boundary setting
+    my $opt_boundary = $U->ou_ancestor_setting_value($e->requestor->ws_ou,'org.patron_opt_boundary');
+ 
+    # auto opt in if user falls within the opt boundary
+    my $opt_orgs = $U->get_org_descendants($ws_org, $opt_boundary);
+
+    return 1 if grep $_ eq $user->home_ou, @$opt_orgs;
 
     my $vals = $e->search_actor_usr_org_unit_opt_in(
-        {org_unit=>$org_id, usr=>$user_id},{idlist=>1});
+        {org_unit=>$opt_orgs, usr=>$user_id},{idlist=>1});
 
     return 1 if @$vals;
     return 0;
@@ -3013,11 +3026,22 @@ __PACKAGE__->register_method(
 );
 
 sub create_user_opt_in_at_org {
-    my($self, $conn, $auth, $user_id) = @_;
+    my($self, $conn, $auth, $user_id, $org_id) = @_;
 
 	my $e = new_editor(authtoken => $auth, xact=>1);
 	return $e->die_event unless $e->checkauth;
-    my $org_id = $e->requestor->ws_ou;
+   
+    # if a specific org unit wasn't passed in, get one based on the defaults;
+    if(!$org_id){
+        my $wsou = $e->requestor->ws_ou;
+        # get the default opt depth
+        my $opt_depth = $U->ou_ancestor_setting_value($wsou,'org.patron_opt_default'); 
+        # get the org unit at that depth
+        my $org = $e->json_query({ 
+            from => [ 'actor.org_unit_ancestor_at_depth', $wsou, $opt_depth ]})->[0];
+
+	$org_id = $org->{id};
+    }
 
     my $user = $e->retrieve_actor_user($user_id) or return $e->die_event;
 	return $e->die_event unless $e->allowed('UPDATE_USER', $user->home_ou);
diff --git a/Open-ILS/src/perlmods/lib/OpenILS/Application/Storage/Publisher/actor.pm b/Open-ILS/src/perlmods/lib/OpenILS/Application/Storage/Publisher/actor.pm
index 1cb3dce..c638e1c 100644
--- a/Open-ILS/src/perlmods/lib/OpenILS/Application/Storage/Publisher/actor.pm
+++ b/Open-ILS/src/perlmods/lib/OpenILS/Application/Storage/Publisher/actor.pm
@@ -639,7 +639,8 @@ sub patron_search {
 	my $sort = shift;
 	my $inactive = shift;
 	my $ws_ou = shift;
-	my $ws_ou_depth = shift || 0;
+	my $search_org = shift || $ws_ou;
+	my $opt_boundary = shift || 0;
 
     my $penalty_sort = 0;
 
@@ -757,11 +758,16 @@ sub patron_search {
 		$ws_ou = actor::org_unit->search( { parent_ou => undef } )->next->id;
 	}
 
-	my $opt_in_join = '';
+	my $descendants = "actor.org_unit_descendants($search_org)";
+
 	my $opt_in_where = '';
 	if (lc($strict_opt_in) eq 'true') {
-		$opt_in_join = "LEFT JOIN $opt_in_table oi ON (oi.org_unit = $ws_ou AND users.id = oi.usr)";
-		$opt_in_where = "AND (oi.id IS NOT NULL OR users.home_ou = $ws_ou)";
+		$opt_in_where = "AND (";
+		$opt_in_where .= "EXISTS (select id FROM $opt_in_table ";
+		$opt_in_where .= " WHERE org_unit in (select (actor.org_unit_ancestors($ws_ou)).id)";
+		$opt_in_where .= " AND usr = users.id) ";
+		$opt_in_where .= "OR";
+		$opt_in_where .= " users.home_ou IN (select (actor.org_unit_descendants($ws_ou,$opt_boundary)).id))";
 	}
 
 	my $penalty_join = '';
@@ -775,15 +781,12 @@ sub patron_search {
         SQL
     }
 
-	my $descendants = "actor.org_unit_descendants($ws_ou, $ws_ou_depth)";
-
 	$select = "JOIN ($select) AS search ON (search.id = users.id)" if ($select);
 	$select = <<"	SQL";
 		SELECT	$distinct_list
 		  FROM	$u_table AS users $card
 			JOIN $descendants d ON (d.id = users.home_ou)
 			$select
-			$opt_in_join
 			$clone_select
             $penalty_join
 		  WHERE	users.deleted = FALSE
diff --git a/Open-ILS/xul/staff_client/server/patron/search_form.js b/Open-ILS/xul/staff_client/server/patron/search_form.js
index 923fd62..7f58952 100644
--- a/Open-ILS/xul/staff_client/server/patron/search_form.js
+++ b/Open-ILS/xul/staff_client/server/patron/search_form.js
@@ -261,9 +261,9 @@ patron.search_form.prototype = {
         JSAN.use('util.file'); JSAN.use('util.widgets'); JSAN.use('util.functional');
         util.widgets.remove_children(obj.controller.view.search_depth);
         var ml = util.widgets.make_menulist(
-            util.functional.map_list( obj.OpenILS.data.list.aout, 
+            util.functional.map_list( obj.OpenILS.data.list.my_aou,
                 function(el,idx) {
-                    return [ el.opac_label(), el.depth() ]
+                    return [ el.name(), el.id() ]
                 }
             ).sort(
                 function(a,b) {

-----------------------------------------------------------------------

Summary of changes:
 .../src/perlmods/lib/OpenILS/Application/Actor.pm  |   40 ++++++++++++++++----
 .../OpenILS/Application/Storage/Publisher/actor.pm |   17 +++++---
 Open-ILS/src/sql/Pg/002.schema.config.sql          |    2 +-
 Open-ILS/src/sql/Pg/950.data.seed-values.sql       |   14 ++++++-
 .../upgrade/0550.data.patron_opt_in_settings.sql   |   40 ++++++++++++++++++++
 .../xul/staff_client/server/patron/search_form.js  |    4 +-
 6 files changed, 98 insertions(+), 19 deletions(-)
 create mode 100644 Open-ILS/src/sql/Pg/upgrade/0550.data.patron_opt_in_settings.sql


hooks/post-receive
-- 
Evergreen ILS


More information about the open-ils-commits mailing list