From 4cbc66d9aa285a476da89685e8b4f5fe98bb0ed0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lera=20Elvo=C3=A9?= Date: Fri, 4 Jul 2025 17:35:17 +0300 Subject: [PATCH] make sure form doesn't make it possible to post to locked topic --- app/models.py | 12 ++++++++++++ app/templates/threads/create.html | 3 ++- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/app/models.py b/app/models.py index 2c99430..9a179b1 100644 --- a/app/models.py +++ b/app/models.py @@ -71,6 +71,18 @@ class Users(Model): subscriptions.user_id = ?""" return db.query(q, self.id) + def can_post_to_topic(self, topic): + if self.is_guest(): + return False + + if self.is_mod(): + return True + + if topic['is_locked']: + return False + + return True + class Topics(Model): table = "topics" diff --git a/app/templates/threads/create.html b/app/templates/threads/create.html index 85c9e1a..d1950b2 100644 --- a/app/templates/threads/create.html +++ b/app/templates/threads/create.html @@ -8,7 +8,8 @@