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() diff --git a/SE_API/UserRoutes.py b/SE_API/UserRoutes.py index c0471c3..0bc26d1 100644 --- a/SE_API/UserRoutes.py +++ b/SE_API/UserRoutes.py @@ -60,14 +60,14 @@ 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(), 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"]) @@ -83,8 +83,9 @@ def updateUser(token): Payload
- JSON Object, Example:
{
- 'name': 'Campus name',
- 'isLecturer': '@campus.ac.com',
+ 'name': 'new name',
+ 'isLecturer': true,
+ 'campusName': 'JCE'
}

Response @@ -100,23 +101,29 @@ 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.campusName = payload['campusName'] 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") diff --git a/models/User.py b/models/User.py index 8c3e330..2328f39 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=[]) diff --git a/templates/css/theme.css b/templates/css/theme.css index 8db9124..ff2f7ab 100644 --- a/templates/css/theme.css +++ b/templates/css/theme.css @@ -147,9 +147,9 @@ body.noscroll .createCampus { position:relative; - /*float:right;*/ } + /*div.img campusAvatar { border: 1px solid #0000ff; @@ -164,10 +164,86 @@ 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: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{ + 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/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/mainController.js b/templates/js/controllers/mainController.js index 09cb9b5..6216c2b 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": "", + "route": "/campuses" + }, { + "title": "My Classes", + "icon": "fa fa-graduation-cap", + "style": "", + "route": "/campuses" + }, { + "title": "My Projects", + "icon": "fa fa-cube", + "style": "", + "route": "/campuses" + }, { + "title": "Tasks", + "icon": "fa fa-clipboard", + "style": "", + "route": "/campuses" + }, { + "title": "Settings", + "icon": "fa fa-cogs", + "style": "", + "route": "#/Settings" + }, { + "title": "Log Out", + "icon": "fa fa-power-off", + "style": "", + "route": "#/logout" + }]; + + }]); \ 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/index.html b/templates/views/index.html index 563c811..7183c20 100644 --- a/templates/views/index.html +++ b/templates/views/index.html @@ -21,10 +21,32 @@
- -
-

Menu

-
+ + +
+
+
+ +
+
+
+ {{user.name}} +
+
+ {{user.email}} +
+
+
+ + +
diff --git a/templates/views/register.html b/templates/views/register.html index 99beeae..f25b61a 100644 --- a/templates/views/register.html +++ b/templates/views/register.html @@ -25,19 +25,19 @@
- Create Campus + Create Campus
- - + + - + - +
@@ -48,7 +48,6 @@
-
@@ -76,13 +75,6 @@
- -
\ No newline at end of file