LP1849212: Course Reserves database and IDL
authorKyle Huckins <khuckins@catalyte.io>
Fri, 18 Oct 2019 18:05:57 +0000 (18:05 +0000)
committerGalen Charlton <gmc@equinoxinitiative.org>
Mon, 14 Sep 2020 22:16:01 +0000 (18:16 -0400)
- Create MANAGE_RESERVES permission.
- Create IDL Object for Courses.
- Create table within asset schema for Courses, containing an id,
a name, a course number, a section number, and an owning library.
- Add IDL Class and asset table to map actor.usr and
asset.course_module_course, along with an optional
string value for the user's role in the course. If
desired, this can later be fleshed out into a separate
course role table.
- Create IDL Class & Table for Course Materials
- Create IDL Class & Table for Non-Cataloged Course Materials
- YAOUS introduced to allow opting into the Course Materials
module functionality.
- Change instances of non-cat-course_materials to non_cat_course_materials

Signed-off-by: Kyle Huckins <khuckins@catalyte.io>
Signed-off-by: Jane Sandberg <sandbej@linnbenton.edu>
Signed-off-by: Michele Morgan <mmorgan@noblenet.org>
Signed-off-by: Galen Charlton <gmc@equinoxinitiative.org>

Open-ILS/examples/fm_IDL.xml
Open-ILS/src/sql/Pg/040.schema.asset.sql
Open-ILS/src/sql/Pg/950.data.seed-values.sql
Open-ILS/src/sql/Pg/upgrade/XXXX.schema.course-materials-module.sql [new file with mode: 0644]

index 6b9640c..146f0a8 100644 (file)
@@ -3111,6 +3111,110 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA
             </actions>
         </permacrud>
        </class>
