From 662f3ed89a2a179deaa253f1211a6ce685e40d2d Mon Sep 17 00:00:00 2001 From: "tangshuangpku@hotmail.com" Date: Mon, 6 Jun 2016 19:44:45 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E6=96=B0=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/notificationmgr.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/notificationmgr.py b/src/notificationmgr.py index 8a55f83..6d7d744 100644 --- a/src/notificationmgr.py +++ b/src/notificationmgr.py @@ -1,3 +1,5 @@ +import json + from log import logger from model import db, Notification, NotificationGroups from userManager import administration_required @@ -20,13 +22,14 @@ class NotificationMgr: def create_notification(self, *args, **kwargs): ''' Usage: createNotification(cur_user = 'Your current user', form = 'Post form') - Post form: {title: 'Your title', content: 'Your content', groups: ['groupA', 'groupB']} + Post form: {title: 'Your title', content: 'Your content', groups: "['groupA', 'groupB']"} ''' form = kwargs['form'] notify = Notification(form['title'], form['content']) db.session.add(notify) db.session.commit() - for group_name in form['groups']: + groups = json.loads(form['groups']) + for group_name in groups: notify_groups = NotificationGroups(notify.id, group_name) db.session.add(notify_groups) db.session.commit()