[open-ils-commits] r625 - conifer/trunk/circ (pzed)

svn at svn.open-ils.org svn at svn.open-ils.org
Wed Aug 19 11:19:06 EDT 2009


Author: pzed
Date: 2009-08-19 11:19:03 -0400 (Wed, 19 Aug 2009)
New Revision: 625

Modified:
   conifer/trunk/circ/circ_permit_copy.js
Log:
testing Leddy and Law for valid patron groups

Modified: conifer/trunk/circ/circ_permit_copy.js
===================================================================
--- conifer/trunk/circ/circ_permit_copy.js	2009-08-18 18:48:39 UTC (rev 624)
+++ conifer/trunk/circ/circ_permit_copy.js	2009-08-19 15:19:03 UTC (rev 625)
@@ -52,24 +52,31 @@
 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 @@
 // 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'];
 
-	if ( ! testCircAllow(circ_allow_list) ) {
+		// 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');
 	}
 } // end permissions for Windsor Law
@@ -118,6 +133,15 @@
 	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) {



More information about the open-ils-commits mailing list