s/subforum/forum
This commit is contained in:
17
db/sqlite.py
17
db/sqlite.py
@@ -5,10 +5,10 @@ class DB:
|
|||||||
self.conn = conn
|
self.conn = conn
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def get_subforums(self):
|
def get_forums(self):
|
||||||
return self._db().execute('''
|
return self._db().execute('''
|
||||||
select f.forum_id, name, description, thread_id, title, update_time
|
select f.forum_id, name, description, thread_id, title, update_time
|
||||||
from subforums f
|
from forums f
|
||||||
left join threads t
|
left join threads t
|
||||||
on t.thread_id = (
|
on t.thread_id = (
|
||||||
select tt.thread_id
|
select tt.thread_id
|
||||||
@@ -20,23 +20,23 @@ class DB:
|
|||||||
'''
|
'''
|
||||||
)
|
)
|
||||||
|
|
||||||
def get_subforum(self, subforum):
|
def get_forum(self, forum_id):
|
||||||
return self._db().execute('''
|
return self._db().execute('''
|
||||||
select name, description
|
select name, description
|
||||||
from subforums
|
from forums
|
||||||
where forum_id = ?
|
where forum_id = ?
|
||||||
''',
|
''',
|
||||||
(subforum,)
|
(forum_id,)
|
||||||
).fetchone()
|
).fetchone()
|
||||||
|
|
||||||
def get_threads(self, subforum):
|
def get_threads(self, forum_id):
|
||||||
return self._db().execute('''
|
return self._db().execute('''
|
||||||
select t.thread_id, title, t.create_time, t.update_time, t.author_id, name, count(1)
|
select t.thread_id, title, t.create_time, t.update_time, t.author_id, name, count(1)
|
||||||
from threads t, users, comments c
|
from threads t, users, comments c
|
||||||
where forum_id = ? and user_id = t.author_id and t.thread_id = c.thread_id
|
where forum_id = ? and user_id = t.author_id and t.thread_id = c.thread_id
|
||||||
group by t.thread_id
|
group by t.thread_id
|
||||||
''',
|
''',
|
||||||
(subforum,)
|
(forum_id,)
|
||||||
)
|
)
|
||||||
|
|
||||||
def get_thread(self, thread):
|
def get_thread(self, thread):
|
||||||
@@ -191,10 +191,11 @@ class DB:
|
|||||||
(thread_id, author_id, text, time, time, thread_id)
|
(thread_id, author_id, text, time, time, thread_id)
|
||||||
)
|
)
|
||||||
if c.rowcount > 0:
|
if c.rowcount > 0:
|
||||||
|
print('SHIT')
|
||||||
c.execute('''
|
c.execute('''
|
||||||
update threads
|
update threads
|
||||||
set update_time = ?
|
set update_time = ?
|
||||||
where threads.thread_id = ?
|
where thread_id = ?
|
||||||
''',
|
''',
|
||||||
(time, thread_id)
|
(time, thread_id)
|
||||||
)
|
)
|
||||||
|
|||||||
8
main.py
8
main.py
@@ -14,14 +14,14 @@ app.config['SECRET_KEY'] = 'totally random'
|
|||||||
|
|
||||||
@app.route('/')
|
@app.route('/')
|
||||||
def index():
|
def index():
|
||||||
return render_template('index.html', title = NAME, subforums = db.get_subforums())
|
return render_template('index.html', title = NAME, forums = db.get_forums())
|
||||||
|
|
||||||
@app.route('/forum/<int:forum_id>/')
|
@app.route('/forum/<int:forum_id>/')
|
||||||
def subforum(forum_id):
|
def forum(forum_id):
|
||||||
title, description = db.get_subforum(forum_id)
|
title, description = db.get_forum(forum_id)
|
||||||
threads = db.get_threads(forum_id)
|
threads = db.get_threads(forum_id)
|
||||||
return render_template(
|
return render_template(
|
||||||
'subforum.html',
|
'forum.html',
|
||||||
title = title,
|
title = title,
|
||||||
forum_id = forum_id,
|
forum_id = forum_id,
|
||||||
description = description,
|
description = description,
|
||||||
|
|||||||
@@ -33,7 +33,7 @@ create table comments (
|
|||||||
dead boolean not null default false
|
dead boolean not null default false
|
||||||
);
|
);
|
||||||
|
|
||||||
create table subforums (
|
create table forums (
|
||||||
forum_id integer unique not null primary key autoincrement,
|
forum_id integer unique not null primary key autoincrement,
|
||||||
name varchar(64) not null,
|
name varchar(64) not null,
|
||||||
description text,
|
description text,
|
||||||
|
|||||||
@@ -6,10 +6,10 @@
|
|||||||
<th>Forum</th>
|
<th>Forum</th>
|
||||||
<th>Last update</th>
|
<th>Last update</th>
|
||||||
</tr>
|
</tr>
|
||||||
{% for id, name, description, t_id, t_title, t_mtime in subforums %}
|
{% for id, name, description, t_id, t_title, t_mtime in forums %}
|
||||||
<tr>
|
<tr>
|
||||||
<td>
|
<td>
|
||||||
<p><a href="{{ url_for('subforum', forum_id = id) }}"><b>{{ name }}</b></a></p>
|
<p><a href="{{ url_for('forum', forum_id = id) }}"><b>{{ name }}</b></a></p>
|
||||||
<p>{{ description }}</p>
|
<p>{{ description }}</p>
|
||||||
</td>
|
</td>
|
||||||
{% if t_id %}
|
{% if t_id %}
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ insert into users (name, password) values (
|
|||||||
"$argon2id$v=19$m=65536,t=3,p=4$9v5fS2ktxTinNEbIGUOoFQ$LMdEuAuuTCJ7utOE88+nXn7o6R/DEKY8ZA6wV+YkVGQ"
|
"$argon2id$v=19$m=65536,t=3,p=4$9v5fS2ktxTinNEbIGUOoFQ$LMdEuAuuTCJ7utOE88+nXn7o6R/DEKY8ZA6wV+YkVGQ"
|
||||||
);
|
);
|
||||||
|
|
||||||
insert into subforums (name, description, allowed_roles_mask)
|
insert into forums (name, description, allowed_roles_mask)
|
||||||
values ("Earth", "The totality of all space and time; all that is, has been, and will be.", 1);
|
values ("Earth", "The totality of all space and time; all that is, has been, and will be.", 1);
|
||||||
|
|
||||||
insert into threads (author_id, forum_id, create_time, modify_time, update_time, title, text)
|
insert into threads (author_id, forum_id, create_time, modify_time, update_time, title, text)
|
||||||
|
|||||||
Reference in New Issue
Block a user