diff --git a/SE_API/MessageRoutes.py b/SE_API/MessageRoutes.py index a360da7..5942b85 100644 --- a/SE_API/MessageRoutes.py +++ b/SE_API/MessageRoutes.py @@ -1,3 +1,5 @@ +import copy + __author__ = 'Aran' from flask import Blueprint @@ -245,9 +247,11 @@ def getAllUserMessages(token): arr = [] - query = Message.all() - query.filter('isProject =', False) - for m in query.run(): + allMsgs = Message.all() + projectMsgs = copy.deepcopy(allMsgs) + + projectMsgs.filter('isProject =', False) + for m in projectMsgs.run(): if str(m.groupId) in user.courses_id_list: msgDic = dict(json.loads(m.to_JSON())) #add a key 'forSortDate' for sorting dates @@ -255,9 +259,9 @@ def getAllUserMessages(token): msgDic['forSortDate'] = msgTime arr.append(msgDic) - query = Message.all() - query.filter('isProject =', True) - for m in query.run(): + + allMsgs.filter('isProject =', True) + for m in allMsgs.run(): if str(m.groupId) in user.projects_id_list: msgDic = dict(json.loads(m.to_JSON())) #add a key 'forSortDate' for sorting dates