Commit 8bae9d72 authored by Vladislav Rykov's avatar Vladislav Rykov
Browse files

notifications_queue removed+cleaned user&admin

parent 8d711652
......@@ -174,4 +174,13 @@ def get_recent_activity(cur, username, n=5):
else:
return (True, [])
@with_psql
def get_devices_locations(cur, username):
devlocs = {}
apps = ad.get_list(username)[1]
for a in apps:
devs = dd.get_list(a[1])[1]
print(devs)
from app.helpers.misc import with_psql
@with_psql
def create(cur, nid, appkey, devid):
query = """
INSERT INTO
notifications_queue
VALUES
(%s, %s, %s)
"""
cur.execute(query, (nid, appkey, devid))
return (True,)
@with_psql
def delete(cur, appkey, devid, nid):
query = """
DELETE FROM
notifications_queue
WHERE
nf_id = %s
AND
app_key = %s
AND
dev_id = %s
"""
cur.execute(query, (nid, appkey, devid))
return (True,)
@with_psql
def get(cur, appkey, devid, nid):
query = """
SELECT * FROM
notifications_queue
WHERE
nf_id = %s
AND
app_key = %s
AND
dev_id = %s
"""
cur.execute(query, (nid, appkey, devid))
nf = cur.fetchone()
if nf is None:
return (False, 'Queued notification with appkey {} and id {} does not exist'.format(appkey, nid))
else:
return (True, nf)
@with_psql
def delete_list(cur, appkey):
query = """
DELETE FROM
notifications_queue
WHERE
app_key = %s
"""
cur.execute(query, (appkey,))
return (True,)
@with_psql
def delete_per_device(cur, appkey, devid):
query = """
DELETE FROM
notifications_queue
WHERE
app_key = %s
AND
dev_id = %s
"""
cur.execute(query, (appkey, devid))
return (True,)
@with_psql
def get_all(cur):
query = """
SELECT * FROM
notifications_queue
"""
cur.execute(query)
return (True, cur.fetchall())
@with_psql
def get_count(cur):
query = """
SELECT COUNT(*) FROM
notifications_queue
"""
cur.execute(query, ())
return (True, cur.fetchone())
......@@ -8,7 +8,6 @@ import app.dao.pend.pend as pend
import app.dao.data.data as data
import app.dao.notification.notification as nfs
import app.dao.trigger.trigger as tr
import app.dao.notification_queue.notification_queue as nq
import app.dao.misc.misc as md
import app.helpers.misc as misc
......@@ -168,7 +167,6 @@ def application_delete(appkey):
for dev in devs[1]:
data.delete_table(appkey, dev[1])
# delete notifications
nq.delete_per_device(appkey, dev[1])
nfss = nfs.get_per_device(appkey, dev[1])
for nf in nfss[1]:
tr.delete(appkey, dev[1], nf[0])
......@@ -246,7 +244,6 @@ def application_add_device(appkey):
@decorators.restricted('user')
@decorators.application_protected
def application_device_delete(appkey, devid):
nq.delete_per_device(appkey, devid)
nfss = nfs.get_per_device(appkey, devid)
for nf in nfss[1]:
tr.delete(appkey, devid, nf[0])
......@@ -547,7 +544,6 @@ def application_new_alert(appkey):
@decorators.restricted('user')
@decorators.application_protected
def application_notification_remove(appkey, ntype):
nq.delete(appkey, request.args.get('devid'), request.args.get('id'))
tr.delete(appkey, request.args.get('devid'), request.args.get('id'))
tr.delete_function(appkey, request.args.get('devid'), request.args.get('id'))
res = nfs.delete(appkey, request.args.get('devid'), request.args.get('id'))
......
......@@ -9,7 +9,6 @@ import app.dao.pend.pend as pend
import app.dao.data.data as data
import app.dao.notification.notification as nfs
import app.dao.trigger.trigger as tr
import app.dao.notification_queue.notification_queue as nq
import app.dao.misc.misc as md
#import app.helpers.misc as misc
......@@ -204,7 +203,6 @@ def administration_user_application_device_settings(name, appkey, devid):
@app.route('/administration/<name>/application/<appkey>/device/<devid>/delete')
@restricted('admin', True)
def administration_user_application_device_delete(name, appkey, devid):
nq.delete_per_device(appkey, devid)
nfss = nfs.get_per_device(appkey, devid)
for nf in nfss[1]:
tr.delete(appkey, devid, nf[0])
......@@ -313,7 +311,6 @@ def administration_user_application_delete(name, appkey):
for dev in devs[1]:
data.delete_table(appkey, dev[1])
# delete notifications
nq.delete_per_device(appkey, dev[1])
nfss = nfs.get_per_device(appkey, dev[1])
for nf in nfss[1]:
tr.delete(appkey, dev[1], nf[0])
......@@ -363,7 +360,6 @@ def administration_user_application_settings(name, appkey):
@app.route('/administration/<name>/application/<appkey>/delete-<ntype>')
@restricted('admin', True)
def administration_user_application_notification_remove(name, appkey, ntype):
nq.delete(appkey, request.args.get('devid'), request.args.get('id'))
tr.delete(appkey, request.args.get('devid'), request.args.get('id'))
tr.delete_function(appkey, request.args.get('devid'), request.args.get('id'))
res = nfs.delete(appkey, request.args.get('devid'), request.args.get('id'))
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment