diff --git a/SE_API/API.py b/SE_API/API.py index a1ad212..972c39e 100644 --- a/SE_API/API.py +++ b/SE_API/API.py @@ -214,7 +214,7 @@ def init_QA(): qa_student = User(username='qa_student', name='Student QA', avatar_url='http://ava.com', email='just@mail.com', isLecturer=False, accessToken='student_token_', seToken='_QA_TOKEN_TEST_STUDENT') qa_lecturer = User(username='qa_lecturer', name='Student QA', avatar_url='http://ava.com', email='just@mail.com', - isLecturer=False, accessToken='student_token_', seToken='_QA_TOKEN_TEST_LECTURER') + isLecturer=True, accessToken='student_token_', seToken='_QA_TOKEN_TEST_LECTURER') query = User.all().filter('username =', qa_student.username) for u in query.run(): is_student_exist = True diff --git a/SE_API/UserRoutes.py b/SE_API/UserRoutes.py index e487f2a..efad1bc 100644 --- a/SE_API/UserRoutes.py +++ b/SE_API/UserRoutes.py @@ -70,6 +70,57 @@ def getUserByToken(token): return bad_request("No User Found") +@user_routes.route('/api/users/updateUser/', methods=["GET"]) +@auto.doc() +def updateUser(token): + """ + >This Call will update user details +
+ Route Parameters
+ - seToken: 'seToken' +
+
+ Payload
+ - JSON Object, Example:
+ {
+ 'name': 'Campus name',
+ 'isLecturer': '@campus.ac.com',
+ }
+
+ Response +
+ 200 - User updated +
+ 400 - Bad Request + """ + + if not request.data: + return bad_request() + + try: + payload = json.loads(request.data) + except Exception as e: + return bad_request(e) + + user = get_user_by_token(token) + if user is None: + return bad_request("Not a user!") + + try: + user.name = payload['user'] + except Exception: + pass + + try: + user.isLecturer = payload['isLecturer'] + except Exception: + pass + + + return ok("User updated") + + + @user_routes.route('/api/users/help') def documentation(): return auto.html() \ No newline at end of file diff --git a/Testing/UserAPI_Test.py b/Testing/UserAPI_Test.py index 7baa8cb..1af62c3 100644 --- a/Testing/UserAPI_Test.py +++ b/Testing/UserAPI_Test.py @@ -67,7 +67,7 @@ class UserTestPlan(unittest.TestCase): def test_Lecturer_isLecturer(self): r = requests.get(self.__class__.url_+'api/users/getUserByToken/'+__CONFIG__['TOKENS']['LECTURER']) self.assertEquals(r.status_code, 200) - self.assertFalse(r.json()['isLecturer']) + self.assertTrue(r.json()['isLecturer']) def test_isClassIdListEmpty_Lecturer(self): r = requests.get(self.__class__.url_+'api/users/getUserByToken/'+__CONFIG__['TOKENS']['LECTURER']) diff --git a/templates/css/theme.css b/templates/css/theme.css index a8b0155..8db9124 100644 --- a/templates/css/theme.css +++ b/templates/css/theme.css @@ -1,3 +1,13 @@ +@import url(http://fonts.googleapis.com/earlyaccess/alefhebrew.css); + +body{ + font-family: "Alef Hebrew", + “Helvetica Neue”, + Helvetica, + Arial, + sans-serif; +} + .menuBtn { background-color: transparent; border: none; @@ -133,6 +143,13 @@ body.noscroll margin-top: auto; } + +.createCampus +{ + position:relative; + /*float:right;*/ +} + /*div.img campusAvatar { border: 1px solid #0000ff; @@ -147,4 +164,10 @@ body.noscroll border-left: 2px black solid; border-right: 2px black solid; border-radius: 1px black solid; -}*/ \ No newline at end of file +}*/ + +.gray-font{ + color: #7f7f7f; + font-size: 300%; + text-shadow:#e0e0e0 1px 1px 0; +} \ No newline at end of file diff --git a/templates/js/app.js b/templates/js/app.js index 9b93421..76bba8f 100644 --- a/templates/js/app.js +++ b/templates/js/app.js @@ -33,6 +33,10 @@ app.config(['$routeProvider', '$locationProvider', .when('/register', { templateUrl: 'templates/views/register.html', controller: 'registerController' + }) + .when('/home', { + templateUrl: 'templates/views/home.html', + controller: 'homeController' }); } diff --git a/templates/js/controllers/homeController.js b/templates/js/controllers/homeController.js new file mode 100644 index 0000000..976e68e --- /dev/null +++ b/templates/js/controllers/homeController.js @@ -0,0 +1,10 @@ +/** + * Created by sagi on 6/16/15. + */ +angular.module('SeHub') +.controller('homeController', ['$scope', '$cookies', '$cookieStore', '$window', '$location', '$mdToast', '$mdDialog', 'apiService', '$rootScope', function ($scope, $cookies, $cookieStore, $window, $location, $mdToast, $mdDialog, apiService ,$rootScope) +{ + + + +}]); \ No newline at end of file diff --git a/templates/js/controllers/mainController.js b/templates/js/controllers/mainController.js index 9da1fa1..09cb9b5 100644 --- a/templates/js/controllers/mainController.js +++ b/templates/js/controllers/mainController.js @@ -17,7 +17,10 @@ angular.module('SeHub') $scope.isInRegisterMode = true; $scope.loadingData = false; $location.path('/register') + }else{ + $location.path('/home') } + }) $scope.loadingData = false; diff --git a/templates/js/controllers/registerController.js b/templates/js/controllers/registerController.js index b46bc91..706670b 100644 --- a/templates/js/controllers/registerController.js +++ b/templates/js/controllers/registerController.js @@ -3,7 +3,14 @@ angular.module('SeHub') { $scope.userHasNoName = false; $scope.campusChecked = false; + $scope.createCampusClicked = false; $scope.isEmpty = true; // if the academic email line is empty + $scope.jsonCreateCampus = + { + "title": "Create Campus", + "email": "email_ending", + "avatar": "self.avatar.url" + } $rootScope.seToken = $cookies['com.sehub.www']; var token = $rootScope.seToken; @@ -44,6 +51,7 @@ angular.module('SeHub') } }; }; + }; $scope.submitClicked = function(ev) @@ -56,6 +64,7 @@ angular.module('SeHub') 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() @@ -66,38 +75,38 @@ angular.module('SeHub') }; }; - $scope.lecturerPrivilege = function(data) + + $scope.lecturer = function(ev) { - // console.log("Now " + data); - var isLecturer; - if(!data) // if i am a lecturer (when pressing -> getting last data value before pressing) = "!data" => I Am Lecturer + 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 { - isLecturer = true; - console.log("im lecturer " + isLecturer); + // var jsonCreateCampus = + // { + // "title": "Create Campus", + // "email": "email_ending", + // "avatar": "self.avatar.url" + // } + console.log("YES lecturer " + $scope.jsonCreateCampus.title); + + if($scope.user.lecAcMail != 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)); + }); + } } - } - - - // 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/home.html b/templates/views/home.html index 989a927..881bf23 100644 --- a/templates/views/home.html +++ b/templates/views/home.html @@ -2,4 +2,25 @@
+ + +
+
+
+

+
+
+
+
+
+
+

Welcome To SE-Hub

+

+ This Is your Home Page +

+
+
+
+
+
\ No newline at end of file diff --git a/templates/views/index.html b/templates/views/index.html index fcc374d..563c811 100644 --- a/templates/views/index.html +++ b/templates/views/index.html @@ -68,6 +68,7 @@ + diff --git a/templates/views/register.html b/templates/views/register.html index dad2074..99beeae 100644 --- a/templates/views/register.html +++ b/templates/views/register.html @@ -18,26 +18,37 @@

Are You A Lecturer?

- - Switch 1: {{ data.cb1 }} -
- -
-
- - - + +
+
+
+ Create Campus +
+ + + + + + + + + + + + +
+
+
+