liquid_feedback_core
diff update/core-update.v2.0.11-v2.1.0.sql @ 290:2301a1f2acfa
Modified function "forbid_changes_on_closed_issue_trigger" to allow voting comments to be changed after voting has finished
author | jbe |
---|---|
date | Sun Aug 19 23:37:37 2012 +0200 (2012-08-19) |
parents | f2292b94fc58 |
children | 86f231bd6906 |
line diff
1.1 --- a/update/core-update.v2.0.11-v2.1.0.sql Sun Aug 19 23:32:26 2012 +0200 1.2 +++ b/update/core-update.v2.0.11-v2.1.0.sql Sun Aug 19 23:37:37 2012 +0200 1.3 @@ -161,6 +161,36 @@ 1.4 COMMENT ON FUNCTION "voter_comment_fields_only_set_when_voter_comment_is_set_trigger"() IS 'Implementation of trigger "voter_comment_fields_only_set_when_voter_comment_is_set" ON table "direct_voter"'; 1.5 COMMENT ON TRIGGER "voter_comment_fields_only_set_when_voter_comment_is_set" ON "direct_voter" IS 'If "comment" is set to NULL, then other comment related fields are also set to NULL.'; 1.6 1.7 +CREATE OR REPLACE FUNCTION "forbid_changes_on_closed_issue_trigger"() 1.8 + RETURNS TRIGGER 1.9 + LANGUAGE 'plpgsql' VOLATILE AS $$ 1.10 + DECLARE 1.11 + "issue_id_v" "issue"."id"%TYPE; 1.12 + "issue_row" "issue"%ROWTYPE; 1.13 + BEGIN 1.14 + IF TG_RELID = 'direct_voter'::regclass AND TG_OP = 'UPDATE' THEN 1.15 + IF 1.16 + OLD."issue_id" = NEW."issue_id" AND 1.17 + OLD."member_id" = NEW."member_id" AND 1.18 + OLD."weight" = NEW."weight" 1.19 + THEN 1.20 + RETURN NULL; -- allows changing of voter comment 1.21 + END IF; 1.22 + END IF; 1.23 + IF TG_OP = 'DELETE' THEN 1.24 + "issue_id_v" := OLD."issue_id"; 1.25 + ELSE 1.26 + "issue_id_v" := NEW."issue_id"; 1.27 + END IF; 1.28 + SELECT INTO "issue_row" * FROM "issue" 1.29 + WHERE "id" = "issue_id_v" FOR SHARE; 1.30 + IF "issue_row"."closed" NOTNULL THEN 1.31 + RAISE EXCEPTION 'Tried to modify data belonging to a closed issue.'; 1.32 + END IF; 1.33 + RETURN NULL; 1.34 + END; 1.35 + $$; 1.36 + 1.37 CREATE OR REPLACE FUNCTION "close_voting"("issue_id_p" "issue"."id"%TYPE) 1.38 RETURNS VOID 1.39 LANGUAGE 'plpgsql' VOLATILE AS $$