From 2ebd7392e4d8d4e1d157b2dec973536c00f27bc5 Mon Sep 17 00:00:00 2001 From: aranzaiger Date: Tue, 16 Jun 2015 22:11:33 +0300 Subject: [PATCH 1/6] fix bug #25 --- SE_API/UserRoutes.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SE_API/UserRoutes.py b/SE_API/UserRoutes.py index c0471c3..f1e9382 100644 --- a/SE_API/UserRoutes.py +++ b/SE_API/UserRoutes.py @@ -67,7 +67,7 @@ def getUserByToken(token): status=200, mimetype="application/json") # Real response! - return bad_request("No User Found") + return no_content("No User Found") @user_routes.route('/api/users/updateUser/', methods=["POST"]) From d428da5df0d53f703f99e97e02ebad2536bdc971 Mon Sep 17 00:00:00 2001 From: aranzaiger Date: Tue, 16 Jun 2015 22:16:11 +0300 Subject: [PATCH 2/6] added a missing parameter (master_id) that made function not usable --- SE_API/CourseRoutes.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/SE_API/CourseRoutes.py b/SE_API/CourseRoutes.py index 4bae4ea..5713db2 100644 --- a/SE_API/CourseRoutes.py +++ b/SE_API/CourseRoutes.py @@ -57,7 +57,7 @@ def create_course(token): 403 - Invalid token or not a lecturer """ if not request.data: - return bad_request() + return bad_request("no data") if not is_lecturer(token): #todo: change to lecturer id return forbidden("Invalid token or not a lecturer!") @@ -77,20 +77,20 @@ def create_course(token): if end_date <= start_date: return bad_request("end date cant be before (or same day) start date") - course = Course(courseName=payload['courseName'], campusName=payload['campusName'], + course = Course(courseName=payload['courseName'], campusName=payload['campusName'], master_id=user.key().id(), startDate=start_date, endDate=end_date) - #check if name already exists try: query = Course.all() query.filter("courseName = ", payload['courseName']) for c in query.run(limit=1): - return forbidden("Campus with same name already exists") + return forbidden("Course with same name already exists") except Exception as e: print e - except Exception: + except Exception as e: + print e return bad_request() From 4bb17157d0eebebc0d2d97594cbfb0fbea43cd5f Mon Sep 17 00:00:00 2001 From: aranzaiger Date: Tue, 16 Jun 2015 22:28:05 +0300 Subject: [PATCH 3/6] fix updateUser - added save ro DB fix parameter name fix documentation --- SE_API/UserRoutes.py | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/SE_API/UserRoutes.py b/SE_API/UserRoutes.py index f1e9382..4073229 100644 --- a/SE_API/UserRoutes.py +++ b/SE_API/UserRoutes.py @@ -83,8 +83,8 @@ def updateUser(token): Payload
- JSON Object, Example:
{
- 'name': 'Campus name',
- 'isLecturer': '@campus.ac.com',
+ 'name': 'new name',
+ 'isLecturer': true
}

Response @@ -100,23 +100,24 @@ def updateUser(token): try: payload = json.loads(request.data) except Exception as e: - return bad_request(e) + return bad_request() user = get_user_by_token(token) if user is None: return bad_request("Not a user!") try: - user.name = payload['user'] + user.name = payload['name'] except Exception: pass try: user.isLecturer = payload['isLecturer'] - except Exception: - pass - + except Exception as e: + print e + db.put(user) + db.save return ok("User updated") From a29e9bce4628b863aa616b52c503440cae7107f7 Mon Sep 17 00:00:00 2001 From: aranzaiger Date: Tue, 16 Jun 2015 22:42:15 +0300 Subject: [PATCH 4/6] added option to change campus name --- SE_API/UserRoutes.py | 8 +++++++- models/User.py | 1 + 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/SE_API/UserRoutes.py b/SE_API/UserRoutes.py index 4073229..ce51a1b 100644 --- a/SE_API/UserRoutes.py +++ b/SE_API/UserRoutes.py @@ -84,7 +84,8 @@ def updateUser(token): - JSON Object, Example:
{
'name': 'new name',
- 'isLecturer': true
+ 'isLecturer': true,
+ 'campusName': 'JCE'
}

