forked from itucsdb1515/itucsdb1515
-
Notifications
You must be signed in to change notification settings - Fork 2
/
notifications.py
31 lines (26 loc) · 1.23 KB
/
notifications.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
import os
import psycopg2
from flask import Flask
from flask import render_template, request
from flask import Blueprint, current_app
#declaring sub app with blueprint
notific_app = Blueprint('notific_app', __name__)
@notific_app.route('/notification_delete/<id>')
def notification_delete(id):
with psycopg2.connect(current_app.config['dsn']) as conn:
crs=conn.cursor()
crs.execute("delete from notifications where notification_id = %s", (id))
data = conn.commit()
return render_template('message.html', message = "Notification deleted..")
@notific_app.route('/status_update/', methods = ['GET'])
def status_update():
id = request.args.get('id')
stat = request.args.get('status')
with psycopg2.connect(current_app.config['dsn']) as conn:
crs=conn.cursor()
if stat == "False":
crs.execute("update notifications set read_status = TRUE where notification_id = %s", (id))
elif stat == "True":
crs.execute("update notifications set read_status = FALSE where notification_id = %s", (id))
data = conn.commit()
return render_template('message.html', message = "Notification status updated..")