2015-06-10 18:39:42 +00:00
|
|
|
import json
|
|
|
|
|
|
|
|
__author__ = 'Aran'
|
|
|
|
from google.appengine.ext import db
|
2015-06-29 18:48:28 +00:00
|
|
|
from models.User import User
|
2015-06-10 18:39:42 +00:00
|
|
|
|
|
|
|
class Project(db.Model):
|
|
|
|
projectName = db.StringProperty(required=True)
|
2015-06-28 13:48:01 +00:00
|
|
|
courseId = db.IntegerProperty(required=True)
|
2015-06-15 13:32:35 +00:00
|
|
|
master_id = db.IntegerProperty(required=True)
|
2015-06-14 22:35:18 +00:00
|
|
|
grade = db.IntegerProperty(required=True, default=0)
|
2015-07-02 14:29:35 +00:00
|
|
|
logo_url = db.StringProperty(required=False, default=None)
|
2015-06-10 18:39:42 +00:00
|
|
|
gitRepository = db.StringProperty(required=True)
|
|
|
|
membersId = db.StringListProperty(required=True)
|
2015-06-29 16:21:18 +00:00
|
|
|
info = db.TextProperty(required=False, default="{}")
|
2015-06-10 18:39:42 +00:00
|
|
|
|
|
|
|
def to_JSON(self):
|
2015-06-29 18:48:28 +00:00
|
|
|
members = []
|
|
|
|
for id in self.membersId:
|
|
|
|
members.append(dict(json.loads(User.get_by_id(int(id)).to_JSON())))
|
2015-06-10 18:39:42 +00:00
|
|
|
data = {'projectName' : self.projectName,
|
2015-06-28 13:48:01 +00:00
|
|
|
'courseId' : self.courseId,
|
2015-06-15 13:32:35 +00:00
|
|
|
'master_id' : self.master_id,
|
2015-06-10 18:39:42 +00:00
|
|
|
'grade' : self.grade,
|
|
|
|
'logo_url' : self.logo_url,
|
|
|
|
'gitRepository' : self.gitRepository,
|
2015-06-29 18:48:28 +00:00
|
|
|
'members': members,
|
2015-06-29 16:21:18 +00:00
|
|
|
'info': json.loads(self.info),
|
2015-06-29 18:48:28 +00:00
|
|
|
'id': self.key().id()
|
2015-06-10 18:39:42 +00:00
|
|
|
}
|
|
|
|
return json.dumps(data)
|