2015-06-10 10:12:59 +00:00
|
|
|
__author__ = 'sagi'
|
|
|
|
|
|
|
|
import json
|
|
|
|
|
|
|
|
from google.appengine.ext import db
|
|
|
|
|
|
|
|
class Campus(db.Model):
|
|
|
|
title = db.StringProperty(required=True)
|
|
|
|
avatar_url = db.StringProperty(required=True)
|
|
|
|
email_ending = db.StringProperty(required=True)
|
|
|
|
master_user_id = db.IntegerProperty(required=True)
|
2015-06-28 14:53:37 +00:00
|
|
|
membersId = db.StringListProperty(required=True, default=[])
|
|
|
|
|
2015-06-10 10:12:59 +00:00
|
|
|
|
|
|
|
def to_JSON(self):
|
2015-06-11 18:01:05 +00:00
|
|
|
data = {'title': self.title,
|
2015-06-10 10:12:59 +00:00
|
|
|
'email_ending': self.email_ending,
|
|
|
|
'master_user_id': self.master_user_id,
|
2015-06-21 22:38:01 +00:00
|
|
|
'avatar_url': self.avatar_url,
|
2015-06-28 14:53:37 +00:00
|
|
|
'membersId': self.membersId,
|
2015-06-21 22:38:01 +00:00
|
|
|
'id' : self.key().id()
|
2015-06-10 10:12:59 +00:00
|
|
|
}
|
2015-06-11 18:01:05 +00:00
|
|
|
return json.dumps(data)
|
2015-06-10 10:12:59 +00:00
|
|
|
|
|
|
|
|
|
|
|
"""
|
|
|
|
DEBUG Script - To create a campus:
|
2015-06-10 10:55:55 +00:00
|
|
|
"""
|
|
|
|
is_jce_in = False
|
|
|
|
query = Campus.all()
|
|
|
|
query.filter('title =', 'JCE')
|
|
|
|
for c in query.run():
|
|
|
|
is_jce_in = True
|
|
|
|
if not is_jce_in:
|
|
|
|
jce = Campus(title='JCE', email_ending='@post.jce.ac.il', master_user_id=111, avatar_url='https://yt3.ggpht.com/--ZkWxybWGOM/AAAAAAAAAAI/AAAAAAAAAAA/_nAICC_kzzI/s88-c-k-no/photo.jpg')
|
|
|
|
db.put(jce)
|