Alter asset.acp_status_changed() function for restrict_copy_delete.
authorJason Stephenson <jstephenson@mvlc.org>
Wed, 12 Oct 2011 14:50:53 +0000 (10:50 -0400)
committerJason Stephenson <jstephenson@mvlc.org>
Tue, 22 Nov 2011 14:27:53 +0000 (09:27 -0500)
Add a check for a change to the deleted field to true and then check
if the new status restricts copy deletion. If so, set the deleted
to FALSE in the NEW row.

Signed-off-by: Jason Stephenson <jstephenson@mvlc.org>
Open-ILS/src/sql/Pg/040.schema.asset.sql

index f80b2d1..30c62a3 100644 (file)
@@ -123,6 +123,11 @@ BEGIN
             NEW.active_date := now();
         END IF;
     END IF;
+    IF NEW.deleted <> OLD.deleted AND NEW.deleted = TRUE THEN
+        IF NEW.status IN (SELECT id FROM config.copy_status WHERE restrict_copy_delete = TRUE) THEN
+            NEW.deleted := FALSE;
+        END IF;
+    END IF;
     RETURN NEW;
 END;
 $$ LANGUAGE plpgsql;