From 652906fee649e42e255c48e4fe863d4bae0408a9 Mon Sep 17 00:00:00 2001 From: Matan Bar Yosef Date: Tue, 16 Jun 2015 18:30:47 +0300 Subject: [PATCH 01/11] comment fixed in order to pull from master --- templates/css/theme.css | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/templates/css/theme.css b/templates/css/theme.css index de31d1a..5b3dd76 100644 --- a/templates/css/theme.css +++ b/templates/css/theme.css @@ -137,9 +137,9 @@ body.noscroll .createCampus { position:relative; - /*float:right;*/ } + /*div.img campusAvatar { border: 1px solid #0000ff; From 0b4af040c7fbce9533cf79b47df9ae700b74d085 Mon Sep 17 00:00:00 2001 From: Matan Bar Yosef Date: Tue, 16 Jun 2015 19:19:17 +0300 Subject: [PATCH 02/11] -create campus Fixed - email validation for lecturer in campus fixed!! --- templates/views/register.html | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/templates/views/register.html b/templates/views/register.html index 99beeae..f835e8b 100644 --- a/templates/views/register.html +++ b/templates/views/register.html @@ -25,19 +25,22 @@
- Create Campus + Create Campus
- - + + + - + - +
From 51fa91d6019b5ba46ac63ed0288a6903178f1bfe Mon Sep 17 00:00:00 2001 From: Matan Bar Yosef Date: Tue, 16 Jun 2015 20:24:09 +0300 Subject: [PATCH 03/11] - email validation for lecturer in campus now working! --- templates/js/controllers/homeController.js | 1 - .../js/controllers/registerController.js | 84 +++++++++++++------ templates/views/register.html | 11 --- 3 files changed, 58 insertions(+), 38 deletions(-) diff --git a/templates/js/controllers/homeController.js b/templates/js/controllers/homeController.js index 976e68e..46395cb 100644 --- a/templates/js/controllers/homeController.js +++ b/templates/js/controllers/homeController.js @@ -6,5 +6,4 @@ angular.module('SeHub') { - }]); \ No newline at end of file diff --git a/templates/js/controllers/registerController.js b/templates/js/controllers/registerController.js index 706670b..346f731 100644 --- a/templates/js/controllers/registerController.js +++ b/templates/js/controllers/registerController.js @@ -76,37 +76,69 @@ angular.module('SeHub') }; - $scope.lecturer = function(ev) + $scope.createCampus = function(ev) { - console.log("inside"); $scope.createCampusClicked = true; - if(!$scope.isLecturer) // if i am a lecturer (when pressing -> getting last data value before pressing) = "!isLecturer" it means => I Am Lecturer + if(!$scope.isLecturer) // "!isLecturer" Means => I Am Lecturer; if i am a lecturer (when pressing -> getting last data value before pressing) { - // var jsonCreateCampus = - // { - // "title": "Create Campus", - // "email": "email_ending", - // "avatar": "self.avatar.url" - // } - console.log("YES lecturer " + $scope.jsonCreateCampus.title); - - if($scope.user.lecAcMail != null) + if($scope.user.campusSuffixMail != null) { - apiService.sendValidationMail($scope.user.seToken, $scope.user.lecAcMail).success(function(data) - { - console.log("DONE - 200"); - $mdDialog.show($mdDialog.alert().title('E-mail Verification').content('A verification e-mail has been sent to your email address.') - .ariaLabel('Email verification alert dialog').ok('Got it!').targetEvent(ev)); // Pop-up alert for e-mail verification - // TODO ADD delete cookies and redirect only after pressed 'Got it' - $cookieStore.remove("com.sehub.www"); // Removing the cookies - $window.location.href = 'http://se-hub.appspot.com'; // Reference to 'welcome' page - }).error(function() - { - $mdDialog.show($mdDialog.alert().title('Error - E-mail Verification').content('An error has occured in your e-mail address or in the campus name.') - .ariaLabel('Email verification error alert dialog').ok('Got it!').targetEvent(ev)); - }); + validateEmail($scope.user.campusSuffixMail); } } - } + } + + validateEmail = function(email) // TODO ADD IT + { + var result = /^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i; + + console.log("Email: " + email); + + if (!result.test(email)) + { + console.log(email + ", Error in email, should alert"); + alert('Please provide a valid e-mail address'); + } + + if(result.test(email)) + { + console.log("Im good"); + apiService.sendValidationMail($scope.user.seToken, email).success(function(data) + { + console.log("DONE - 200"); + $mdDialog.show($mdDialog.alert().title('E-mail Verification').content('A verification e-mail has been sent to your email address.') + .ariaLabel('Email verification alert dialog').ok('Got it!').targetEvent(email)); // Pop-up alert for e-mail verification + // TODO ADD delete cookies and redirect only after pressed 'Got it' + $cookieStore.remove("com.sehub.www"); // Removing the cookies + $window.location.href = 'http://se-hub.appspot.com'; // Reference to 'welcome' page + }).error(function() + { + $mdDialog.show($mdDialog.alert().title('Error - E-mail Verification').content('An error has occured in your e-mail address or in the campus name.') + .ariaLabel('Email verification error alert dialog').ok('Got it!').targetEvent(email)); + }); + } + } + + // TODO FOR LATER - toast + // TODO FOR LATER + + // $scope.getPopWindowPosition = function() + // { + // return Object.keys($scope.toastPosition).filter(function(pos) + // { + // return $scope.toastPosition[pos]; + // }).join(' '); + // }; + + // $scope.toastPosition = + // { + // bottom: false, + // top: true, + // left: false, + // right: true + // }; + + // TODO FOR LATER + // TODO FOR LATER }]); diff --git a/templates/views/register.html b/templates/views/register.html index f835e8b..f25b61a 100644 --- a/templates/views/register.html +++ b/templates/views/register.html @@ -30,9 +30,6 @@ - @@ -51,7 +48,6 @@
-
@@ -79,13 +75,6 @@
- - \ No newline at end of file From 190d9510baf2d38691dd7473379aed0f24a953f3 Mon Sep 17 00:00:00 2001 From: Sagi Dayan Date: Tue, 16 Jun 2015 20:34:17 +0300 Subject: [PATCH 04/11] se-hub-33 #33 - Main Menu - Skeleton --- templates/views/index.html | 28 ++++++++++++++++++++++++---- 1 file changed, 24 insertions(+), 4 deletions(-) diff --git a/templates/views/index.html b/templates/views/index.html index 563c811..3abfe58 100644 --- a/templates/views/index.html +++ b/templates/views/index.html @@ -21,10 +21,30 @@
- -
-

Menu

-
+ + +
+
+ +
+
+
+ {{user.name}} +
+
+ {{user.email}} +
+
+
+ +
From 45f59dcbcb316da05eccb2143b25176d083b76e7 Mon Sep 17 00:00:00 2001 From: Sagi Dayan Date: Tue, 16 Jun 2015 20:34:37 +0300 Subject: [PATCH 05/11] se-hub-33 #33 - Main Menu - More Skeleton --- templates/css/theme.css | 97 ++++++++++++++++++---- templates/js/controllers/mainController.js | 88 +++++++++++++++----- 2 files changed, 150 insertions(+), 35 deletions(-) diff --git a/templates/css/theme.css b/templates/css/theme.css index 8db9124..a1cac9b 100644 --- a/templates/css/theme.css +++ b/templates/css/theme.css @@ -2,10 +2,10 @@ body{ font-family: "Alef Hebrew", - “Helvetica Neue”, - Helvetica, - Arial, - sans-serif; + “Helvetica Neue”, + Helvetica, + Arial, + sans-serif; } .menuBtn { @@ -144,11 +144,11 @@ body.noscroll } -.createCampus -{ - position:relative; - /*float:right;*/ -} + .createCampus + { + position:relative; + /*float:right;*/ + } /*div.img campusAvatar { @@ -164,10 +164,77 @@ body.noscroll border-left: 2px black solid; border-right: 2px black solid; border-radius: 1px black solid; -}*/ + }*/ -.gray-font{ - color: #7f7f7f; - font-size: 300%; - text-shadow:#e0e0e0 1px 1px 0; -} \ No newline at end of file + .gray-font{ + color: #7f7f7f; + font-size: 300%; + text-shadow:#e0e0e0 1px 1px 0; + } + + .user-pane-menu{ + width: 100%; + height: 15%; + background-color: #3F51B5; + -webkit-box-shadow: 0px 13px 34px -14px rgba(0,0,0,0.75); + -moz-box-shadow: 0px 13px 34px -14px rgba(0,0,0,0.75); + box-shadow: 0px 13px 34px -14px rgba(0,0,0,0.75); + top: 20px; + position: relative; + } + + .user-pane-menu img{ + border: 7px rgb(255, 255, 255) solid; + -webkit-border-radius: 100px; + -moz-border-radius: 100px; + border-radius: 50px; + width: 30%; + /*top: -40px;*/ + position: relative; + z-index: 50; + } + + .se-menu{ + /*margin-top: 20%; */ + } + + .se-menu ul{ + list-style: none; + padding: 0; + padding-left: 0; + } + + .se-menu li{ + width: 100%; + padding: 15px 0px 15px 15px; + font-size: 150%; + } + + .se-menu li:hover{ + background-color: #E2E2E2; + font-weight: bold; + } + .se-menu li .selected{ + background-color: #E2E2E2; + } + + .user-box{ + width: 100% + } + + .user-box img{ + width: 100%; + border: 4px #7f7f7f solid; + + -webkit-border-radius: 5px; + -moz-border-radius: 5px; + border-radius: 5px; + } + .user-data{ + margin-top: auto; + } + + .se-menu ul a{ + text-decoration: none !important; + color: #7f7f7f; + } \ No newline at end of file diff --git a/templates/js/controllers/mainController.js b/templates/js/controllers/mainController.js index 09cb9b5..c0ba8ce 100644 --- a/templates/js/controllers/mainController.js +++ b/templates/js/controllers/mainController.js @@ -1,28 +1,76 @@ angular.module('SeHub') -.controller('mainController', ['$scope', '$rootScope', 'apiService', '$cookies', '$location', function ($scope, $rootScope, apiService, $cookies, $location) { + .controller('mainController', ['$scope', '$rootScope', 'apiService', '$cookies', '$location', function($scope, $rootScope, apiService, $cookies, $location) { - var token = $cookies['com.sehub.www']; + var token = $cookies['com.sehub.www']; - $scope.loadingData = true; - $scope.isInRegisterMode = false; + $scope.loadingData = true; + $scope.isInRegisterMode = false; - apiService.getUserByToken(token).success(function(data){ - if(data.message == 'No User Found'){ - console.error("No User Found!"); - } + apiService.getUserByToken(token).success(function(data) { + if (data.message == 'No User Found') { + console.error("No User Found!"); + } - $scope.user = data; - if($scope.user.isFirstLogin){ - $scope.menuObj = {}; - $scope.isInRegisterMode = true; - $scope.loadingData = false; - $location.path('/register') - }else{ - $location.path('/home') - } + $scope.user = data; + if ($scope.user.isFirstLogin) { + $scope.menuObj = {}; + $scope.isInRegisterMode = true; + $scope.loadingData = false; + $location.path('/register') + } else { + $location.path('/home') + } - }) + }) - $scope.loadingData = false; + apiService.getUserByToken(token).success(function(data) // Get user token + { + $scope.user = data; + $scope.loadingData = false; -}]); \ No newline at end of file + apiService.getAllCampuses($scope.user.seToken).success(function(data) // Get all the campuses + { + $scope.campuses = data; + }).error(function() { + + }); + }); + + $scope.menuItems = [{ + "title": "Home", + "icon": "fa fa-home", + "style": "selected", + "route": "/home" + }, { + "title": "My Campuses", + "icon": "fa fa-university", + "style": "selected", + "route": "/campuses" + }, { + "title": "My Classes", + "icon": "fa fa-graduation-cap", + "style": "selected", + "route": "/campuses" + }, { + "title": "My Projects", + "icon": "fa fa-cube", + "style": "selected", + "route": "/campuses" + }, { + "title": "Tasks", + "icon": "fa fa-clipboard", + "style": "selected", + "route": "/campuses" + }, { + "title": "Settings", + "icon": "fa fa-cogs", + "style": "selected", + "route": "/campuses" + }, { + "title": "Log Out", + "icon": "fa fa-power-off", + "style": "selected", + "route": "/campuses" + }]; + + }]); \ No newline at end of file From 2ebd7392e4d8d4e1d157b2dec973536c00f27bc5 Mon Sep 17 00:00:00 2001 From: aranzaiger Date: Tue, 16 Jun 2015 22:11:33 +0300 Subject: [PATCH 06/11] 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 07/11] 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 08/11] 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 09/11] 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 10/11] 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 11/11] 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=[])