+    <class id="acmc" controller="open-ils.cstore open-ils.pcrud" oils_obj:fieldmapper="asset::course_module_course" oils_persist:tablename="asset.course_module_course" reporter:label="Course">
+        <fields oils_persist:primary="id" oils_persist:sequence="asset.course_module_course_id_seq">
+            <field reporter:label="ID" name="id" reporter:datatype="id" />
+            <field reporter:label="Title" name="name" reporter:datatype="text" />
+            <field reporter:label="Course Number" name="course_number" reporter:datatype="text" />
+            <field reporter:label="Section Number" name="section_number" reporter:datatype="text" />
+            <field reporter:label="Owning Library" name="owning_lib" reporter:datatype="link" />
+            <field reporter:label="Course Members" name="members" oils_persist:virtual="true" reporter:datatype="link" />
+            <field reporter:label="Course Materials" name="materials" oils_persist:virtual="true" reporter:datatype="link" />
+            <field reporter:label="Non-Cataloged Course Materials" name="non_cat_materials" oils_persist:virtual="true" reporter:datatype="link" />
+        </fields>
+        <links>
+            <link field="owning_lib" reltype="has_a" key="id" map="" class="aou" />
+            <link field="members" reltype="has_many" key="course" map="" class="acmcu" />
+            <link field="materials" reltype="has_many" key="course" map="" class="acmcm" />
+            <link field="non_cat_materials" reltype="has_many" key="course" map="" class="acmncm" />
+        </links>
+        <permacrud xmlns="http://open-ils.org/spec/opensrf/IDL/permacrud/v1">
+            <actions>
+                <create permission="MANAGE_RESERVES" context_field="owning_lib"/>
+                <retrieve/>
+                <update permission="MANAGE_RESERVES" context_field="owning_lib"/>
+                <delete permission="MANAGE_RESERVES" context_field="owning_lib"/>
+            </actions>
+        </permacrud>
+    </class>
+    <class id="acmcu" controller="open-ils.cstore open-ils.pcrud" oils_obj:fieldmapper="asset::course_module_course_users" oils_persist:tablename="asset.course_module_course_users" reporter:label="Course Users">
+        <fields oils_persist:primary="id" oils_persist:sequence="asset.course_module_course_users_id_seq">
+            <field reporter:label="ID" name="id" reporter:datatype="id" />
+            <field reporter:label="Course" name="course" reporter:datatype="link" />
+            <field reporter:label="User" name="usr" reporter:datatype="link" />
+            <field reporter:label="User Role" name="user_role" reporter:datatype="text" />
+        </fields>
+        <links>
+            <link field="course" reltype="has_a" key="id" map="" class="acmc" />
+            <link field="usr" reltype="has_a" key="id" map="" class="au" />
+        </links>
+        <permacrud xmlns="http://open-ils.org/spec/opensrf/IDL/permacrud/v1">
+            <actions>
+                <create permission="MANAGE_RESERVES">
+                                       <context link="course" field="owning_lib" />
+                </create>
+                <retrieve/>
+                <update permission="MANAGE_RESERVES">
+                                       <context link="course" field="owning_lib" />
+                </update>
+                <delete permission="MANAGE_RESERVES">
+                                       <context link="course" field="owning_lib" />
+                </delete>
+            </actions>
+        </permacrud>
+    </class>
+    <class id="acmcm" controller="open-ils.cstore open-ils.pcrud" oils_obj:fieldmapper="asset::course_module_course_materials" oils_persist:tablename="asset.course_module_course_materials" reporter:label="Course Materials">
+        <fields oils_persist:primary="id" oils_persist:sequence="asset.course_module_course_materials_id_seq">
+            <field reporter:label="ID" name="id" reporter:datatype="id" />
+            <field reporter:label="Course" name="course" reporter:datatype="link" />
+            <field reporter:label="Item" name="item" reporter:datatype="link" />
+            <field reporter:label="Item Relationship" name="relationship" reporter:datatype="text" />
+        </fields>
+        <links>
+            <link field="course" reltype="has_a" key="id" map="" class="acmc" />
+            <link field="item" reltype="has_a" key="id" map="" class="acp" />
+        </links>
+        <permacrud xmlns="http://open-ils.org/spec/opensrf/IDL/permacrud/v1">
+            <actions>
+                <create permission="MANAGE_RESERVES">
+                                       <context link="course" field="owning_lib" />
+                </create>
+                <retrieve/>
+                <update permission="MANAGE_RESERVES">
+                                       <context link="course" field="owning_lib" />
+                </update>
+                <delete permission="MANAGE_RESERVES">
+                                       <context link="course" field="owning_lib" />
+                </delete>
+            </actions>
+        </permacrud>
+    </class>
+    <class id="acmncm" controller="open-ils.cstore open-ils.pcrud" oils_obj:fieldmapper="asset::course_module_non_cat_course_materials" oils_persist:tablename="asset.course_module_non_cat_course_materials" reporter:label="Non-Cataloged Course Materials">
+        <fields oils_persist:primary="id" oils_persist:sequence="asset.course_module_non_cat_course_materials_id_seq">
+            <field reporter:label="ID" name="id" reporter:datatype="id" />
+            <field reporter:label="Course" name="course" reporter:datatype="link" />
+            <field reporter:label="Title" name="title" reporter:datatype="text" />
+            <field reporter:label="URL" name="url" reporter:datatype="text" />
+            <field reporter:label="Item Relationship" name="relationship" reporter:datatype="text" />
+        </fields>
+        <links>
+            <link field="course" reltype="has_a" key="id" map="" class="acmc" />
+        </links>
+        <permacrud xmlns="http://open-ils.org/spec/opensrf/IDL/permacrud/v1">
+            <actions>
+                <create permission="MANAGE_RESERVES">
+                                       <context link="course" field="owning_lib" />
+                </create>
+                <retrieve/>
+                <update permission="MANAGE_RESERVES">
+                                       <context link="course" field="owning_lib" />
+                </update>
+                <delete permission="MANAGE_RESERVES">
+                                       <context link="course" field="owning_lib" />
+                </delete>
+            </actions>
+        </permacrud>
+    </class>
     <class id="acnc" controller="open-ils.cstore open-ils.pcrud" oils_obj:fieldmapper="asset::call_number_class" oils_persist:tablename="asset.call_number_class" reporter:label="Call number classification scheme">
         <fields oils_persist:primary="id" oils_persist:sequence="asset.call_number_class_id_seq">
             <field reporter:label="Call number class ID" name="id" reporter:datatype="id"/>
index 198632a..2d21799 100644 (file)
@@ -1105,5 +1105,35 @@ CREATE VIEW asset.active_copy_alert AS
       FROM  asset.copy_alert
       WHERE ack_time IS NULL;
 
+CREATE TABLE asset.course_module_course (
+    id              SERIAL PRIMARY KEY,
+    name            TEXT NOT NULL,
+    course_number   TEXT NOT NULL,
+    section_number  TEXT,
+    owning_lib      INT REFERENCES actor.org_unit (id)
+);
+
+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
+);
+
+CREATE TABLE asset.course_module_course_materials (
+    id              SERIAL PRIMARY KEY,
+    course          INT NOT NULL REFERENCES asset.course_module_course (id),
+    item            INT NOT NULL REFERENCES asset.copy (id),
+    relationship    TEXT
+);
+
+CREATE TABLE asset.course_module_non_cat_course_materials (
+    id              SERIAL PRIMARY KEY,
+    course          INT NOT NULL REFERENCES asset.course_module_course (id),
+    item            TEXT NOT NULL,
+    url             TEXT,
+    relationship    TEXT
+);
+
 COMMIT;
 
