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

Evergreen Git git at git.evergreen-ils.org
Thu Dec 29 11:05:09 EST 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  ea71899306e026bd0c9c91180a0af76a55fbec08 (commit)
       via  67a2606376232fec9d2803a30f146f4176695402 (commit)
       via  611b4b1ab4b586a815bb4035bf141438c5939b46 (commit)
       via  c3583b4788574ad6b940f447b69c303c1c7810f0 (commit)
       via  d04e4cea8ffbd0e9e9ab5bb11fa6e4b60c3443c5 (commit)
      from  f49146ec6b6c0e54056a911a0f21e2d5c80a38b5 (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 ea71899306e026bd0c9c91180a0af76a55fbec08
Author: Dan Scott <dan at coffeecode.net>
Date:   Tue Dec 27 12:31:03 2011 -0500

    TPAC: Uniform search lib / depth settings
    
    The current TPAC code uses logic embedded within the templates to
    determine which org unit and depth to apply to searches.
    
    This commit attempts to standardize the logic within the new
    OpenILS::WWWW::EGCatLoader::Util::_get_search_lib() function and sets
    the result as a new context variable, "search_ou". The org unit is
    determined as follows (first matching condition wins):
    
    * specific CGI "loc" value
    * logged-in user's preferred search library
    * logged-in user's home org unit
    * specific CGI "physical_loc" value
    
    The depth is set as follows (first matching condition wins):
    
    * specific CGI "depth" value
    * depth of the chosen org_unit
    
    As of this commit, a library that wishes to set the a default search
    org unit for any given user should set the "physical_loc" CGI param;
    after the user performs their first search, the "loc" CGI param will
    propagate through most interfaces. When a user clicks "Your account log
    in", the user's preferred search library or home org unit will be set as
    the new search lib.
    
    At any time after that, the user can select a different org unit from
    the org unit selector to explicitly set the "loc" CGI param.
    
    Signed-off-by: Dan Scott <dan at coffeecode.net>
    Signed-off-by: Jason Stephenson <jstephenson at mvlc.org>

diff --git a/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Search.pm b/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Search.pm
index 6e74628..7fa671d 100644
--- a/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Search.pm
+++ b/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Search.pm
@@ -124,6 +124,8 @@ sub _prepare_biblio_search {
             $depth = $org->ou_type->depth;
         }
         $query .= " depth($depth)";
+    } else {
+        $depth = $ctx->{get_aou}->($org)->ou_type->depth;
     }
 
     $logger->info("tpac: site=$site, depth=$depth, query=$query");

commit 67a2606376232fec9d2803a30f146f4176695402
Author: Dan Scott <dan at coffeecode.net>
Date:   Wed Dec 28 18:42:18 2011 -0500

    TPAC: Add "preferred search location" preference setting
    
    Working towards parity with the JSPAC, give the user the ability to set
    their preferred search library in account preferences via the org
    selector. The value defaults to the user's home OU.
    
    Also set a sane default of 10 search results per page in the absence of
    any preference, as the default had been set to 5.
    
    While we're in there, remove some of the inline styles and weird markup
    in the user preference page, and refactor the O:W:EGCatLoader:Account
    module to accept an easily-appended list of preferences to be set.
    
    Signed-off-by: Dan Scott <dan at coffeecode.net>
    Signed-off-by: Jason Stephenson <jstephenson at mvlc.org>

