[open-ils-commits] r11292 - in trunk/Open-ILS: examples src/sql/Pg
svn at svn.open-ils.org
svn at svn.open-ils.org
Thu Nov 20 17:10:14 EST 2008
Author: miker
Date: 2008-11-20 17:10:07 -0500 (Thu, 20 Nov 2008)
New Revision: 11292
Modified:
trunk/Open-ILS/examples/fm_IDL.xml
trunk/Open-ILS/src/sql/Pg/005.schema.actors.sql
trunk/Open-ILS/src/sql/Pg/006.schema.permissions.sql
trunk/Open-ILS/src/sql/Pg/100.circ_matrix.sql
trunk/Open-ILS/src/sql/Pg/950.data.seed-values.sql
Log:
beginning the org_unit-ification of penalties
Modified: trunk/Open-ILS/examples/fm_IDL.xml
===================================================================
--- trunk/Open-ILS/examples/fm_IDL.xml 2008-11-20 21:15:42 UTC (rev 11291)
+++ trunk/Open-ILS/examples/fm_IDL.xml 2008-11-20 22:10:07 UTC (rev 11292)
@@ -1725,10 +1725,12 @@
<field name="grp" oils_obj:array_position="4" oils_persist:virtual="false" reporter:datatype="link"/>
<field name="penalty" oils_obj:array_position="5" oils_persist:virtual="false" reporter:datatype="link"/>
<field name="threshold" oils_obj:array_position="6" oils_persist:virtual="false" reporter:datatype="float"/>
+ <field name="org_unit" oils_obj:array_position="7" oils_persist:virtual="false" reporter:datatype="link"/>
</fields>
<links>
<link field="penalty" reltype="has_a" key="id" map="" class="csp"/>
<link field="grp" reltype="has_a" key="id" map="" class="pgt"/>
+ <link field="org_unit" reltype="has_a" key="id" map="" class="aou"/>
</links>
</class>
<class id="ccs" controller="open-ils.cstore" oils_obj:fieldmapper="config::copy_status" oils_persist:tablename="config.copy_status">
@@ -1761,9 +1763,11 @@
<field name="usr" oils_obj:array_position="5" oils_persist:virtual="false" reporter:datatype="link"/>
<field name="staff" oils_obj:array_position="6" oils_persist:virtual="false" reporter:datatype="link"/>
<field name="standing_penalty" oils_obj:array_position="7" oils_persist:virtual="false" reporter:datatype="link"/>
+ <field name="org_unit" oils_obj:array_position="8" oils_persist:virtual="false" reporter:datatype="link"/>
</fields>
<links>
<link field="usr" reltype="has_a" key="id" map="" class="au"/>
+ <link field="org_unit" reltype="has_a" key="id" map="" class="aou"/>
<link field="staff" reltype="has_a" key="id" map="" class="au"/>
<link field="standing_penalty" reltype="has_a" key="id" map="" class="csp"/>
</links>
Modified: trunk/Open-ILS/src/sql/Pg/005.schema.actors.sql
===================================================================
--- trunk/Open-ILS/src/sql/Pg/005.schema.actors.sql 2008-11-20 21:15:42 UTC (rev 11291)
+++ trunk/Open-ILS/src/sql/Pg/005.schema.actors.sql 2008-11-20 22:10:07 UTC (rev 11292)
@@ -144,36 +144,6 @@
);
CREATE INDEX actor_usr_note_usr_idx ON actor.usr_note (usr);
-CREATE TABLE actor.usr_standing_penalty (
- id SERIAL PRIMARY KEY,
- usr INT NOT NULL REFERENCES actor.usr (id) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED,
- standing_penalty INT NOT NULL REFERENCES config.standing_penalty (id) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED,
- staff INT REFERENCES actor.usr (id) ON DELETE SET NULL DEFERRABLE INITIALLY DEFERRED,
- set_date TIMESTAMP WITH TIME ZONE DEFAULT NOW()
-);
-COMMENT ON TABLE actor.usr_standing_penalty IS $$
-/*
- * Copyright (C) 2005-2008 Equinox Software, Inc. / Georgia Public Library Service
- * Mike Rylander <mrylander at gmail.com>
- *
- * User standing penalties
- *
- * ****
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- */
-$$;
-
-CREATE INDEX actor_usr_standing_penalty_usr_idx ON actor.usr_standing_penalty (usr);
-
CREATE TABLE actor.usr_setting (
id BIGSERIAL PRIMARY KEY,
usr INT NOT NULL REFERENCES actor.usr ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED,
@@ -517,4 +487,36 @@
SELECT SUBSTRING( $1, 1, 5);
$$ LANGUAGE SQL;
+CREATE TABLE actor.usr_standing_penalty (
+ id SERIAL PRIMARY KEY,
+ org_unit INT NOT NULL REFERENCES actor.org_unit (id) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED,
+ usr INT NOT NULL REFERENCES actor.usr (id) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED,
+ standing_penalty INT NOT NULL REFERENCES config.standing_penalty (id) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED,
+ staff INT REFERENCES actor.usr (id) ON DELETE SET NULL DEFERRABLE INITIALLY DEFERRED,
+ set_date TIMESTAMP WITH TIME ZONE DEFAULT NOW()
+);
+COMMENT ON TABLE actor.usr_standing_penalty IS $$
+/*
+ * Copyright (C) 2005-2008 Equinox Software, Inc. / Georgia Public Library Service
+ * Mike Rylander <mrylander at gmail.com>
+ *
+ * User standing penalties
+ *
+ * ****
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ */
+$$;
+
+CREATE INDEX actor_usr_standing_penalty_usr_idx ON actor.usr_standing_penalty (usr);
+
+
COMMIT;
Modified: trunk/Open-ILS/src/sql/Pg/006.schema.permissions.sql
===================================================================
--- trunk/Open-ILS/src/sql/Pg/006.schema.permissions.sql 2008-11-20 21:15:42 UTC (rev 11291)
+++ trunk/Open-ILS/src/sql/Pg/006.schema.permissions.sql 2008-11-20 22:10:07 UTC (rev 11292)
@@ -40,8 +40,9 @@
CREATE INDEX grp_tree_parent_idx ON permission.grp_tree (parent);
CREATE TABLE permission.grp_penalty_threshold (
- id SERIAL PRIMARY KEY,
+ id SERIAL PRIMARY KEY,
grp INT NOT NULL REFERENCES permission.grp_tree (id) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED,
+ org_unit INT NOT NULL REFERENCES actor.org_unit (id) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED,
penalty INT NOT NULL REFERENCES config.standing_penalty (id) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED,
threshold NUMERIC(8,2) NOT NULL,
CONSTRAINT penalty_grp_once UNIQUE (grp,penalty)
Modified: trunk/Open-ILS/src/sql/Pg/100.circ_matrix.sql
===================================================================
--- trunk/Open-ILS/src/sql/Pg/100.circ_matrix.sql 2008-11-20 21:15:42 UTC (rev 11291)
+++ trunk/Open-ILS/src/sql/Pg/100.circ_matrix.sql 2008-11-20 22:10:07 UTC (rev 11292)
@@ -301,7 +301,7 @@
SELECT INTO circ_test * from config.circ_matrix_test WHERE matchpoint = result.matchpoint;
IF circ_test.org_depth IS NOT NULL THEN
- SELECT INTO overdue_orgs ARRAY_ACCUM(id) FROM actor.org_unit_descendants( circ_ou, circ_test.org_depth );
+ SELECT INTO overdue_orgs ARRAY_ACCUM(id) FROM actor.org_unit_full_path( circ_ou, circ_test.org_depth );
END IF;
-- Fail if we couldn't find a set of tests
@@ -324,6 +324,7 @@
FROM actor.usr_standing_penalty usp
JOIN config.standing_penalty csp ON (csp.id = usp.penalty)
WHERE usr = match_user
+ AND usp.org_unit IN ( SELECT * FROM explode_array(overdue_orgs) )
AND csp.block_list LIKE '%RENEW%';
IF patron_penalties > 0 THEN
@@ -339,6 +340,7 @@
FROM actor.usr_standing_penalty usp
JOIN config.standing_penalty csp ON (csp.id = usp.penalty)
WHERE usr = match_user
+ AND usp.org_unit IN ( SELECT * FROM explode_array(overdue_orgs) )
AND csp.block_list LIKE '%CIRC%';
IF patron_penalties > 0 THEN
@@ -406,8 +408,8 @@
AND due_date < NOW()
AND (stop_fines NOT IN ('LOST','CLAIMSRETURNED','LONGOVERDUE') OR stop_fines IS NULL);
IF items_overdue >= max_overdue THEN
- DELETE FROM actor.usr_standing_penalty WHERE usr = match_usr AND standing_penalty = 2;
- INSERT INTO actor.usr_standing_penalty (usr, standing_penalty) VALUES (match_usr, 2);
+ DELETE FROM actor.usr_standing_penalty WHERE usr = match_usr AND standing_penalty = 2 AND org_unit = circ_ou;
+ INSERT INTO actor.usr_standing_penalty (usr, standing_penalty, org_unit) VALUES (match_usr, 2, circ_ou);
result.fail_part := 'config.circ_matrix_test.max_overdue';
result.success := FALSE;
done := TRUE;
@@ -446,8 +448,8 @@
END LOOP;
IF current_fines >= max_fines THEN
- DELETE FROM actor.usr_standing_penalty WHERE usr = match_usr AND standing_penalty = 1;
- INSERT INTO actor.usr_standing_penalty (usr, standing_penalty) VALUES (match_usr, 1);
+ DELETE FROM actor.usr_standing_penalty WHERE usr = match_usr AND standing_penalty = 1 AND org_unit = circ_ou;
+ INSERT INTO actor.usr_standing_penalty (usr, standing_penalty, org_unit) VALUES (match_usr, 1, circ_ou);
result.fail_part := 'config.circ_matrix_test.max_fines';
result.success := FALSE;
RETURN NEXT result;
Modified: trunk/Open-ILS/src/sql/Pg/950.data.seed-values.sql
===================================================================
--- trunk/Open-ILS/src/sql/Pg/950.data.seed-values.sql 2008-11-20 21:15:42 UTC (rev 11291)
+++ trunk/Open-ILS/src/sql/Pg/950.data.seed-values.sql 2008-11-20 22:10:07 UTC (rev 11292)
@@ -1293,12 +1293,12 @@
SELECT SETVAL('permission.grp_tree_id_seq'::TEXT, (SELECT MAX(id) FROM permission.grp_tree));
-INSERT INTO permission.grp_penalty_threshold (grp,penalty,threshold)
- VALUES (1,1,10.0);
-INSERT INTO permission.grp_penalty_threshold (grp,penalty,threshold)
- VALUES (1,2,10.0);
+INSERT INTO permission.grp_penalty_threshold (grp,org_unit,penalty,threshold)
+ VALUES (1,1,1,10.0);
+INSERT INTO permission.grp_penalty_threshold (grp,org_unit,penalty,threshold)
+ VALUES (1,1,2,10.0);
-SELECT SETVAL('permission.grp_tree_id_seq'::TEXT, (SELECT MAX(id) FROM permission.grp_tree));
+SELECT SETVAL('permission.grp_penalty_threshold_id_seq'::TEXT, (SELECT MAX(id) FROM permission.grp_penalty_threshold));
-- XXX Incomplete base permission setup. A patch would be appreciated.
INSERT INTO permission.grp_perm_map VALUES (57, 2, 15, 0, false);
More information about the open-ils-commits
mailing list