index 28be205..8f6353d 100644 (file)
@@ -1940,7 +1940,9 @@ INSERT INTO permission.perm_list ( id, code, description ) VALUES
  ( 622, 'VIEW_BOOKING_RESOURCE', oils_i18n_gettext(622,
     'View booking resources', 'ppl', 'description')),
  ( 623, 'UPDATE_ORG_UNIT_SETTING.opac.matomo', oils_i18n_gettext(623,
-    'Allows a user to configure Matomo Analytics org unit settings', 'ppl', 'description'))
+    'Allows a user to configure Matomo Analytics org unit settings', 'ppl', 'description')),
+ ( 624, 'MANAGE_RESERVES', oils_i18n_gettext(623,
+    'Allows user to manage Courses, Course Materials, and associate Users with Courses.', 'ppl', 'description'))
 ;
 
 
@@ -2454,6 +2456,7 @@ INSERT INTO permission.grp_perm_map (grp, perm, depth, grantable)
                        'CREATE_CIRC_DURATION',
                        'CREATE_PRECAT',
                        'DELETE_CIRC_DURATION',
+            'MANAGE_RESERVES',
                        'MARK_ITEM_MISSING_PIECES',
                        'UPDATE_CIRC_DURATION',
                        'UPDATE_HOLD_REQUEST_TIME',
@@ -3829,6 +3832,17 @@ INSERT into config.org_unit_setting_type
         'coust', 'description'),
     'bool', null)
 
+,( 'circ.course_materials_opt_in', 'circ',
+    oils_i18n_gettext(
+        'circ.course_materials_opt_in',
+        'Opt Org Unit into the Course Materials Module',
+        'coust', 'label'),
+    oils_i18n_gettext(
+        'circ.course_materials_opt_in',
+        'If enabled, the Org Unit will utilize Course Material functionality.'
+        'coust', 'description'),
+    'bool', null)
+
 ,( 'circ.password_reset_request_per_user_limit', 'sec',
     oils_i18n_gettext('circ.password_reset_request_per_user_limit',
         'Maximum concurrently active self-serve password reset requests per user',
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
new file mode 100644 (file)
index 0000000..23dd272
--- /dev/null
@@ -0,0 +1,68 @@
+BEGIN;
+
+SELECT evergreen.upgrade_deps_block_check('XXXX', :eg_version);
+
+CREATE TABLE asset.course_module_course (
+    id              SERIAL PRIMARY KEY,
+    name            TEXT NOT NULL,
+    course_number   TEXT NOT NULL,
+    section_number  TEXT,
+    owning_lib      INT REFERENCES actor.org_unit (id)
+);
+
+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
+);
+
+CREATE TABLE asset.course_module_course_materials (
+    id              SERIAL PRIMARY KEY,
+    course          INT NOT NULL REFERENCES asset.course_module_course (id),
+    item            INT NOT NULL REFERENCES asset.copy (id),
+    relationship    TEXT
+);
+
+CREATE TABLE asset.course_module_non_cat_course_materials (
+    id              SERIAL PRIMARY KEY,
+    course          INT NOT NULL REFERENCES asset.course_module_course (id),
+    item            TEXT NOT NULL,
+    url             TEXT,
+    relationship    TEXT
+);
+
+INSERT INTO permission.perm_list(id, code, description)
+    VALUES (
+        624,
+        'MANAGE_RESERVES',
+        oils_i18n_gettext(
+            624,
+            'Allows user to manage Courses, Course Materials, and associate Users with Courses.',
+            'ppl',
+            'description'
+        )
+    );
+
+INSERT INTO permission.grp_perm_map(perm, grp, depth) VALUES (624, 9, 0), (624, 11, 0), (624, 12, 0), (624, 13, 0);
+
+INSERT INTO config.org_unit_setting_type 
+    (grp, name, datatype, label, description)
+VALUES (
+    'circ',
+    'circ.course_materials_opt_in', 'bool',
+    oils_i18n_gettext(
+        'circ.course_materials_opt_in',
+        'Opt Org Unit into the Course Materials Module',
+        'coust',
+        'label'
+    ),
+    oils_i18n_gettext(
+        'circ.course_materials_opt_in',
+        'If enabled, the Org Unit will utilize Course Material functionality.'
+        'coust',
+        'description'
+    )
+);
+
+COMMIT;