se-hub/models/Campus.py

36 lines
1.1 KiB
Python
Raw Normal View History

__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=[])
def to_JSON(self):
data = {'title': self.title,
'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()
}
return json.dumps(data)
"""
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)