添加新接口

This commit is contained in:
tangshuangpku@hotmail.com 2016-06-07 02:06:41 +08:00
parent 9c5a6f8951
commit c167444707
3 changed files with 51 additions and 2 deletions

View File

@ -599,6 +599,16 @@ def create_notification(cur_user, user, form):
result = G_notificationmgr.create_notification(cur_user=cur_user, form=form) result = G_notificationmgr.create_notification(cur_user=cur_user, form=form)
return json.dumps(result) return json.dumps(result)
@app.route("/notification/query_self/", methods=['POST'])
@login_required
def query_self_notifications(cur_user, user, form):
global G_notificationmgr
logger.info("handle request: notification/query_self/")
result = G_notificationmgr.query_self_notifications(cur_user=cur_user, form=form)
return json.dumps(result)
@app.route("/system/parmList/", methods=['POST']) @app.route("/system/parmList/", methods=['POST'])
@login_required @login_required
def parmList_system(cur_user, user, form): def parmList_system(cur_user, user, form):

View File

@ -2,7 +2,7 @@ import json
from log import logger from log import logger
from model import db, Notification, NotificationGroups from model import db, Notification, NotificationGroups
from userManager import administration_required from userManager import administration_required, token_required
class NotificationMgr: class NotificationMgr:
@ -53,3 +53,23 @@ class NotificationMgr:
'groups': [group.group_name for group in groups] 'groups': [group.group_name for group in groups]
}) })
return {'success': 'true', 'data': notify_infos} return {'success': 'true', 'data': notify_infos}
@token_required
def query_self_notifications(self, *args, **kwargs):
user = kwargs['cur_user']
group_name = user.user_group
notifies = NotificationGroups.query.filter_by(group_name=group_name).all()
notifies.extend(NotificationGroups.query.filter_by(group_name='all').all())
notify_ids = [notify.notification_id for notify in notifies]
notify_ids = sorted(list(set(notify_ids)), reversed=True)
notify_simple_infos = []
for notify_id in notify_ids:
notify = Notification.query.filter_by(id=notify_id).first()
if notify.status != 'open':
continue
notify_simple_infos.append({
'id': notify.id,
'title': notify.title,
'create_date': notify.create_date
})
return {'success': 'true', 'data': notify_simple_infos}

View File

@ -55,7 +55,26 @@
<div class="navbar-custom-menu"> <div class="navbar-custom-menu">
<ul class="nav navbar-nav"> <ul class="nav navbar-nav">
<!-- Messages: style can be found in dropdown.less--> <!-- Messages: style can be found in dropdown.less-->
<li class="dropdown notifications-menu">
<a href="#" class="dropdown-toggle" data-toggle="dropdown">
<i class="fa fa-bell-o"></i>
<span class="label label-warning">0</span>
</a>
<ul class="dropdown-menu">
<li class="header">You have 10 notifications</li>
<li>
<!-- inner menu: contains the actual data -->
<ul class="menu">
<li>
<a href="#">
<i class="ion ion-ios-people info"></i> Notification title
</a>
</li>
</ul>
</li>
<li class="footer"><a href="#">View all</a></li>
</ul>
</li>
<li class="dropdown user user-menu"> <li class="dropdown user user-menu">
<!-- Menu Toggle Button --> <!-- Menu Toggle Button -->
<a href="#" class="dropdown-toggle" data-toggle="dropdown"> <a href="#" class="dropdown-toggle" data-toggle="dropdown">