Commit 4e8b255a authored by HERBERT Ryan's avatar HERBERT Ryan
Browse files

controllers/notifications.py views/notification/info.html deprecated index in...

controllers/notifications.py views/notification/info.html deprecated index in favour of more flexible info page
parent 66b4b0bd
...@@ -10,6 +10,7 @@ if request.env.http_origin: ...@@ -10,6 +10,7 @@ if request.env.http_origin:
ACCESS_DENIED = "access denied" ACCESS_DENIED = "access denied"
NOTIFICATION_CACHE_PREFIX = 'notification_' NOTIFICATION_CACHE_PREFIX = 'notification_'
# Deprecated
def index(): def index():
if not auth.is_admin() : if not auth.is_admin() :
res = {"message": ACCESS_DENIED} res = {"message": ACCESS_DENIED}
...@@ -23,7 +24,10 @@ def index(): ...@@ -23,7 +24,10 @@ def index():
def info(): def info():
user_id = auth.user.id if auth.user else None user_id = auth.user.id if auth.user else None
query = db.notification[request.vars['id']]
query = None
if request.vars['id']:
query = db.notification[request.vars['id']]
if auth.user: if auth.user:
rows = db((db.user_preference.user_id==auth.user.id) rows = db((db.user_preference.user_id==auth.user.id)
&(db.user_preference.preference=='mail') &(db.user_preference.preference=='mail')
...@@ -38,7 +42,8 @@ def info(): ...@@ -38,7 +42,8 @@ def info():
cache.ram.clear(regex=NOTIFICATION_CACHE_PREFIX + str(user_id)) cache.ram.clear(regex=NOTIFICATION_CACHE_PREFIX + str(user_id))
notifications = db(db.notification).select(orderby=~db.notification.id) notifications = db(db.notification).select(orderby=~db.notification.id)
return dict(query=query, return dict(message="Notifications",
query=query,
notifications=notifications) notifications=notifications)
# serve for to add a notification # serve for to add a notification
......
{{from gluon.contrib.markdown.markdown2 import markdown}} {{from gluon.contrib.markdown.markdown2 import markdown}}
{{extend 'db_layout.html'}} {{extend 'db_layout.html'}}
<h3>{{=query.title}}</h3> <h3>{{=query.title if query is not None else message}}</h3>
<div class="db_block info_block"> {{if query is not None:}}
{{=XML(markdown(query.message_content))}} <div class="db_block info_block">
</div> {{=XML(markdown(query.message_content))}}
</div>
{{pass}}
<div id="db_table_container" class="info_table"> <div id="db_table_container" {{if query is not None:}}class="info_table"{{pass}}>
<table class="db_table" id="table"> <table class="db_table" id="table">
<thead> <thead>
...@@ -60,3 +62,7 @@ ...@@ -60,3 +62,7 @@
</table> </table>
<table class="db_table" id="db_fixed_header"></table> <table class="db_table" id="db_fixed_header"></table>
</div> </div>
{{if auth.is_admin():}}
<span class="button2" onclick="db.call('notification/add')"> + new notification </span>
{{pass}}
Markdown is supported
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