API: Messages now will return with the Group associated
This commit is contained in:
parent
569205957c
commit
604c19af19
2 changed files with 10 additions and 2 deletions
|
@ -155,7 +155,8 @@ def getMessagesByGroup(token, groupId):
|
||||||
'campuses_id_list': [43243532532,5325325325,532532342],<br>
|
'campuses_id_list': [43243532532,5325325325,532532342],<br>
|
||||||
'courses_id_list': [53523,43432423,432432432432]<br>
|
'courses_id_list': [53523,43432423,432432432432]<br>
|
||||||
'id': 1234567890 <br>
|
'id': 1234567890 <br>
|
||||||
}<br>
|
},<br>
|
||||||
|
'group': {The Group Object Project OR Campus (according to isProject)}<br><br>
|
||||||
|
|
||||||
}<br>
|
}<br>
|
||||||
</code>
|
</code>
|
||||||
|
|
|
@ -3,6 +3,8 @@ import json
|
||||||
__author__ = 'Aran'
|
__author__ = 'Aran'
|
||||||
from google.appengine.ext import db
|
from google.appengine.ext import db
|
||||||
from models.User import User
|
from models.User import User
|
||||||
|
from models.Project import Project
|
||||||
|
from models.Course import Course
|
||||||
|
|
||||||
class Message(db.Model):
|
class Message(db.Model):
|
||||||
groupId = db.IntegerProperty(required=True)
|
groupId = db.IntegerProperty(required=True)
|
||||||
|
@ -13,6 +15,10 @@ class Message(db.Model):
|
||||||
|
|
||||||
def to_JSON(self):
|
def to_JSON(self):
|
||||||
user = User.get_by_id(self.master_id)
|
user = User.get_by_id(self.master_id)
|
||||||
|
if self.isProject:
|
||||||
|
group = Project.get_by_id(self.groupId)
|
||||||
|
else:
|
||||||
|
group = Course.get_by_id(self.groupId)
|
||||||
data = {
|
data = {
|
||||||
'groupId' : self.groupId,
|
'groupId' : self.groupId,
|
||||||
'message' : self.message,
|
'message' : self.message,
|
||||||
|
@ -26,6 +32,7 @@ class Message(db.Model):
|
||||||
'id' : self.key().id(),
|
'id' : self.key().id(),
|
||||||
'master_id' : self.master_id,
|
'master_id' : self.master_id,
|
||||||
'isProject' : self.isProject,
|
'isProject' : self.isProject,
|
||||||
'user': json.loads(user.to_JSON())
|
'user': json.loads(user.to_JSON()),
|
||||||
|
'group': json.loads(group.to_JSON())
|
||||||
}
|
}
|
||||||
return json.dumps(data)
|
return json.dumps(data)
|
||||||
|
|
Loading…
Reference in a new issue