Fixed up algoma circ rules
authorrisard <risard@6d9bc8c9-1ec2-4278-b937-99fde70a366f>
Wed, 2 Sep 2009 15:06:12 +0000 (15:06 +0000)
committerrisard <risard@6d9bc8c9-1ec2-4278-b937-99fde70a366f>
Wed, 2 Sep 2009 15:06:12 +0000 (15:06 +0000)
git-svn-id: svn://svn.open-ils.org/ILS-Contrib/conifer/trunk@637 6d9bc8c9-1ec2-4278-b937-99fde70a366f

circ/circ_permit_copy.js

index f6ec2ae..e18eff5 100644 (file)
-function go() {\r
-\r
-/* load the lib script */\r
-load_lib('circ/circ_lib.js');\r
-load_lib('JSON_v1.js');\r
-log_vars('circ_permit_copy');\r
-\r
-var lusys = ['LUSYS', 'CRC', 'HUNTINGTON', 'LDCR', 'MRC', 'OSUL', 'MEDIACEN', 'SUDBURY'];\r
-var hearstsys = ['HEARSTSYS', 'HEARST', 'KAP', 'TIMMINS'];\r
-var nosmsys = ['OSM', 'NOSME', 'NOSMW'];\r
+function go() {
+
+/* load the lib script */
+load_lib('circ/circ_lib.js');
+load_lib('JSON_v1.js');
+log_vars('circ_permit_copy');
+
+var lusys = ['LUSYS', 'CRC', 'HUNTINGTON', 'LDCR', 'MRC', 'OSUL', 'MEDIACEN', 'SUDBURY'];
+var hearstsys = ['HEARSTSYS', 'HEARST', 'KAP', 'TIMMINS'];
+var nosmsys = ['OSM', 'NOSME', 'NOSMW'];
 var winsys = ['OWA', 'OWAL'];
-var algsys = ['OSTMA']; /* looks silly but we do plan to add one or two branches during the winter term */\r
-\r
-/* In theory, isOrgDescendent would work - but it isn't, for some reason */\r
-if (patron.home_ou.id != copy.circ_lib.id) {\r
-        /* Laurentian campus patrons can borrow from one another */\r
-        if (isOrgDescendent('LUSYS', patron.home_ou.id) && isOrgDescendent('LUSYS', copy.circ_lib.id)) {\r
-                // go in peace\r
-        } else if (isAMember(patron.home_ou.shortname, lusys) && (\r
-                       isAMember(copy.circ_lib.shortname, lusys) || isAMember(copy.circ_lib.shortname, nosmsys) \r
-               ))\r
-       {\r
-                // No problemo\r
-        } else if (isOrgDescendent('HEARSTSYS', patron.home_ou.id) && isOrgDescendent('LUSYS', copy.circ_lib.id)) {\r
-                // go in peace\r
-        } else if (isAMember(patron.home_ou.shortname, hearstsys) && isAMember(copy.circ_lib.shortname, hearstsys)) {\r
-                // No problemo\r
-        } else if (isAMember(patron.home_ou.shortname, winsys) && isAMember(copy.circ_lib.shortname, winsys)) {\r
-                // No problemo\r
-        } else if (isOrgDescendent('OSM', patron.home_ou.id) && isOrgDescendent('OSM', copy.circ_lib.id)) {\r
-                // go in peace\r
-        } else if (isAMember(patron.home_ou.shortname, nosmsys) && (\r
-                       isAMember(copy.circ_lib.shortname, lusys) || isAMember(copy.circ_lib.shortname, nosmsys) \r
-               ))\r
-       {\r
-                // No problemo\r
-        } else {\r
-                result.events.push('CIRC_EXCEEDS_COPY_RANGE');\r
-        }\r
-}\r
-\r
-if( ! isTrue(copy.circulate) || \r
-       !isTrue(copy.location.circulate) ||\r
-       (copy.circ_lib.shortname == 'OSUL' && copy.circ_modifier == 'DEPOSIT') ||\r
-       (copy.circ_lib.shortname == 'OSUL' && copy.circ_modifier == 'DOCUMENTS') ||\r
-       (copy.circ_lib.shortname == 'OSUL' && copy.circ_modifier == 'PERIODICAL') ||\r
-       (copy.circ_lib.shortname == 'OSUL' && copy.circ_modifier == 'REFERENCE')\r
-) {\r
-       result.events.push('COPY_CIRC_NOT_ALLOWED');\r
-}\r
-\r
-// set permissions for Windsor Leddy\r
-if (copy.circ_lib.shortname == 'OWA') {\r
-\r
-       if (isValidPatron(patronProfile)) {\r
-  \r
-               // permit circulations for the following circ modifiers to all patrons\r
-               var circ_allow_list = ['CIRC', 'CRC MEDIA', 'CRC SPEC', 'CRC TEXT', 'DOC', 'DVD VIDEO', 'MEDIA', 'MFORM', 'REF', 'THESIS'];\r
-\r
-               // add permissions for patron groups who are not external borrowers\r
-               if (patronProfile == 'Faculty' || patronProfile == 'Graduate' || patronProfile == 'Undergraduate' || patronProfile == 'Staff members') {\r
-                       circ_allow_list = circ_allow_list.concat('CIRC SHORT', 'RSV1', 'RSV2', 'RSV3', 'RSV7');\r
-               }\r
-\r
-               // faculty, grads, and staff can borrow serials\r
-               if (patronProfile == 'Faculty' || patronProfile == 'Graduate'|| patronProfile == 'Staff members') {\r
-                       circ_allow_list = circ_allow_list.concat('SER');\r
-               }\r
-\r
-               // faculty and staff can also borrow music CDs\r
-               if (patronProfile == 'Faculty' || patronProfile == 'Staff members') {\r
-                       circ_allow_list = circ_allow_list.concat('CD MUSIC');\r
-               }\r
-\r
-               if ( ! testCircAllow(circ_allow_list) ) {\r
-                       result.events.push('COPY_CIRC_NOT_ALLOWED');\r
-               }\r
-\r
-       } else {\r
-               result.events.push('COPY_CIRC_NOT_ALLOWED'); // would prefer this to push a "Check Patron Profile" message\r
-       }\r
-} // end permissions for Windsor Leddy\r
-\r
-// set permissions for Windsor Law\r
-if (copy.circ_lib.shortname == 'OWAL') {\r
-\r
-       if (isValidPatron(patronProfile)) {\r
-\r
-               // only Law external borrowers can borrow Law items\r
-               if (patronProfile == 'Readers' && patron.home_ou.shortname != 'OWAL') {\r
-                       result.events.push('COPY_CIRC_NOT_ALLOWED');\r
-               }\r
-\r
-               // permit circulations for the following circ modifiers to all patrons not excluded above\r
-               var circ_allow_list = ['LAW MONO'];\r
-\r
-               // add permissions for patron groups who are not external borrowers\r
-               if (patronProfile == 'Faculty' || patronProfile == 'Graduate' || patronProfile == 'Undergraduate' || patronProfile == 'Staff members') {\r
-                       circ_allow_list = circ_allow_list.concat('LAW RES1D', 'LAW RES3D', 'LAW RES3H', 'LAW RES5H');\r
-               }\r
-\r
-               // faculty can borrow non-circulating items and serials\r
-               if (patronProfile == 'Faculty') {\r
-                       circ_allow_list = circ_allow_list.concat('LAW NOCIRC', 'LAW SERIAL');\r
-               }\r
-\r
-               if ( ! testCircAllow(circ_allow_list) ) {\r
-                       result.events.push('COPY_CIRC_NOT_ALLOWED');\r
-               }\r
-\r
-       } else {\r
-               result.events.push('COPY_CIRC_NOT_ALLOWED'); // would prefer this to push a "Check Patron Profile" message\r
-       }\r
-} // end permissions for Windsor Law\r
+var algsys = ['OSTMA']; /* looks silly but we do plan to add one or two branches during the winter term */
+
+/* In theory, isOrgDescendent would work - but it isn't, for some reason */
+if (patron.home_ou.id != copy.circ_lib.id) {
+        /* Laurentian campus patrons can borrow from one another */
+        if (isOrgDescendent('LUSYS', patron.home_ou.id) && isOrgDescendent('LUSYS', copy.circ_lib.id)) {
+                // go in peace
+        } else if (isAMember(patron.home_ou.shortname, lusys) && (
+                       isAMember(copy.circ_lib.shortname, lusys) || isAMember(copy.circ_lib.shortname, nosmsys) 
+               ))
+       {
+                // No problemo
+        } else if (isOrgDescendent('HEARSTSYS', patron.home_ou.id) && isOrgDescendent('LUSYS', copy.circ_lib.id)) {
+                // go in peace
+        } else if (isAMember(patron.home_ou.shortname, hearstsys) && isAMember(copy.circ_lib.shortname, hearstsys)) {
+                // No problemo
+        } else if (isAMember(patron.home_ou.shortname, winsys) && isAMember(copy.circ_lib.shortname, winsys)) {
+                // No problemo
+        } else if (isOrgDescendent('OSM', patron.home_ou.id) && isOrgDescendent('OSM', copy.circ_lib.id)) {
+                // go in peace
+        } else if (isAMember(patron.home_ou.shortname, nosmsys) && (
+                       isAMember(copy.circ_lib.shortname, lusys) || isAMember(copy.circ_lib.shortname, nosmsys) 
+               ))
+       {
+                // No problemo
+        } else {
+                result.events.push('CIRC_EXCEEDS_COPY_RANGE');
+        }
+}
+
+if( ! isTrue(copy.circulate) || 
+       !isTrue(copy.location.circulate) ||
+       (copy.circ_lib.shortname == 'OSUL' && copy.circ_modifier == 'DEPOSIT') ||
+       (copy.circ_lib.shortname == 'OSUL' && copy.circ_modifier == 'DOCUMENTS') ||
+       (copy.circ_lib.shortname == 'OSUL' && copy.circ_modifier == 'PERIODICAL') ||
+       (copy.circ_lib.shortname == 'OSUL' && copy.circ_modifier == 'REFERENCE')
+) {
+       result.events.push('COPY_CIRC_NOT_ALLOWED');
+}
+
+// set permissions for Windsor Leddy
+if (copy.circ_lib.shortname == 'OWA') {
+
+       if (isValidPatron(patronProfile)) {
+  
+               // permit circulations for the following circ modifiers to all patrons
+               var circ_allow_list = ['CIRC', 'CRC MEDIA', 'CRC SPEC', 'CRC TEXT', 'DOC', 'DVD VIDEO', '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');
+               }
+
+               // 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');
+               }
+
+               if ( ! testCircAllow(circ_allow_list) ) {
+                       result.events.push('COPY_CIRC_NOT_ALLOWED');
+               }
+
+       } else {
+               result.events.push('COPY_CIRC_NOT_ALLOWED'); // would prefer this to push a "Check Patron Profile" message
+       }
+} // end permissions for Windsor Leddy
+
+// set permissions for Windsor Law
+if (copy.circ_lib.shortname == 'OWAL') {
+
+       if (isValidPatron(patronProfile)) {
+
+               // only Law external borrowers can borrow Law items
+               if (patronProfile == 'Readers' && patron.home_ou.shortname != 'OWAL') {
+                       result.events.push('COPY_CIRC_NOT_ALLOWED');
+               }
+
+               // 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) ) {
+                       result.events.push('COPY_CIRC_NOT_ALLOWED');
+               }
+
+       } else {
+               result.events.push('COPY_CIRC_NOT_ALLOWED'); // would prefer this to push a "Check Patron Profile" message
+       }
+} // end permissions for Windsor Law
 
 /*******************************
    PERMIT FOR ALGOMA
 ********************************/
 
