custom code, fix thread and comment deletions

This commit is contained in:
Ville Rantanen
2023-07-30 10:07:37 +03:00
parent 7fe10f05a2
commit da15d163e2
4 changed files with 33 additions and 54 deletions

View File

@@ -7,17 +7,6 @@ class DB:
self.conn = conn
pass
# ~ def get_config(self):
# ~ return (
# ~ self._db()
# ~ .execute(
# ~ """
# ~ select version, name, description, secret_key, captcha_key, registration_enabled, login_required from config
# ~ """
# ~ )
# ~ .fetchone()
# ~ )
def get_forums(self):
return self._db().execute(
"""
@@ -205,6 +194,21 @@ class DB:
.fetchone()
)
def get_comment_thread(self, comment_id):
""" Get the thread of a comment """
return (
self._db()
.execute(
"""
select thread_id
from comments
where comment_id = ?
""",
(comment_id,),
)
.fetchone()[0]
)
def get_subcomments(self, comment_id):
db = self._db()
thread_id, parent_id, title = db.execute(
@@ -628,26 +632,6 @@ class DB:
)
db.commit()
# ~ def set_config(
# ~ self, server_name, server_description, registration_enabled, login_required
# ~ ):
# ~ return self.change_one(
# ~ """
# ~ update config
# ~ set name = ?, description = ?, registration_enabled = ?, login_required = ?
# ~ """,
# ~ (server_name, server_description, registration_enabled, login_required),
# ~ )
# ~ def set_config_secrets(self, secret_key, captcha_key):
# ~ return self.change_one(
# ~ """
# ~ update config
# ~ set secret_key = ?, captcha_key = ?
# ~ """,
# ~ (secret_key, captcha_key),
# ~ )
def set_user_ban(self, user_id, until):
return self.change_one(
"""