API: Messages now will return with the User in them

This commit is contained in:
Sagi Dayan 2015-07-02 20:38:08 +03:00
parent c13b726cbb
commit 569205957c
2 changed files with 18 additions and 2 deletions

View file

@ -143,7 +143,20 @@ def getMessagesByGroup(token, groupId):
},<br>
'id' : 1234567890,<br>
'master_id' : 1234567890,<br>
'isProject' : false<br>
'isProject' : false,<br>
'user': {<br>
'username': 'DarkLord',<br>
'name': 'Darth Vader',<br>
'email': 'darkLord@death.planet,<br>
'isLecturer': 'True',<br>
'seToken': 'xxxxxx-xxxxx-xxxxx-xxxxxx',<br>
'avatar_url': 'http://location.git.com/somthing'<br>
'isFirstLogin': False,<br>
'campuses_id_list': [43243532532,5325325325,532532342],<br>
'courses_id_list': [53523,43432423,432432432432]<br>
'id': 1234567890 <br>
}<br>
}<br>
</code>
<br>

View file

@ -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)