From 6518fa3ff34ec8c305aa08d5569f8b7f13a609fe Mon Sep 17 00:00:00 2001 From: aranzaiger Date: Tue, 16 Jun 2015 23:22:44 +0300 Subject: [PATCH 1/4] courseName is optional --- models/User.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/models/User.py b/models/User.py index d59e690..e1edb87 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(default="") campuses_id_list = db.StringListProperty(default=[]) classes_id_list = db.StringListProperty(default=[]) @@ -24,6 +24,7 @@ class User(db.Model): 'seToken' : self.seToken, 'avatar_url' : self.avatar_url, 'isFirstLogin' : self.isFirstLogin, + 'campusName': self.campusName, 'campuses_id_list': self.campuses_id_list, 'classes_id_list': self.classes_id_list } From ea728b0cc7e1353412b44a3fb6d1e48277068d36 Mon Sep 17 00:00:00 2001 From: aranzaiger Date: Tue, 16 Jun 2015 23:23:09 +0300 Subject: [PATCH 2/4] documentation --- SE_API/CourseRoutes.py | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/SE_API/CourseRoutes.py b/SE_API/CourseRoutes.py index 5713db2..51a54a4 100644 --- a/SE_API/CourseRoutes.py +++ b/SE_API/CourseRoutes.py @@ -42,9 +42,9 @@ def create_course(token): {
'courseName': 'Advance Math',
'campusName': 'JCE',
- 'startDate': '2015-14-3'
- 'endDate': '2015-29-6'
- 'taskFlag': 'False'
+ 'startDate': {'year': 2015, 'month' : 4, 'day' : 3}
+ 'endDate': {'year': 2016, 'month' : 5, 'day' : 14}
+ 'taskFlag': false
}


