[open-ils-commits] [GIT] Evergreen ILS branch rel_3_0 updated. 6fb9fc8659241a65405845b0dff0e7c4355dc56d

Evergreen Git git at git.evergreen-ils.org
Tue May 22 15:56:10 EDT 2018


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, rel_3_0 has been updated
       via  6fb9fc8659241a65405845b0dff0e7c4355dc56d (commit)
       via  d5e7320a9c1bde5838a4f244c3370d48df2f9346 (commit)
       via  ead1711400e1b161c53515e620e50ef3bf1d3404 (commit)
      from  3126271e138d694ffbd6b46983e0da9c7f47f09a (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 6fb9fc8659241a65405845b0dff0e7c4355dc56d
Author: Galen Charlton <gmc at equinoxinitiative.org>
Date:   Mon Apr 30 17:03:26 2018 -0400

    LP#14973322: (follow-up) allow profile-only patron searches
    
    This patch removes the implicit requirement introduced by the previous
    patch that a field other than profile be used in the patron search.
    
    For performance reasons, it might be good to mark permission.grp_descendants()
    as stable.
    
    Signed-off-by: Galen Charlton <gmc at equinoxinitiative.org>
    Signed-off-by: Jason Boyer <jboyer at library.in.gov>
    Signed-off-by: Mike Rylander <mrylander at gmail.com>

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 134821a..1cef88b 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
@@ -775,7 +775,13 @@ sub patron_search {
         $name = '(' . join(' OR ', @ns) . ')';
     }
 
-    my $usr_where = join ' AND ', grep { $_ } ($usr,$phone,$ident,$name);
+    my $profile = '';
+    my @profv = ();
+    if ($prof) {
+        $profile = '(profile IN (SELECT id FROM permission.grp_descendants(?)))';
+        push @profv, $prof;
+    }
+    my $usr_where = join ' AND ', grep { $_ } ($usr,$phone,$ident,$name,$profile);
     my $addr_where = $addr;
 
 
@@ -821,7 +827,6 @@ sub patron_search {
     }
 
     my $descendants = "actor.org_unit_descendants($search_org)";
-    my $profile = "JOIN permission.grp_descendants($prof) p ON (p.id = users.profile)" if $prof;
 
     my $opt_in_where = '';
     if (lc($strict_opt_in) eq 'true') {
@@ -849,7 +854,6 @@ sub patron_search {
         SELECT  $distinct_list
           FROM  $u_table AS users $card
             JOIN $descendants d ON (d.id = users.home_ou)
-            $profile
             $select
             $clone_select
             $penalty_join
@@ -862,7 +866,7 @@ sub patron_search {
           OFFSET $offset
     SQL
 
-    return actor::user->db_Main->selectcol_arrayref($select, {Columns=>[scalar(@$sort)]}, map {lc($_)} (@usrv, at phonev, at identv, at namev, at addrv));
+    return actor::user->db_Main->selectcol_arrayref($select, {Columns=>[scalar(@$sort)]}, map {lc($_)} (@usrv, at phonev, at identv, at namev, at profv, at addrv));
 }
 __PACKAGE__->register_method(
     api_name    => 'open-ils.storage.actor.user.crazy_search',

commit d5e7320a9c1bde5838a4f244c3370d48df2f9346
Author: Jason Boyer <jboyer at library.in.gov>
Date:   Fri Apr 20 14:49:25 2018 -0400

    LP14973322: Search for Users by Profile
    
    Stop treating profile like a text value, instead
    include users in the selected profiles and descendants.
    
    To test
    -------
    [0] Search for users by last name (and / or first) and do not
        select a profile, take note of results
    [1] Select the top of your permission group tree (Users, likely) and
        search again, results should be the same.
    [2] Select a group further down the tree (Circulators, Administrators,
        Patrons, etc.) and repeat the search, there should only be results
        from that group and its descendants.
    [3] Finally, select a group with no child groups. Results will only be
        that specific group.
    
    Signed-off-by: Jason Boyer <jboyer at library.in.gov>
    Signed-off-by: Terran McCanna <tmccanna at georgialibraries.org>
    Signed-off-by: Galen Charlton <gmc at equinoxinitiative.org>
    Signed-off-by: Mike Rylander <mrylander at gmail.com>

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 a1e634d..134821a 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
@@ -677,6 +677,7 @@ sub patron_search {
     # group 2 = phone, ident
     # group 3 = barcode
     # group 4 = dob
+    # group 5 = profile
 
     # Treatment of name fields depends on whether the org has 
     # diacritic_insensitivity turned on or off.
@@ -718,6 +719,10 @@ sub patron_search {
     my $addr = join ' AND ', map { "evergreen.lowercase(CAST($_ AS text)) ~ ?" } grep { ''.$$search{$_}{group} eq '1' } keys %$search;
     my @addrv = map { "^" . _clean_regex_chars($$search{$_}{value}) } grep { ''.$$search{$_}{group} eq '1' } keys %$search;
 
+    # should only be 1 profile sent but this construction makes dealing with the lists simpler.
+    my ($prof) = map { $$search{$_}{value} } grep {''.$$search{$_}{group} eq '5' } keys %$search;
+    $prof = int($prof) if $prof; # int or out
+
     my $pv = _clean_regex_chars($$search{phone}{value});
     my $iv = _clean_regex_chars($$search{ident}{value});
     my $nv = _clean_regex_chars($$search{name}{value});
@@ -816,6 +821,7 @@ sub patron_search {
     }
 
     my $descendants = "actor.org_unit_descendants($search_org)";
+    my $profile = "JOIN permission.grp_descendants($prof) p ON (p.id = users.profile)" if $prof;
 
     my $opt_in_where = '';
     if (lc($strict_opt_in) eq 'true') {
@@ -843,6 +849,7 @@ sub patron_search {
         SELECT  $distinct_list
           FROM  $u_table AS users $card
             JOIN $descendants d ON (d.id = users.home_ou)
+            $profile
             $select
             $clone_select
             $penalty_join
diff --git a/Open-ILS/web/js/ui/default/staff/services/patron_search.js b/Open-ILS/web/js/ui/default/staff/services/patron_search.js
index f19678f..b0f1bed 100644
--- a/Open-ILS/web/js/ui/default/staff/services/patron_search.js
+++ b/Open-ILS/web/js/ui/default/staff/services/patron_search.js
@@ -775,7 +775,7 @@ function($scope,  $q,  $routeParams,  $timeout,  $window,  $location,  egCore,
         angular.forEach(args, function(val, key) {
             if (!val) return;
             if (key == 'profile' && args.profile) {
-                search.profile = {value : args.profile.id(), group : 0};
+                search.profile = {value : args.profile.id(), group : 5};
             } else if (key == 'home_ou' && args.home_ou) {
                 search.home_ou = args.home_ou.id(); // passed separately
             } else if (key == 'inactive') {

commit ead1711400e1b161c53515e620e50ef3bf1d3404
Author: Galen Charlton <gmc at equinoxinitiative.org>
Date:   Mon Apr 30 16:14:52 2018 -0400

    LP#1497322: add Perl live_t regression and unit tests for patron searching
    
    Signed-off-by: Galen Charlton <gmc at equinoxinitiative.org>
    Signed-off-by: Mike Rylander <mrylander at gmail.com>

diff --git a/Open-ILS/src/perlmods/live_t/27-lp1497322-patron-search-by-profile.t b/Open-ILS/src/perlmods/live_t/27-lp1497322-patron-search-by-profile.t
new file mode 100644
index 0000000..b07fa5b
--- /dev/null
+++ b/Open-ILS/src/perlmods/live_t/27-lp1497322-patron-search-by-profile.t
@@ -0,0 +1,62 @@
+#!perl
+use strict; use warnings;
+
+use Test::More tests => 4;
+
+diag("Tests searching for patrons by profile");
+
+use DateTime;
+use OpenILS::Utils::TestUtils;
+my $script = OpenILS::Utils::TestUtils->new();
+our $apputils = 'OpenILS::Application::AppUtils';
+$script->bootstrap;
+
+$script->authenticate({
+    username => 'admin',
+    password => 'demo123',
+    type => 'staff'
+});
+
+ok($script->authtoken, 'Have an authtoken');
+
+my $results = $apputils->simplereq(
+    'open-ils.actor',
+    'open-ils.actor.patron.search.advanced.fleshed.atomic',
+    $script->authtoken,
+    {"family_name" => {"value" => "smith", "group" =>  0}},
+    10,
+    [],
+    undef,
+    1,
+    ["cards"]
+);
+
+cmp_ok(@$results, '>=', 1, 'Patron search on "Smith" returns at least one result');
+
+$results = $apputils->simplereq(
+    'open-ils.actor',
+    'open-ils.actor.patron.search.advanced.fleshed.atomic',
+    $script->authtoken,
+    {"profile" => {"value" => 3, "group" =>  0}},
+    10,
+    [],
+    undef,
+    1,
+    ["cards"]
+);
+
+cmp_ok(@$results, '==', 0, 'Patron search profile 3 (staff) in group 0 returns at zero results');
+
+$results = $apputils->simplereq(
+    'open-ils.actor',
+    'open-ils.actor.patron.search.advanced.fleshed.atomic',
+    $script->authtoken,
+    {"profile" => {"value" => 3, "group" =>  5}},
+    10,
+    [],
+    undef,
+    1,
+    ["cards"]
+);
+
+cmp_ok(@$results, '>=', 1, 'Patron search profile 3 (staff) in group 5 returns at least one result');

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

Summary of changes:
 .../OpenILS/Application/Storage/Publisher/actor.pm |   15 ++++-
 .../live_t/27-lp1497322-patron-search-by-profile.t |   62 ++++++++++++++++++++
 .../js/ui/default/staff/services/patron_search.js  |    2 +-
 3 files changed, 76 insertions(+), 3 deletions(-)
 create mode 100644 Open-ILS/src/perlmods/live_t/27-lp1497322-patron-search-by-profile.t


hooks/post-receive
-- 
Evergreen ILS


More information about the open-ils-commits mailing list