API: Campus Hot Fix

This commit is contained in:
Sagi Dayan 2015-06-10 13:55:55 +03:00
parent 5bdcff7f51
commit 9698a5b4e2
2 changed files with 14 additions and 6 deletions

View file

@ -143,11 +143,12 @@ def get_campuses(token):
""" """
if is_user_token_valid(token): if is_user_token_valid(token):
arr = [] arr = []
query = User.all() query = Campus.all()
for c in query.run(): for c in query.run():
arr.append(c.to_JSON) arr.append(dict(json.loads(c.to_JSON())))
print arr
if len(arr) != 0: if len(arr) != 0:
return Response(response=json.dumps([]), return Response(response=json.dumps(arr),
status=200, status=200,
mimetype="application/json") mimetype="application/json")
else: else:

View file

@ -11,7 +11,7 @@ class Campus(db.Model):
master_user_id = db.IntegerProperty(required=True) master_user_id = db.IntegerProperty(required=True)
def to_JSON(self): def to_JSON(self):
dick = {'title': self.username, dick = {'title': self.title,
'email_ending': self.email_ending, 'email_ending': self.email_ending,
'master_user_id': self.master_user_id, 'master_user_id': self.master_user_id,
'avatar_url': self.avatar_url 'avatar_url': self.avatar_url
@ -21,5 +21,12 @@ class Campus(db.Model):
""" """
DEBUG Script - To create a campus: DEBUG Script - To create a campus:
"""
""" 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)