Allow editing threads

This commit is contained in:
David Hoppenbrouwers
2022-10-08 13:34:09 +02:00
parent 6299a9e1fb
commit 47f92b2d83
4 changed files with 70 additions and 0 deletions

View File

@@ -67,6 +67,15 @@ class DB:
(thread_id,)
).fetchone()
def get_thread_title_text(self, thread_id):
return self._db().execute('''
select title, text
from threads
where thread_id = ?
''',
(thread_id,)
).fetchone()
def get_recent_threads(self, limit):
return self._db().execute('''
select thread_id, title, modify_date
@@ -244,5 +253,20 @@ class DB:
return True
return False
def modify_thread(self, thread_id, user_id, title, text, time):
db = self._db()
c = db.cursor()
c.execute('''
update threads
set title = ?, text = ?, modify_time = ?
where thread_id = ? and author_id = ?
''',
(title, text, time, thread_id, user_id)
)
if c.rowcount > 0:
db.commit()
return True
return False
def _db(self):
return sqlite3.connect(self.conn)