Compare commits

...

2 Commits

Author SHA1 Message Date
12a76158ed Merge branch 'main' of git.ingemanngade.net:NikolajDanger/UIS_Prototype 2022-05-24 15:49:46 +02:00
57efc8bd32 2022-05-24 15:49:39 +02:00
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