From 569205957c8682ae6d051de1428a1ffa853ba4c2 Mon Sep 17 00:00:00 2001 From: Sagi Dayan Date: Thu, 2 Jul 2015 20:38:08 +0300 Subject: [PATCH] API: Messages now will return with the User in them --- SE_API/MessageRoutes.py | 15 ++++++++++++++- models/Message.py | 5 ++++- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/SE_API/MessageRoutes.py b/SE_API/MessageRoutes.py index 6a3204b..8a18726 100644 --- a/SE_API/MessageRoutes.py +++ b/SE_API/MessageRoutes.py @@ -143,7 +143,20 @@ def getMessagesByGroup(token, groupId): },
'id' : 1234567890,
'master_id' : 1234567890,
- 'isProject' : false
+ 'isProject' : false,
+ 'user': {
+ 'username': 'DarkLord',
+ 'name': 'Darth Vader',
+ 'email': 'darkLord@death.planet,
+ 'isLecturer': 'True',
+ 'seToken': 'xxxxxx-xxxxx-xxxxx-xxxxxx',
+ 'avatar_url': 'http://location.git.com/somthing'
+ 'isFirstLogin': False,
+ 'campuses_id_list': [43243532532,5325325325,532532342],
+ 'courses_id_list': [53523,43432423,432432432432]
+ 'id': 1234567890
+ }
+ }

diff --git a/models/Message.py b/models/Message.py index 23019e9..8563174 100644 --- a/models/Message.py +++ b/models/Message.py @@ -2,6 +2,7 @@ import json __author__ = 'Aran' from google.appengine.ext import db +from models.User import User class Message(db.Model): groupId = db.IntegerProperty(required=True) @@ -11,6 +12,7 @@ class Message(db.Model): isProject = db.BooleanProperty(default=False) def to_JSON(self): + user = User.get_by_id(self.master_id) data = { 'groupId' : self.groupId, 'message' : self.message, @@ -23,6 +25,7 @@ class Message(db.Model): }, 'id' : self.key().id(), 'master_id' : self.master_id, - 'isProject' : self.isProject + 'isProject' : self.isProject, + 'user': json.loads(user.to_JSON()) } return json.dumps(data)