diff --git a/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Account.pm b/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Account.pm
index 526fbfa..116f8c5 100644
--- a/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Account.pm
+++ b/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Account.pm
@@ -297,6 +297,11 @@ sub _prepare_anonlist_sorting_query {
 sub load_myopac_prefs_settings {
     my $self = shift;
 
+    my @user_prefs = qw/
+        opac.hits_per_page
+        opac.default_search_location
+    /;
+
     my $stat = $self->_load_user_with_prefs;
     return $stat if $stat;
 
@@ -310,13 +315,14 @@ sub load_myopac_prefs_settings {
     my %settings;
     my $set_map = $self->ctx->{user_setting_map};
 
-    my $key = 'opac.hits_per_page';
-    my $val = $self->cgi->param($key);
-    $settings{$key}= $val unless $$set_map{$key} eq $val;
+    foreach my $key (@user_prefs) {
+        my $val = $self->cgi->param($key);
+        $settings{$key}= $val unless $$set_map{$key} eq $val;
+    }
 
     my $now = DateTime->now->strftime('%F');
-    for $key (qw/history.circ.retention_start history.hold.retention_start/) {
-        $val = $self->cgi->param($key);
+    foreach my $key (qw/history.circ.retention_start history.hold.retention_start/) {
+        my $val = $self->cgi->param($key);
         if($val and $val eq 'on') {
             # Set the start time to 'now' unless a start time already exists for the user
             $settings{$key} = $now unless $$set_map{$key};
diff --git a/Open-ILS/src/templates/opac/myopac/prefs_settings.tt2 b/Open-ILS/src/templates/opac/myopac/prefs_settings.tt2
index 0a117bb..7cb3103 100644
--- a/Open-ILS/src/templates/opac/myopac/prefs_settings.tt2
+++ b/Open-ILS/src/templates/opac/myopac/prefs_settings.tt2
@@ -1,4 +1,5 @@
 [%  PROCESS "opac/parts/header.tt2";
+    PROCESS "opac/parts/org_selector.tt2";
     WRAPPER "opac/parts/myopac/prefs_base.tt2";
     myopac_page = "prefs_notify";
     prefs_page = 'settings' %]
@@ -6,15 +7,7 @@
 
     <form method='POST'>
 
-        <div style="float:right;width:65px;">
-            <div style="position:absolute">
-                <div style="position:relative;top:75px;">
-                    <input type="submit" value="[% l('Save') %]" alt="[% l('Save') %]" class="opac-button"/>
-                </div>
-            </div>
-        </div>
-
-        <table class="full-width data_grid" id="acct_search_main">
+       <table class="full-width data_grid" id="acct_search_main">
             <tbody>
 
                 [% IF ctx.updated_user_settings %]
@@ -28,20 +21,32 @@
                 <tr >
                     <td width='20%'>[% l("Search hits per page") %]</td>
                     <td>
-                        <div style="position:absolute">
-                            <div style="position:relative;top:0px;left:55px;">
-                                <a href="#"><img alt="[% l('Search Hits Help') %]" 
-                                    src="[% ctx.media_prefix %]/images/question-mark.png" /></a>
-                            </div>
-                        </div>
                         [% setting = 'opac.hits_per_page' %]
                         <select name='[% setting %]'>
-                            [%  FOR val IN [5, 8, 10, 15, 20, 25, 50] %]
+                            [%  UNLESS ctx.user_setting_map.$setting;
+                                    ctx.user_setting_map.$setting = 10;
+                                END;
+                                FOR val IN [5, 8, 10, 15, 20, 25, 50] %]
                                 <option value='[% val | uri %]' 
                                     [% IF ctx.user_setting_map.$setting == val %]
                                         selected='selected'[% END %]>[% val | html %]</option>
                             [% END %]
                         </select>
+                        <a href="#"><img alt="[% l('Search Hits Help') %]" 
+                            src="[% ctx.media_prefix %]/images/question-mark.png"
+                        /></a>
+                    </td>
+                </tr>
+                <tr >
+                    <td width='20%'>[% l("Preferred search location") %]</td>
+                    <td>
+                        [%- setting = 'opac.default_search_location';
+                            thang = ctx.user.home_ou.id;
+                            IF ctx.user_setting_map.$setting;
+                                thang = ctx.user_setting_map.$setting;
+                            END;
+                            PROCESS build_org_selector name=setting value=thang;
+                        %]
                     </td>
                 </tr>
                 <tr>
@@ -71,30 +76,11 @@
                         </select>
                     </td>
                 </tr>
-
-                <tr>
-                    <td>[% l("Default Search Location") %]</td>
-                    <td>
-                        <div style='margin-bottom: 5px;'>
-                            <input type='checkbox' id='myopac_pref_home_lib' />
-                            [% l("Search my home library by default.") %]
-                        </div>
-                        <select id='prefs_def_location'></select>
-                    </td>
-                </tr>
-
-                <tr>
-                    <td>[% l("Default Search Range") %]</td>
-                    <td>
-                        <select>
-                            [%# TODO %]
-                        </select>
-                    </td>
-                </tr>
                 -->
 
             </tbody>
         </table>
+        <input type="submit" value="[% l('Save') %]" alt="[% l('Save') %]" class="opac-button"/>
     </form>
     [% INCLUDE "opac/parts/myopac/prefs_hints.tt2" %]
 [% END %]

commit 611b4b1ab4b586a815bb4035bf141438c5939b46
Author: Dan Scott <dan at coffeecode.net>
Date:   Tue Dec 27 21:17:02 2011 -0500

    TPAC: Set search_ou context in common loader
    
    By setting the search_ou context in load_common() after checking for a
    valid user session, we can catch the remaining pages in TPAC in which
    the default search library was not being set properly.
    
    Signed-off-by: Dan Scott <dan at coffeecode.net>
    Signed-off-by: Jason Stephenson <jstephenson at mvlc.org>

diff --git a/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader.pm b/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader.pm
index 59a2cb1..5091c50 100644
--- a/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader.pm
+++ b/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader.pm
@@ -243,6 +243,7 @@ sub load_common {
             return $self->load_logout($self->apache->unparsed_uri);
         }
     }
+    $ctx->{search_ou} = $self->_get_search_lib();
 
     $self->staff_saved_searches_set_expansion_state if $ctx->{is_staff};
 

commit c3583b4788574ad6b940f447b69c303c1c7810f0
Author: Dan Scott <dan at coffeecode.net>
Date:   Tue Dec 27 18:36:32 2011 -0500

    TPAC: Resolve conflict with master
    
    The changes for LP909111 ended up causing a conflict with this branch.
    Resolve!
    
    Signed-off-by: Dan Scott <dan at coffeecode.net>
    Signed-off-by: Jason Stephenson <jstephenson at mvlc.org>

diff --git a/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Search.pm b/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Search.pm
index 7fa671d..6e74628 100644
--- a/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Search.pm
+++ b/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Search.pm
@@ -124,8 +124,6 @@ sub _prepare_biblio_search {
             $depth = $org->ou_type->depth;
         }
         $query .= " depth($depth)";
-    } else {
-        $depth = $ctx->{get_aou}->($org)->ou_type->depth;
     }
 
     $logger->info("tpac: site=$site, depth=$depth, query=$query");

commit d04e4cea8ffbd0e9e9ab5bb11fa6e4b60c3443c5
Author: Dan Scott <dan at coffeecode.net>
Date:   Tue Dec 27 12:31:03 2011 -0500

    TPAC: Uniform search lib / depth settings
    
    The current TPAC code uses logic embedded within the templates to
    determine which org unit and depth to apply to searches.
    
    This commit attempts to standardize the logic within the new
    OpenILS::WWWW::EGCatLoader::Util::_get_search_lib() function and sets
    the result as a new context variable, "search_ou". The org unit is
    determined as follows (first matching condition wins):
    
    * specific CGI "loc" value
    * logged-in user's preferred search library
    * logged-in user's home org unit
    * specific CGI "physical_loc" value
    
    The depth is set as follows (first matching condition wins):
    
    * specific CGI "depth" value
    * depth of the chosen org_unit
    
    As of this commit, a library that wishes to set the a default search
    org unit for any given user should set the "physical_loc" CGI param;
    after the user performs their first search, the "loc" CGI param will
    propagate through most interfaces. When a user clicks "Your account log
    in", the user's preferred search library or home org unit will be set as
    the new search lib.
    
    At any time after that, the user can select a different org unit from
    the org unit selector to explicitly set the "loc" CGI param.
    
    Signed-off-by: Dan Scott <dan at coffeecode.net>
    Signed-off-by: Jason Stephenson <jstephenson at mvlc.org>

diff --git a/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader.pm b/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader.pm
index 3c10db7..59a2cb1 100644
--- a/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader.pm
+++ b/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader.pm
@@ -183,6 +183,7 @@ sub redirect_auth {
 sub load_simple {
     my ($self, $page) = @_;
     $self->ctx->{page} = $page;
+    $self->ctx->{search_ou} = $self->_get_search_lib();
 
     if (my $patron_barcode = $self->cgi->param("patron_barcode")) {
         # Special CGI variable from staff client; propagate henceforth as cookie
diff --git a/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Account.pm b/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Account.pm
index 30d2cba..526fbfa 100644
--- a/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Account.pm
+++ b/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Account.pm
@@ -1239,6 +1239,7 @@ sub load_myopac_main {
     my $self = shift;
     my $limit = $self->cgi->param('limit') || 0;
     my $offset = $self->cgi->param('offset') || 0;
+    $self->ctx->{search_ou} = $self->_get_search_lib();
 
     return $self->prepare_fines($limit, $offset) || Apache2::Const::OK;
 }
diff --git a/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Record.pm b/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Record.pm
index 97a6fa5..3d1d6c8 100644
--- a/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Record.pm
+++ b/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Record.pm
@@ -14,8 +14,8 @@ sub load_record {
     my $ctx = $self->ctx;
     $ctx->{page} = 'record';  
 
-    my $org = $self->cgi->param('loc') || $ctx->{aou_tree}->()->id;
-    my $depth = $self->cgi->param('depth') || 0;
+    my $org = $self->_get_search_lib();
+    my $depth = $self->cgi->param('depth') || $ctx->{get_aou}->($org)->ou_type->depth;
     my $copy_limit = int($self->cgi->param('copy_limit') || 10);
     my $copy_offset = int($self->cgi->param('copy_offset') || 0);
 
diff --git a/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Search.pm b/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Search.pm
index 77cfb38..7fa671d 100644
--- a/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Search.pm
+++ b/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Search.pm
@@ -97,7 +97,7 @@ sub _prepare_biblio_search {
     }
 
     my $site;
-    my $org = $cgi->param('loc');
+    my $org = $ctx->{search_ou};
     if (defined($org) and $org ne '' and ($org ne $ctx->{aou_tree}->()->id) and not $query =~ /site\(\S+\)/) {
         $site = $ctx->{get_aou}->($org)->shortname;
         $query .= " site($site)";
@@ -124,6 +124,8 @@ sub _prepare_biblio_search {
             $depth = $org->ou_type->depth;
         }
         $query .= " depth($depth)";
+    } else {
+        $depth = $ctx->{get_aou}->($org)->ou_type->depth;
     }
 
     $logger->info("tpac: site=$site, depth=$depth, query=$query");
@@ -204,7 +206,7 @@ sub load_rresults {
     my $page = $cgi->param('page') || 0;
     my @facets = $cgi->param('facet');
     my $limit = $self->_get_search_limit;
-    my $loc = $cgi->param('loc') || $ctx->{aou_tree}->()->id;
+    $ctx->{search_ou} = $self->_get_search_lib();
     my $offset = $page * $limit;
     my $metarecord = $cgi->param('metarecord');
     my $results; 
@@ -244,7 +246,7 @@ sub load_rresults {
         $results = $U->simplereq(
             'open-ils.search', 
             'open-ils.search.biblio.metarecord_to_records',
-            $metarecord, {org => $loc, depth => $depth}
+            $metarecord, {org => $ctx->{search_ou}, depth => $depth}
         );
 
         # force the metarecord result blob to match the format of regular search results
@@ -348,10 +350,7 @@ sub check_1hit_redirect {
 
     } else {
         $sname = 'opac.patron.jump_to_details_on_single_hit';
-        $org = ($ctx->{user}) ? 
-            $ctx->{user}->home_ou : 
-            $ctx->{physical_loc} || 
-            $self->ctx->{aou_tree}->()->id;
+        $org = $self->_get_search_lib();
     }
 
     return undef unless 
@@ -451,7 +450,7 @@ sub marc_expert_search {
     # loc, limit and offset
     my $page = $self->cgi->param("page") || 0;
     my $limit = $self->_get_search_limit;
-    my $org_unit = $self->cgi->param("loc") || $self->ctx->{aou_tree}->()->id;
+    $self->ctx->{search_ou} = $self->_get_search_lib();
     my $offset = $page * $limit;
 
     $self->ctx->{records} = [];
@@ -473,7 +472,7 @@ sub marc_expert_search {
     my $ses = OpenSRF::AppSession->create('open-ils.search');
     my $req = $ses->request(
         'open-ils.search.biblio.marc',
-        {searches => $query, org_unit => $org_unit}, 
+        {searches => $query, org_unit => $self->ctx->{search_ou}}, 
         $limit, $offset, $timeout);
 
     my $resp = $req->recv($timeout);
diff --git a/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Util.pm b/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Util.pm
index 92cea97..5ea922f 100644
--- a/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Util.pm
+++ b/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Util.pm
@@ -276,4 +276,30 @@ sub fetch_marc_xml_by_id {
     return $marc_xml;
 }
 
+sub _get_search_lib {
+    my $self = shift;
+
+    # loc param takes precedence
+    my $loc = $self->cgi->param('loc');
+    return $loc if $loc;
+
+    if ($self->ctx->{user}) {
+        # See if the user has a search library preference
+        my $lset = $self->editor->search_actor_user_setting({
+            usr => $self->ctx->{user}->id, 
+            name => 'opac.default_search_location'
+        })->[0];
+        return OpenSRF::Utils::JSON->JSON2perl($lset->value) if $lset;
+
+        # Otherwise return the user's home library
+        return $self->ctx->{user}->home_ou;
+    }
+
+    if ($self->cgi->param('physical_loc')) {
+        return $self->cgi->param('physical_loc');
+    }
+
+    return $self->ctx->{aou_tree}->()->id;
+}
+
 1;
diff --git a/Open-ILS/src/templates/opac/parts/advanced/search.tt2 b/Open-ILS/src/templates/opac/parts/advanced/search.tt2
index 378b9f6..f14aaa8 100644
--- a/Open-ILS/src/templates/opac/parts/advanced/search.tt2
+++ b/Open-ILS/src/templates/opac/parts/advanced/search.tt2
@@ -67,7 +67,7 @@
                         <td valign='top'>
                             <strong>[% l("Search Library") %]</strong><br />
                             [% PROCESS "opac/parts/org_selector.tt2";
-                                PROCESS build_org_selector name='loc' value=CGI.param('loc') %]
+                                PROCESS build_org_selector name='loc' value=ctx.search_ou %]
                             <div style="position:relative;top:7px;">
                                 <input type='checkbox' name="modifier"
                                     value="available"[% CGI.param('modifier').grep('available').size ? ' checked="checked"' : '' %]
diff --git a/Open-ILS/src/templates/opac/parts/searchbar.tt2 b/Open-ILS/src/templates/opac/parts/searchbar.tt2
index 907a0e7..43a9c85 100644
--- a/Open-ILS/src/templates/opac/parts/searchbar.tt2
+++ b/Open-ILS/src/templates/opac/parts/searchbar.tt2
@@ -21,7 +21,7 @@
                 x-webkit-speech />
         </span>
         [%- INCLUDE "opac/parts/qtype_selector.tt2";
-            l(' in '); PROCESS build_org_selector name='loc' value=CGI.param('loc');
+            l(' in '); PROCESS build_org_selector name='loc' value=ctx.search_ou;
     %]
     <span>
         <input id='search-submit-go' type="submit" value="[% l('Search') %]" alt="[% l('Search') %]" class="opac-button"

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

Summary of changes:
 .../src/perlmods/lib/OpenILS/WWW/EGCatLoader.pm    |    2 +
 .../lib/OpenILS/WWW/EGCatLoader/Account.pm         |   17 ++++--
 .../perlmods/lib/OpenILS/WWW/EGCatLoader/Record.pm |    4 +-
 .../perlmods/lib/OpenILS/WWW/EGCatLoader/Search.pm |   17 +++---
 .../perlmods/lib/OpenILS/WWW/EGCatLoader/Util.pm   |   26 +++++++++
 .../src/templates/opac/myopac/prefs_settings.tt2   |   58 ++++++++------------
 .../src/templates/opac/parts/advanced/search.tt2   |    2 +-
 Open-ILS/src/templates/opac/parts/searchbar.tt2    |    2 +-
 8 files changed, 74 insertions(+), 54 deletions(-)


hooks/post-receive
-- 
Evergreen ILS


More information about the open-ils-commits mailing list