-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy paththreads.py
More file actions
23 lines (18 loc) · 818 Bytes
/
threads.py
File metadata and controls
23 lines (18 loc) · 818 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
from flask import Flask
from flask import redirect, render_template, request, session
from werkzeug.security import check_password_hash, generate_password_hash
from os import getenv
from flask_sqlalchemy import SQLAlchemy
from db import db
from app import app
import messages, users
def thread_id ():
return session["thread"]
def show_thread():
list = messages.get_list()
return render_template("thread.html", count=len(list), messages=list, user_id=session["user_id"], admin = users.is_admin())
def fetch_category_threads(category_id):
sql = "SELECT T.id, T.title, T.created_at, T.private, T.user_id FROM threads T, " \
"categories C WHERE T.category_id = C.id AND C.id = :category_id"
result = db.session.execute(sql, {"category_id":category_id})
return result.fetchall()