This commit is contained in:
NikolajDanger
2022-05-24 15:49:39 +02:00
parent 4122fb57aa
commit 57efc8bd32
2 changed files with 12 additions and 3 deletions

View File

@ -11,12 +11,10 @@ Login = Blueprint('Login', __name__)
@Login.route("/")
@Login.route("/home")
def home():
print(current_user.is_authenticated)
if current_user.is_authenticated:
posts = get_posts_for_user(current_user.get_id())
else:
posts = []
print(posts)
return render_template('home.html', posts=posts)

View File

@ -112,4 +112,15 @@ def select_users_by_email(email):
return user
def get_posts_for_user(user_id):
return []
cur = conn.cursor()
sql_call = """
SELECT * FROM posts
WHERE group_id in (
SELECT group_id FROM users_groups
WHERE user_id = %s
)
"""
cur.execute(sql_call, (user_id,))
user = [Post(i) for i in cur.fetchmany(50)] if cur.rowcount > 0 else []
cur.close()
return user