-if (copy.circ_lib.shortname == 'OSTMA') {\r
-\r
+if (copy.circ_lib.shortname == 'OSTMA') {
+
        if (isValidPatron(patronProfile)) {
 
-               if (copy.location == 'ALGO-SHWK') ||\r
-                  (copy.location == 'ALGO-REF') ||\r
-                  (copy.location == 'ALGO-PER') ||\r
-                  (copy.location == 'ALGO-DOC')\r
-               {\r
-                       result.events.push('COPY_CIRC_NOT_ALLOWED');\r
+               if (copy.location.name == 'ALGO-REF' ||
+                   copy.location.name == 'ALGO-PER' ||
+                   copy.location.name == 'ALGO-SHWK' ||        
+                    copy.location.name == 'ALGO-DOC' 
+                  )
+               {
+                       result.events.push('COPY_CIRC_NOT_ALLOWED');
                }
         } 
 
 
-       if ( !(patronProfile == 'Faculty') && (copy.location == 'ALGO-AV') {
+       if (patronProfile != 'Faculty' && copy.location.name == 'ALGO-AV') {
                result.events.push('COPY_CIRC_NOT_ALLOWED');            
        }
 
@@ -142,33 +143,33 @@ if (copy.circ_lib.shortname == 'OSTMA') {
    END -- PERMIT FOR ALGOMA
 ********************************/
 
-\r
-if( ! isTrue(isRenewal) ) {\r
-       if(copyStatus != 'Available' && \r
-               copyStatus != 'On holds shelf' && copyStatus != 'Reshelving' ) {\r
-                       result.events.push('COPY_NOT_AVAILABLE');\r
-       } \r
-}\r
-\r
-}\r
-\r
-function isAMember(shortname, group) {\r
-       for (var i = 0; i < group.length; i++) {\r
-               if (group[i] == shortname) {\r
-                       return true;\r
-               }\r
-       }\r
-       return false;\r
-}\r
-\r
-function testCircAllow(circ_allow_list) {\r
-       for (var i = 0; i < circ_allow_list.length; i++) {\r
-               if (circ_allow_list[i] == copy.circ_modifier) {\r
-                       return true;\r
-               }\r
-       }\r
-       return false;\r
-}\r
-\r
-go();\r
-\r
+
+if( ! isTrue(isRenewal) ) {
+       if(copyStatus != 'Available' && 
+               copyStatus != 'On holds shelf' && copyStatus != 'Reshelving' ) {
+                       result.events.push('COPY_NOT_AVAILABLE');
+       } 
+}
+
+}
+
+function isAMember(shortname, group) {
+       for (var i = 0; i < group.length; i++) {
+               if (group[i] == shortname) {
+                       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) {
+                       return true;
+               }
+       }
+       return false;
+}
+
+go();
+