@@ -67,8 +67,7 @@ def create_course(token): try: payload = json.loads(request.data) except Exception as e: - return bad_request(e) - + return bad_request() try: start_date = datetime.date(payload['startDate']['year'],payload['startDate']['month'],payload['startDate']['day']) From 37880d649a0e67a6f64e0aab3f3c7cbbede4f1e7 Mon Sep 17 00:00:00 2001 From: Matan Bar Yosef Date: Tue, 16 Jun 2015 23:29:34 +0300 Subject: [PATCH 3/4] - fixed mdDialog on email error --- .../js/controllers/registerController.js | 50 +++++++------------ templates/js/services/apiService.js | 14 ++++-- templates/views/register.html | 6 +-- 3 files changed, 30 insertions(+), 40 deletions(-) diff --git a/templates/js/controllers/registerController.js b/templates/js/controllers/registerController.js index 346f731..a2ca317 100644 --- a/templates/js/controllers/registerController.js +++ b/templates/js/controllers/registerController.js @@ -56,9 +56,13 @@ angular.module('SeHub') $scope.submitClicked = function(ev) { + var emailValid = false; if($scope.user.AcMail != null) { var fullMail = $scope.user.AcMail + $scope.campusObj.email_ending; // Holds the full academic email of the user + + console.log("Mail: " + fullMail); + apiService.sendValidationMail($scope.user.seToken, fullMail).success(function(data) { console.log("DONE - 200"); @@ -72,36 +76,38 @@ angular.module('SeHub') $mdDialog.show($mdDialog.alert().title('Error - E-mail Verification').content('An error has occured in your e-mail address.') .ariaLabel('Email verification error alert dialog').ok('Got it!').targetEvent(ev)); }); + } + else // TODO Fix when success to show mdDialog until 'Got it' clicked + { + $mdDialog.show($mdDialog.alert().title('Error - E-mail Verification').content('An error has occured in your e-mail address.') + .ariaLabel('Email verification error alert dialog').ok('Got it!').targetEvent(ev)); }; }; - $scope.createCampus = function(ev) { $scope.createCampusClicked = true; if(!$scope.isLecturer) // "!isLecturer" Means => I Am Lecturer; if i am a lecturer (when pressing -> getting last data value before pressing) { - if($scope.user.campusSuffixMail != null) + if($scope.user.campusMail != null) { - validateEmail($scope.user.campusSuffixMail); + validateEmail($scope.user.campusMail); // Verify the email according to "xxx@name.suffix" } } } - validateEmail = function(email) // TODO ADD IT + validateEmail = function(email) { 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)) + if (!result.test(email)) // TODO Fix when success to show mdDialog until 'Got it' clicked { console.log(email + ", Error in email, should alert"); - alert('Please provide a valid e-mail address'); + // alert('Please provide a valid e-mail address'); + $mdDialog.show($mdDialog.alert().title('Error - E-mail Verification').content('An error has occured in your e-mail address.') + .ariaLabel('Email verification error alert dialog').ok('Got it!').targetEvent(email)); } - - if(result.test(email)) + if(result.test(email)) // TODO Fix when success to show mdDialog until 'Got it' clicked { console.log("Im good"); apiService.sendValidationMail($scope.user.seToken, email).success(function(data) @@ -119,26 +125,4 @@ angular.module('SeHub') }); } } - - // 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/js/services/apiService.js b/templates/js/services/apiService.js index 108b309..297bea4 100644 --- a/templates/js/services/apiService.js +++ b/templates/js/services/apiService.js @@ -3,8 +3,6 @@ var DEBUG = true; var service = angular.module('seHub.services', []); service.factory('apiService', ['$http', function($http) { - - return { getUserByToken: function(token){ var url = (DEBUG ? "http://localhost:8080" : "http://se-hub.appspot.com") + "/api/users/getUserByToken/" + token; @@ -36,9 +34,17 @@ service.factory('apiService', ['$http', function($http) { data: payload }; + return $http(req); + }, + updateUser: function(token, payLoad){ + var url = (DEBUG ? "http://localhost:8080" : "http://se-hub.appspot.com") + "/api/users/updateUser/" + token; + + req = { + method: "POST", + url: url, + data: payLoad + }; return $http(req); } - - }; }]); \ No newline at end of file diff --git a/templates/views/register.html b/templates/views/register.html index f25b61a..7d4d967 100644 --- a/templates/views/register.html +++ b/templates/views/register.html @@ -12,7 +12,7 @@
- +


@@ -29,7 +29,7 @@
- + @@ -65,7 +65,7 @@
- +
From f5be224cb25d09a16a3c7ca11380ed76fcdbef7b Mon Sep 17 00:00:00 2001 From: Sagi Dayan Date: Tue, 16 Jun 2015 23:32:10 +0300 Subject: [PATCH 4/4] Menu is usable (issue #42) and starting settings --- templates/css/theme.css | 1 + templates/js/app.js | 4 +++ templates/js/controllers/mainController.js | 36 ++++++++++--------- .../js/controllers/settingsController.js | 30 ++++++++++++++++ templates/js/services/apiService.js | 1 - templates/views/index.html | 9 ++--- templates/views/settings.html | 10 ++++++ 7 files changed, 66 insertions(+), 25 deletions(-) create mode 100644 templates/js/controllers/settingsController.js create mode 100644 templates/views/settings.html diff --git a/templates/css/theme.css b/templates/css/theme.css index ff2f7ab..92d6805 100644 --- a/templates/css/theme.css +++ b/templates/css/theme.css @@ -213,6 +213,7 @@ body.noscroll .se-menu li:hover{ background-color: #E2E2E2; font-weight: bold; + cursor: pointer; } .se-menu li:active{ diff --git a/templates/js/app.js b/templates/js/app.js index 76bba8f..86cbcc1 100644 --- a/templates/js/app.js +++ b/templates/js/app.js @@ -37,6 +37,10 @@ app.config(['$routeProvider', '$locationProvider', .when('/home', { templateUrl: 'templates/views/home.html', controller: 'homeController' + }) + .when('/Settings', { + templateUrl: 'templates/views/settings.html', + controller: 'settingsController' }); } diff --git a/templates/js/controllers/mainController.js b/templates/js/controllers/mainController.js index 6216c2b..bad88a9 100644 --- a/templates/js/controllers/mainController.js +++ b/templates/js/controllers/mainController.js @@ -10,8 +10,9 @@ angular.module('SeHub') if (data.message == 'No User Found') { console.error("No User Found!"); } - + $scope.loadingData = false; $scope.user = data; + console.log(data); if ($scope.user.isFirstLogin) { $scope.menuObj = {}; $scope.isInRegisterMode = true; @@ -23,24 +24,11 @@ angular.module('SeHub') }) - apiService.getUserByToken(token).success(function(data) // Get user token - { - $scope.user = data; - $scope.loadingData = false; - - 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" + "route": "/home" }, { "title": "My Campuses", "icon": "fa fa-university", @@ -65,12 +53,26 @@ angular.module('SeHub') "title": "Settings", "icon": "fa fa-cogs", "style": "", - "route": "#/Settings" + "route": "/Settings" }, { "title": "Log Out", "icon": "fa fa-power-off", "style": "", - "route": "#/logout" + "route": "/logout" }]; + $scope.menuClicked = function(item){ + var route = "" + for (var i = $scope.menuItems.length - 1; i >= 0; i--) { + if($scope.menuItems[i].title === item.title){ + $scope.menuItems[i].style="selected"; + route = $scope.menuItems[i].route; + }else{ + $scope.menuItems[i].style = ""; + } + }; + $location.path(route); + } + + }]); \ No newline at end of file diff --git a/templates/js/controllers/settingsController.js b/templates/js/controllers/settingsController.js new file mode 100644 index 0000000..4968b42 --- /dev/null +++ b/templates/js/controllers/settingsController.js @@ -0,0 +1,30 @@ +angular.module('SeHub') + .controller('settingsController', ['$scope', '$rootScope', 'apiService', '$cookies', '$location', function($scope, $rootScope, apiService, $cookies, $location) { + + var token = $cookies['com.sehub.www']; + + $scope.loadingData = true; + $scope.isInRegisterMode = false; + + $scope.title = "Settings" + + apiService.getUserByToken(token).success(function(data) { + if (data.message == 'No User Found') { + console.error("No User Found!"); + } + $scope.loadingData = false; + $scope.user = data; + console.log(data); + if ($scope.user.isFirstLogin) { + $scope.menuObj = {}; + $scope.isInRegisterMode = true; + $scope.loadingData = false; + $location.path('/register') + } + + }); + + + + + }]); \ No newline at end of file diff --git a/templates/js/services/apiService.js b/templates/js/services/apiService.js index 108b309..53bc627 100644 --- a/templates/js/services/apiService.js +++ b/templates/js/services/apiService.js @@ -11,7 +11,6 @@ service.factory('apiService', ['$http', function($http) { req = { method : "GET", url : url - }; return $http(req); }, diff --git a/templates/views/index.html b/templates/views/index.html index 7183c20..cd629d1 100644 --- a/templates/views/index.html +++ b/templates/views/index.html @@ -21,9 +21,6 @@
-
@@ -41,15 +38,12 @@
-
- -
@@ -91,6 +85,7 @@ + diff --git a/templates/views/settings.html b/templates/views/settings.html new file mode 100644 index 0000000..0c4b980 --- /dev/null +++ b/templates/views/settings.html @@ -0,0 +1,10 @@ +
+
+ +
+ + +

{{title}}

+
+
+
\ No newline at end of file