From 9698a5b4e2e08c1e916b94544748d44d528ae956 Mon Sep 17 00:00:00 2001 From: Sagi Dayan Date: Wed, 10 Jun 2015 13:55:55 +0300 Subject: [PATCH] API: Campus Hot Fix --- SE_API/API.py | 7 ++++--- models/Campus.py | 13 ++++++++++--- 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/SE_API/API.py b/SE_API/API.py index 3006b58..d8f1be3 100644 --- a/SE_API/API.py +++ b/SE_API/API.py @@ -143,11 +143,12 @@ def get_campuses(token): """ if is_user_token_valid(token): arr = [] - query = User.all() + query = Campus.all() for c in query.run(): - arr.append(c.to_JSON) + arr.append(dict(json.loads(c.to_JSON()))) + print arr if len(arr) != 0: - return Response(response=json.dumps([]), + return Response(response=json.dumps(arr), status=200, mimetype="application/json") else: diff --git a/models/Campus.py b/models/Campus.py index de62f31..4859409 100644 --- a/models/Campus.py +++ b/models/Campus.py @@ -11,7 +11,7 @@ class Campus(db.Model): master_user_id = db.IntegerProperty(required=True) def to_JSON(self): - dick = {'title': self.username, + dick = {'title': self.title, 'email_ending': self.email_ending, 'master_user_id': self.master_user_id, 'avatar_url': self.avatar_url @@ -21,5 +21,12 @@ class Campus(db.Model): """ DEBUG Script - To create a campus: - -""" \ No newline at end of file +""" +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) \ No newline at end of file