Response @@ -111,6 +112,11 @@ def updateUser(token): except Exception: pass + try: + user.campusName = payload['campusName'] + except Exception: + pass + try: user.isLecturer = payload['isLecturer'] except Exception as e: diff --git a/models/User.py b/models/User.py index 8c3e330..d59e690 100644 --- a/models/User.py +++ b/models/User.py @@ -12,6 +12,7 @@ class User(db.Model): seToken = db.StringProperty(required=True) avatar_url = db.StringProperty(required=True) isFirstLogin = db.BooleanProperty(default=True) + campusName = db.StringProperty(required=True, default="") campuses_id_list = db.StringListProperty(default=[]) classes_id_list = db.StringListProperty(default=[]) From 06f94259282ea0bc113196bc6ae82d3b756935e6 Mon Sep 17 00:00:00 2001 From: Sagi Dayan Date: Tue, 16 Jun 2015 22:45:06 +0300 Subject: [PATCH 5/6] issue #33 - Main Menu Done --- templates/css/theme.css | 11 ++++++- templates/js/controllers/mainController.js | 18 ++++++------ templates/views/index.html | 34 ++++++++++++---------- 3 files changed, 37 insertions(+), 26 deletions(-) diff --git a/templates/css/theme.css b/templates/css/theme.css index a1cac9b..83a3c64 100644 --- a/templates/css/theme.css +++ b/templates/css/theme.css @@ -214,8 +214,17 @@ body.noscroll background-color: #E2E2E2; font-weight: bold; } - .se-menu li .selected{ + + .se-menu li:active{ + background-color: #B2B2B2; + text-shadow:#e0e0e0 1px 1px 0; + font-weight: bold; + } + + .se-menu .selected{ background-color: #E2E2E2; + text-shadow:#e0e0e0 1px 1px 0; + font-weight: bold; } .user-box{ diff --git a/templates/js/controllers/mainController.js b/templates/js/controllers/mainController.js index c0ba8ce..6216c2b 100644 --- a/templates/js/controllers/mainController.js +++ b/templates/js/controllers/mainController.js @@ -40,37 +40,37 @@ angular.module('SeHub') "title": "Home", "icon": "fa fa-home", "style": "selected", - "route": "/home" + "route": "#/home" }, { "title": "My Campuses", "icon": "fa fa-university", - "style": "selected", + "style": "", "route": "/campuses" }, { "title": "My Classes", "icon": "fa fa-graduation-cap", - "style": "selected", + "style": "", "route": "/campuses" }, { "title": "My Projects", "icon": "fa fa-cube", - "style": "selected", + "style": "", "route": "/campuses" }, { "title": "Tasks", "icon": "fa fa-clipboard", - "style": "selected", + "style": "", "route": "/campuses" }, { "title": "Settings", "icon": "fa fa-cogs", - "style": "selected", - "route": "/campuses" + "style": "", + "route": "#/Settings" }, { "title": "Log Out", "icon": "fa fa-power-off", - "style": "selected", - "route": "/campuses" + "style": "", + "route": "#/logout" }]; }]); \ No newline at end of file diff --git a/templates/views/index.html b/templates/views/index.html index 3abfe58..7183c20 100644 --- a/templates/views/index.html +++ b/templates/views/index.html @@ -25,26 +25,28 @@ --> -
-
- -
-
-
- {{user.name}} +
+
+
+
-
- {{user.email}} +
+
+ {{user.name}} +
+
+ {{user.email}} +
+ +
- -
From 24d8252d07e6144264c2ec1404f12156419d3b38 Mon Sep 17 00:00:00 2001 From: Sagi Dayan Date: Tue, 16 Jun 2015 23:08:37 +0300 Subject: [PATCH 6/6] API: Hot-Fix for the GetUserByToken Method --- SE_API/UserRoutes.py | 2 +- models/User.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/SE_API/UserRoutes.py b/SE_API/UserRoutes.py index ce51a1b..0bc26d1 100644 --- a/SE_API/UserRoutes.py +++ b/SE_API/UserRoutes.py @@ -60,7 +60,7 @@ def getUserByToken(token): 403 - No User Found """ query = User.all() - query.filter("seToken = ", token) + query.filter("seToken =", token) for u in query.run(limit=5): return Response(response=u.to_JSON(), diff --git a/models/User.py b/models/User.py index d59e690..2328f39 100644 --- a/models/User.py +++ b/models/User.py @@ -12,7 +12,7 @@ class User(db.Model): seToken = db.StringProperty(required=True) avatar_url = db.StringProperty(required=True) isFirstLogin = db.BooleanProperty(default=True) - campusName = db.StringProperty(required=True, default="") + campusName = db.StringProperty(required=True, default=" ") campuses_id_list = db.StringListProperty(default=[]) classes_id_list = db.StringListProperty(default=[])