From 6714a00b838d792612362c0a29e9982cb2bb3cf2 Mon Sep 17 00:00:00 2001 From: Jane Sandberg Date: Tue, 1 Sep 2020 21:24:08 -0700 Subject: [PATCH] LP1849212: Use a set list of roles for course users Signed-off-by: Jane Sandberg Signed-off-by: Michele Morgan Signed-off-by: Galen Charlton --- Open-ILS/examples/fm_IDL.xml | 19 +++++++++++-- .../course-associate-users.component.html | 27 ++++-------------- .../course-associate-users.component.ts | 12 ++++---- .../course-list.component.html | 8 +++++- .../eg2/src/app/staff/share/course.service.ts | 3 +- .../lib/OpenILS/Application/Courses.pm | 4 +-- .../lib/OpenILS/WWW/EGCatLoader/Course.pm | 10 +++++-- Open-ILS/src/sql/Pg/040.schema.asset.sql | 9 ++++-- Open-ILS/src/sql/Pg/950.data.seed-values.sql | 5 ++++ .../XXXX.schema.course-materials-module.sql | 28 +++++++++++++------ .../src/templates/opac/course/results.tt2 | 2 +- .../src/templates/opac/parts/course/body.tt2 | 2 +- 12 files changed, 79 insertions(+), 50 deletions(-) diff --git a/Open-ILS/examples/fm_IDL.xml b/Open-ILS/examples/fm_IDL.xml index d5e7377ea8..3dc33be718 100644 --- a/Open-ILS/examples/fm_IDL.xml +++ b/Open-ILS/examples/fm_IDL.xml @@ -3143,12 +3143,12 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA - - + + @@ -3251,6 +3251,21 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA + + + + + + + + + + + + + + + diff --git a/Open-ILS/src/eg2/src/app/staff/admin/local/course-reserves/course-associate-users.component.html b/Open-ILS/src/eg2/src/app/staff/admin/local/course-reserves/course-associate-users.component.html index f96087deee..5959761e15 100644 --- a/Open-ILS/src/eg2/src/app/staff/admin/local/course-reserves/course-associate-users.component.html +++ b/Open-ILS/src/eg2/src/app/staff/admin/local/course-reserves/course-associate-users.component.html @@ -36,30 +36,13 @@
- + +
-
-
-
-
- -
-
-
-
- -
-
-
-
diff --git a/Open-ILS/src/eg2/src/app/staff/admin/local/course-reserves/course-associate-users.component.ts b/Open-ILS/src/eg2/src/app/staff/admin/local/course-reserves/course-associate-users.component.ts index d9360ccb00..55d77b43df 100644 --- a/Open-ILS/src/eg2/src/app/staff/admin/local/course-reserves/course-associate-users.component.ts +++ b/Open-ILS/src/eg2/src/app/staff/admin/local/course-reserves/course-associate-users.component.ts @@ -7,11 +7,12 @@ import {Pager} from '@eg/share/util/pager'; import {NgbModal} from '@ng-bootstrap/ng-bootstrap'; import {GridDataSource} from '@eg/share/grid/grid'; import {GridComponent} from '@eg/share/grid/grid.component'; -import {IdlObject, IdlService} from '@eg/core/idl.service'; +import {IdlObject} from '@eg/core/idl.service'; import {StringComponent} from '@eg/share/string/string.component'; import {FmRecordEditorComponent} from '@eg/share/fm-editor/fm-editor.component'; import {ToastService} from '@eg/share/toast/toast.service'; import {CourseService} from '@eg/staff/share/course.service'; +import {ComboboxEntry} from '@eg/share/combobox/combobox.component'; @Component({ selector: 'eg-course-associate-users-dialog', @@ -39,8 +40,7 @@ export class CourseAssociateUsersComponent extends DialogComponent implements On userEditFailedString: StringComponent; usersDataSource: GridDataSource; userBarcode: String; - userRoleInput: String; - isPublicRole: Boolean; + userRoleInput: ComboboxEntry; constructor( private auth: AuthService, @@ -69,10 +69,12 @@ export class CourseAssociateUsersComponent extends DialogComponent implements On const args = { currentCourse: this.currentCourse, barcode: barcode.trim(), - role: this.userRoleInput, - is_public: this.isPublicRole }; + if (this.userRoleInput) { + args['role'] = this.userRoleInput.id; + } + this.userBarcode = null; this.net.request( diff --git a/Open-ILS/src/eg2/src/app/staff/admin/local/course-reserves/course-list.component.html b/Open-ILS/src/eg2/src/app/staff/admin/local/course-reserves/course-list.component.html index 13f9932563..3fac6006a8 100644 --- a/Open-ILS/src/eg2/src/app/staff/admin/local/course-reserves/course-list.component.html +++ b/Open-ILS/src/eg2/src/app/staff/admin/local/course-reserves/course-list.component.html @@ -33,7 +33,7 @@ - +
  • @@ -42,6 +42,12 @@
  • +
  • + Course roles + + + +
  • diff --git a/Open-ILS/src/eg2/src/app/staff/share/course.service.ts b/Open-ILS/src/eg2/src/app/staff/share/course.service.ts index c3e480da41..43caf76528 100644 --- a/Open-ILS/src/eg2/src/app/staff/share/course.service.ts +++ b/Open-ILS/src/eg2/src/app/staff/share/course.service.ts @@ -53,7 +53,7 @@ export class CourseService { getUsers(course_ids?: Number[]): Observable { const flesher = { flesh: 1, - flesh_fields: {'acmcu': ['usr']} + flesh_fields: {'acmcu': ['usr', 'usr_role']} }; if (!course_ids) { return this.pcrud.retrieveAll('acmcu', @@ -134,7 +134,6 @@ export class CourseService { associateUsers(patron_id, args) { const new_user = this.idl.create('acmcu'); - if (args.is_public) { new_user.is_public(args.is_public); } if (args.role) { new_user.usr_role(args.role); } new_user.course(args.currentCourse.id()); new_user.usr(patron_id); diff --git a/Open-ILS/src/perlmods/lib/OpenILS/Application/Courses.pm b/Open-ILS/src/perlmods/lib/OpenILS/Application/Courses.pm index 836a9347df..a68ce6b7fe 100644 --- a/Open-ILS/src/perlmods/lib/OpenILS/Application/Courses.pm +++ b/Open-ILS/src/perlmods/lib/OpenILS/Application/Courses.pm @@ -191,11 +191,11 @@ sub fetch_course_users { my %patrons; $filter->{course} = $course_id; - $filter->{is_public} = 't' + $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, {order_by => {acmcu => 'id'}}); + $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; 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 eaffd44223..88c35aac32 100644 --- a/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Course.pm +++ b/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Course.pm @@ -64,10 +64,9 @@ sub load_course_browse { "select" => {"acmcu" => [ 'id', 'usr', - 'is_public' ]}, # TODO: We need to support the chosen library as well... - "where" => {'+acmcu' => 'is_public'} + "where" => {'usr_role' => {'in' => {'select' => {'acmr' => ['id']}, 'where' => {'+acmr' => 'is_public'}}}} }); $results = $e->json_query({ "from" => "au", @@ -88,7 +87,12 @@ sub load_course_browse { "acmcu" => ['usr'] }, "where" => {'-and' => [ - {'+acmcu' => 'is_public'}, + {'usr_role' => { 'in' => { + 'from' => 'acmr', + "select" => { + "acmr" => ['id'] + }, + "where" => {'+acmr' => 'is_public'}}}}, {"course" => { "in" =>{ "from" => "acmc", "select" => { diff --git a/Open-ILS/src/sql/Pg/040.schema.asset.sql b/Open-ILS/src/sql/Pg/040.schema.asset.sql index 04f6b90770..426b460f1a 100644 --- a/Open-ILS/src/sql/Pg/040.schema.asset.sql +++ b/Open-ILS/src/sql/Pg/040.schema.asset.sql @@ -1114,12 +1114,17 @@ CREATE TABLE asset.course_module_course ( is_archived BOOLEAN DEFAULT false ); +CREATE TABLE asset.course_module_role ( + id SERIAL PRIMARY KEY, + name TEXT UNIQUE NOT NULL, + is_public BOOLEAN NOT NULL DEFAULT false +); + CREATE TABLE asset.course_module_course_users ( id SERIAL PRIMARY KEY, course INT NOT NULL REFERENCES asset.course_module_course (id), usr INT NOT NULL REFERENCES actor.usr (id), - usr_role TEXT, - is_public BOOLEAN NOT NULL DEFAULT false + usr_role INT REFERENCES asset.course_module_role (id) ON UPDATE CASCADE ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED ); CREATE TABLE asset.course_module_course_materials ( 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 b62ea3277b..d5b0946951 100644 --- a/Open-ILS/src/sql/Pg/950.data.seed-values.sql +++ b/Open-ILS/src/sql/Pg/950.data.seed-values.sql @@ -20639,6 +20639,11 @@ INSERT INTO actor.org_unit_setting (org_unit, name, value) FROM config.bib_source WHERE source='Course materials module'; +INSERT INTO asset.course_module_role (id, name, is_public) VALUES +(1, oils_i18n_gettext(1, 'Instructor', 'acmr', 'name'), true), +(2, oils_i18n_gettext(2, 'Teaching assistant', 'acmr', 'name'), true), +(3, oils_i18n_gettext(2, 'Student', 'acmr', 'name'), false); + INSERT INTO config.workstation_setting_type (name, grp, datatype, label) VALUES ( diff --git a/Open-ILS/src/sql/Pg/upgrade/XXXX.schema.course-materials-module.sql b/Open-ILS/src/sql/Pg/upgrade/XXXX.schema.course-materials-module.sql index 26dc6c706e..7d903a471b 100644 --- a/Open-ILS/src/sql/Pg/upgrade/XXXX.schema.course-materials-module.sql +++ b/Open-ILS/src/sql/Pg/upgrade/XXXX.schema.course-materials-module.sql @@ -11,12 +11,17 @@ CREATE TABLE asset.course_module_course ( is_archived BOOLEAN NOT NULL DEFAULT false; ); +CREATE TABLE asset.course_module_role ( + id SERIAL PRIMARY KEY, + name TEXT UNIQUE NOT NULL, + is_public BOOLEAN NOT NULL DEFAULT false +); + CREATE TABLE asset.course_module_course_users ( id SERIAL PRIMARY KEY, course INT NOT NULL REFERENCES asset.course_module_course (id), usr INT NOT NULL REFERENCES actor.usr (id), - usr_role TEXT, - is_public BOOLEAN NOT NULL DEFAULT false + usr_role INT REFERENCES asset.course_module_role (id) ON UPDATE CASCADE ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED ); CREATE TABLE asset.course_module_course_materials ( @@ -25,11 +30,11 @@ CREATE TABLE asset.course_module_course_materials ( item INT REFERENCES asset.copy (id), relationship TEXT, record INT REFERENCES biblio.record_entry (id), - temporary_record BOOLEAN, - original_location INT REFERENCES asset.copy_location, - original_status INT REFERENCES config.copy_status, - original_circ_modifier TEXT, --REFERENCES config.circ_modifier, - original_callnumber INT REFERENCES asset.call_number, + temporary_record BOOLEAN, + original_location INT REFERENCES asset.copy_location, + original_status INT REFERENCES config.copy_status, + original_circ_modifier TEXT, --REFERENCES config.circ_modifier + original_callnumber INT REFERENCES asset.call_number, unique (course, item, record) ); @@ -37,10 +42,15 @@ CREATE TABLE asset.course_module_term ( id SERIAL PRIMARY KEY, name TEXT UNIQUE NOT NULL, owning_lib INT REFERENCES actor.org_unit (id), - start_date TIMESTAMP WITH TIME ZONE, - end_date TIMESTAMP WITH TIME ZONE + start_date TIMESTAMP WITH TIME ZONE, + end_date TIMESTAMP WITH TIME ZONE ); +INSERT INTO asset.course_module_role (id, name, is_public) VALUES +(1, oils_i18n_gettext(1, 'Instructor', 'acmr', 'name'), true), +(2, oils_i18n_gettext(2, 'Teaching assistant', 'acmr', 'name'), true), +(3, oils_i18n_gettext(2, 'Student', 'acmr', 'name'), false); + CREATE TABLE asset.course_module_term_course_map ( id BIGSERIAL PRIMARY KEY, term INT NOT NULL REFERENCES asset.course_module_term (id) ON UPDATE CASCADE ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED, diff --git a/Open-ILS/src/templates/opac/course/results.tt2 b/Open-ILS/src/templates/opac/course/results.tt2 index f8ae3b971a..d2d68cadee 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) %]). + [% instructorString %] ([% l(instructor.usr_role.name) %]). [% END %]
    diff --git a/Open-ILS/src/templates/opac/parts/course/body.tt2 b/Open-ILS/src/templates/opac/parts/course/body.tt2 index 2d80caff69..7f6333aaac 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) _ ')'; %] + instructorString = instructorString _ ' (' _ l(instructor.usr_role.name) _ ')'; %] [% instructorString %]. [% END %]
    -- 2.43.2