From 746d460939c3afbf48ac95554d545e96f3279022 Mon Sep 17 00:00:00 2001 From: Jane Sandberg Date: Thu, 3 Sep 2020 09:00:18 -0700 Subject: [PATCH] LP1849212: OPAC course browse, search, display improvements Signed-off-by: Jane Sandberg Signed-off-by: Michele Morgan Signed-off-by: Galen Charlton --- Open-ILS/examples/fm_IDL.xml | 1 + .../perlmods/lib/OpenILS/Application/Courses.pm | 52 +++++++--------------- .../perlmods/lib/OpenILS/WWW/EGCatLoader/Course.pm | 13 ++---- Open-ILS/src/templates/opac/course/results.tt2 | 2 +- Open-ILS/src/templates/opac/parts/course/body.tt2 | 2 +- 5 files changed, 23 insertions(+), 47 deletions(-) diff --git a/Open-ILS/examples/fm_IDL.xml b/Open-ILS/examples/fm_IDL.xml index 3dc33be718..11dcf07d36 100644 --- a/Open-ILS/examples/fm_IDL.xml +++ b/Open-ILS/examples/fm_IDL.xml @@ -3910,6 +3910,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA + diff --git a/Open-ILS/src/perlmods/lib/OpenILS/Application/Courses.pm b/Open-ILS/src/perlmods/lib/OpenILS/Application/Courses.pm index a68ce6b7fe..577807a83b 100644 --- a/Open-ILS/src/perlmods/lib/OpenILS/Application/Courses.pm +++ b/Open-ILS/src/perlmods/lib/OpenILS/Application/Courses.pm @@ -186,43 +186,23 @@ __PACKAGE__->register_method( sub fetch_course_users { my ($self, $conn, $course_id) = @_; my $e = new_editor(); - my $filter = {}; - my $users = {}; - my %patrons; - $filter->{course} = $course_id; - $filter->{usr_role}->{is_public} = 't' - unless ($self->api_name =~ /\.staff/) and $e->allowed('MANAGE_RESERVES'); - - - $users->{list} = $e->search_asset_course_module_course_users($filter, {flesh => 1, flesh_fields => {acmcu => ['usr_role']}, order_by => {acmcu => 'id'}}); - for my $course_user (@{$users->{list}}) { - my $patron = {}; - $patron->{id} = $course_user->id; - $patron->{usr_role} = $course_user->usr_role; - $patron->{patron_data} = $e->retrieve_actor_user($course_user->usr); - $patrons{$course_user->usr} = $patron; - } - - my $targets = (); - for my $user (values %patrons) { - my $final_user = {}; - $final_user->{id} = $user->{id}; - $final_user->{usr_role} = $user->{usr_role}; - $final_user->{patron_id} = $user->{patron_data}->id; - $final_user->{first_given_name} = $user->{patron_data}->first_given_name; - $final_user->{second_given_name} = $user->{patron_data}->second_given_name; - $final_user->{family_name} = $user->{patron_data}->family_name; - $final_user->{pref_first_given_name} = $user->{patron_data}->pref_first_given_name; - $final_user->{pref_family_name} = $user->{patron_data}->pref_family_name; - $final_user->{pref_second_given_name} = $user->{patron_data}->pref_second_given_name; - $final_user->{pref_suffix} = $user->{patron_data}->pref_suffix; - $final_user->{pref_prefix} = $user->{patron_data}->pref_prefix; - - push @$targets, $final_user; - } - - return $targets; + return $e->json_query({ + select => { + acmcu => ['id'], + acmr => [{column => 'name', alias => 'usr_role'}], + au => [{column => 'id', alias => 'patron_id'}, + 'first_given_name', 'second_given_name', + 'family_name', 'pref_first_given_name', + 'pref_second_given_name', 'pref_family_name', + 'pref_suffix', 'pref_prefix'], + }, + from => { acmcu => {'acmr' => {}, 'au' => {}} }, + where => { + '+acmcu' => { course => $course_id }, + '+acmr' => {'is_public' => 't'} + }, + }); } diff --git a/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Course.pm b/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Course.pm index 88c35aac32..46c4521056 100644 --- a/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Course.pm +++ b/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Course.pm @@ -66,7 +66,7 @@ sub load_course_browse { 'usr', ]}, # TODO: We need to support the chosen library as well... - "where" => {'usr_role' => {'in' => {'select' => {'acmr' => ['id']}, 'where' => {'+acmr' => 'is_public'}}}} + "where" => {'usr_role' => {'in' => {'from' => 'acmr', 'select' => {'acmr' => ['id']}, 'where' => {'+acmr' => 'is_public'}}}} }); $results = $e->json_query({ "from" => "au", @@ -266,14 +266,9 @@ sub load_cresults { 'from' => 'au', 'select' => {'au' => ['id']}, 'where' => { - '-or' => [ - {'pref_first_given_name' => {'~*' => $query}}, - {'first_given_name' => {'~*' => $query}}, - {'pref_second_given_name' => {'~*' => $query}}, - {'second_given_name' => {'~*' => $query}}, - {'pref_family_name' => {'~*' => $query}}, - {'family_name' => {'~*' => $query}} - ] + 'name_kw_tsvector' => { + '@@' => {'value' => [ 'plainto_tsquery', $query ] } + } } }}} }}}; diff --git a/Open-ILS/src/templates/opac/course/results.tt2 b/Open-ILS/src/templates/opac/course/results.tt2 index d2d68cadee..41966bf91d 100644 --- a/Open-ILS/src/templates/opac/course/results.tt2 +++ b/Open-ILS/src/templates/opac/course/results.tt2 @@ -86,7 +86,7 @@ href="[% mkurl(ctx.opac_root _ '/results', {qtype => 'instructor', query => instructorString}) %]" rel="nofollow" vocab=""> - [% instructorString %] ([% l(instructor.usr_role.name) %]). + [% instructorString %] ([% l(instructor.usr_role) %]). [% END %]
diff --git a/Open-ILS/src/templates/opac/parts/course/body.tt2 b/Open-ILS/src/templates/opac/parts/course/body.tt2 index 7f6333aaac..2d80caff69 100644 --- a/Open-ILS/src/templates/opac/parts/course/body.tt2 +++ b/Open-ILS/src/templates/opac/parts/course/body.tt2 @@ -24,7 +24,7 @@ ELSE; instructorString = instructorString _ instructor.first_given_name; END; - instructorString = instructorString _ ' (' _ l(instructor.usr_role.name) _ ')'; %] + instructorString = instructorString _ ' (' _ l(instructor.usr_role) _ ')'; %] [% instructorString %]. [% END %]
-- 2.11.0