aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorubq323 <ubq323>2021-07-07 23:23:25 +0000
committerubq323 <ubq323>2021-07-07 23:23:25 +0000
commit13ef3cb6d3f25bcf4d3413b69cccc6f3117effd4 (patch)
treec9288d1da0cb8e4f534ed6e8fc16adb11b39cbfe
parent4bb33e0c18b45ae0cc0f87438c8e0432cf6250c1 (diff)
role permissions table
-rw-r--r--apioforum/db.py27
1 files changed, 26 insertions, 1 deletions
diff --git a/apioforum/db.py b/apioforum/db.py
index 7dd635e..10b2c24 100644
--- a/apioforum/db.py
+++ b/apioforum/db.py
@@ -117,7 +117,32 @@ CREATE VIEW most_recent_posts AS
CREATE VIEW number_of_posts AS
SELECT thread, count(*) AS num_replies FROM posts GROUP BY thread;
""",
-
+# 0 = inherit, 1 = allow, -1 = deny
+"""
+CREATE TABLE roles (
+ id INTEGER PRIMARY KEY,
+ name TEXT NOT NULL,
+ forum INTEGER NOT NULL REFERENCES forums(id),
+
+ p_create_threads INT NOT NULL DEFAULT 0,
+ p_reply_threads INT NOT NULL DEFAULT 0,
+ p_view_threads INT NOT NULL DEFAULT 0,
+ p_manage_threads INT NOT NULL DEFAULT 0,
+ p_vote INT NOT NULL DEFAULT 0,
+ p_create_polls INT NOT NULL DEFAULT 0,
+ p_approve INT NOT NULL DEFAULT 0,
+ p_create_subforums INT NOT NULL DEFAULT 0,
+
+);
+
+INSERT INTO roles (name,forum) SELECT 'approved',id FROM forums;
+INSERT INTO roles (name,forum) SELECT 'other',id FROM forums;
+
+CREATE TRIGGER default_roles AFTER INSERT ON forums BEGIN
+ INSERT INTO roles (role,forum) VALUES ('approved',new.id);
+ INSERT INTO roles (role,forum) VALUES ('other',new.id);
+END;
+""",
]
def init_db():