From bfbc29f010a228882b5d071a0e151113d9d85acb Mon Sep 17 00:00:00 2001 From: pzed Date: Wed, 19 Aug 2009 15:19:03 +0000 Subject: [PATCH] testing Leddy and Law for valid patron groups git-svn-id: svn://svn.open-ils.org/ILS-Contrib/conifer/trunk@625 6d9bc8c9-1ec2-4278-b937-99fde70a366f --- circ/circ_permit_copy.js | 80 +++++++++++++++++++++++++++++++----------------- 1 file changed, 52 insertions(+), 28 deletions(-) diff --git a/circ/circ_permit_copy.js b/circ/circ_permit_copy.js index b7d05b6b6c..cbc3e17619 100644 --- a/circ/circ_permit_copy.js +++ b/circ/circ_permit_copy.js @@ -52,24 +52,31 @@ if( ! isTrue(copy.circulate) || if (copy.circ_lib.shortname == 'OWA') { // permit circulations for the following circ modifiers to all patrons + var valid_patrons = ['Faculty', 'Graduate', 'Undergraduate', 'Staff members', 'Readers']; var circ_allow_list = ['CIRC', 'CRC MEDIA', 'CRC SPEC', 'CRC TEXT', 'DOC', 'DVD VIDEO', 'MAP (CIRCULATING)', 'MEDIA', 'MFORM', 'REF', 'THESIS']; - // add permissions for patron groups who are not external borrowers - if (patronProfile == 'Faculty' || patronProfile == 'Graduate' || patronProfile == 'Undergraduate' || patronProfile == 'Staff members') { - circ_allow_list = circ_allow_list.concat('CIRC SHORT', 'RSV1', 'RSV2', 'RSV3', 'RSV7'); - } + if (isValidPatron(patronProfile, valid_patrons)) { + + // add permissions for patron groups who are not external borrowers + if (patronProfile == 'Faculty' || patronProfile == 'Graduate' || patronProfile == 'Undergraduate' || patronProfile == 'Staff members') { + circ_allow_list = circ_allow_list.concat('CIRC SHORT', 'RSV1', 'RSV2', 'RSV3', 'RSV7'); + } - // faculty, grads, and staff can borrow serials - if (patronProfile == 'Faculty' || patronProfile == 'Graduate'|| patronProfile == 'Staff members') { - circ_allow_list = circ_allow_list.concat('SER'); - } + // faculty, grads, and staff can borrow serials + if (patronProfile == 'Faculty' || patronProfile == 'Graduate'|| patronProfile == 'Staff members') { + circ_allow_list = circ_allow_list.concat('SER'); + } - // faculty and staff can also borrow music CDs - if (patronProfile == 'Faculty' || patronProfile == 'Staff members') { - circ_allow_list = circ_allow_list.concat('CD MUSIC'); - } + // faculty and staff can also borrow music CDs + if (patronProfile == 'Faculty' || patronProfile == 'Staff members') { + circ_allow_list = circ_allow_list.concat('CD MUSIC'); + } - if ( ! testCircAllow(circ_allow_list) ) { + if ( ! testCircAllow(circ_allow_list) ) { + result.events.push('COPY_CIRC_NOT_ALLOWED'); + } + + } else { result.events.push('COPY_CIRC_NOT_ALLOWED'); } } // end permissions for Windsor Leddy @@ -77,25 +84,33 @@ if (copy.circ_lib.shortname == 'OWA') { // set permissions for Windsor Law if (copy.circ_lib.shortname == 'OWAL') { - // only Law external borrowers can borrow Law items - if (patronProfile == 'Readers' && patron.home_ou.shortname <> 'OWAL'){ - result.events.push('COPY_CIRC_NOT_ALLOWED'); - } + var valid_patrons = ['Faculty', 'Graduate', 'Undergraduate', 'Staff members', 'Readers']; - // permit circulations for the following circ modifiers to all patrons not excluded above - var circ_allow_list = ['LAW MONO']; + if (isValidPatron(patronProfile, valid_patrons)) { - // add permissions for patron groups who are not external borrowers - if (patronProfile == 'Faculty' || patronProfile == 'Graduate' || patronProfile == 'Undergraduate' || patronProfile == 'Staff members') { - circ_allow_list = circ_allow_list.concat('LAW RES1D', 'LAW RES3D', 'LAW RES3H', 'LAW RES5H'); - } + // only Law external borrowers can borrow Law items + if (patronProfile == 'Readers' && patron.home_ou.shortname != 'OWAL') { + result.events.push('COPY_CIRC_NOT_ALLOWED'); + } - // faculty can borrow non-circulating items and serials - if (patronProfile == 'Faculty') { - circ_allow_list = circ_allow_list.concat('LAW NOCIRC', 'LAW SERIAL'); - } + // permit circulations for the following circ modifiers to all patrons not excluded above + var circ_allow_list = ['LAW MONO']; + + // add permissions for patron groups who are not external borrowers + if (patronProfile == 'Faculty' || patronProfile == 'Graduate' || patronProfile == 'Undergraduate' || patronProfile == 'Staff members') { + circ_allow_list = circ_allow_list.concat('LAW RES1D', 'LAW RES3D', 'LAW RES3H', 'LAW RES5H'); + } + + // faculty can borrow non-circulating items and serials + if (patronProfile == 'Faculty') { + circ_allow_list = circ_allow_list.concat('LAW NOCIRC', 'LAW SERIAL'); + } - if ( ! testCircAllow(circ_allow_list) ) { + if ( ! testCircAllow(circ_allow_list) ) { + result.events.push('COPY_CIRC_NOT_ALLOWED'); + } + + } else { result.events.push('COPY_CIRC_NOT_ALLOWED'); } } // end permissions for Windsor Law @@ -118,6 +133,15 @@ function isAMember(shortname, group) { return false; } +function isValidPatron(patronProfile, valid_patrons) { + for (var i = 0; i < valid_patrons.length; i++) { + if (valid_patrons[i] == patronProfile) { + return true; + } + } + return false; +} + function testCircAllow(circ_allow_list) { for (var i = 0; i < circ_allow_list.length; i++) { if (circ_allow_list[i] == copy.circ_modifier) { -- 2.11.0