From d2f67a94c256a0e93ed29164294b596859d05b09 Mon Sep 17 00:00:00 2001 From: Shefali_Upadhyaya Date: Sun, 6 Aug 2023 12:08:20 -0400 Subject: [PATCH] Issue #50 - Select notification logic from the database for a user --- run.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/run.py b/run.py index b7410c4..9626095 100644 --- a/run.py +++ b/run.py @@ -93,6 +93,18 @@ def delete_user(username): return redirect(url_for('home')) +@app.route('/notifications') +def notifications(): + db = Database().db + cursor = db.cursor() + cursor.execute(f"select * from notifications where username= '{session['username']}' and seen=0;") + db.commit() + item = [dict(keyid=row[0],alert = row[2]) for row in cursor.fetchall()] + # cursor.execute("update user set is_admin=1 where username='" + username + "';") + cursor.execute(f"update notifications set seen=1 where username= '{session['username']}' and seen=0;") + db.commit() + return render_template('notifications.html',session=session,items=item) + # Suspend user from admin panel @app.route('/suspend-user/') def suspend_user(username):