Merge branch 'master' of https://github.com/sagidayan/SE-Hub into QA
This commit is contained in:
commit
1df1239f18
11 changed files with 179 additions and 46 deletions
|
@ -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
|
||||
|
|
|
@ -70,6 +70,57 @@ def getUserByToken(token):
|
|||
return bad_request("No User Found")
|
||||
|
||||
|
||||
@user_routes.route('/api/users/updateUser/<string:token>', methods=["GET"])
|
||||
@auto.doc()
|
||||
def updateUser(token):
|
||||
"""
|
||||
<span class="card-title">>This Call will update user details</span>
|
||||
<br>
|
||||
<b>Route Parameters</b><br>
|
||||
- seToken: 'seToken'
|
||||
<br>
|
||||
<br>
|
||||
<b>Payload</b><br>
|
||||
- JSON Object, Example: <br>
|
||||
{<br>
|
||||
'name': 'Campus name',<br>
|
||||
'isLecturer': '@campus.ac.com',<br>
|
||||
}<br>
|
||||
<br>
|
||||
<b>Response</b>
|
||||
<br>
|
||||
200 - User updated
|
||||
<br>
|
||||
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()
|
|
@ -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'])
|
||||
|
|
|
@ -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;
|
||||
|
@ -148,3 +165,9 @@ body.noscroll
|
|||
border-right: 2px black solid;
|
||||
border-radius: 1px black solid;
|
||||
}*/
|
||||
|
||||
.gray-font{
|
||||
color: #7f7f7f;
|
||||
font-size: 300%;
|
||||
text-shadow:#e0e0e0 1px 1px 0;
|
||||
}
|
|
@ -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'
|
||||
});
|
||||
|
||||
}
|
||||
|
|
10
templates/js/controllers/homeController.js
Normal file
10
templates/js/controllers/homeController.js
Normal file
|
@ -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)
|
||||
{
|
||||
|
||||
|
||||
|
||||
}]);
|
|
@ -17,7 +17,10 @@ angular.module('SeHub')
|
|||
$scope.isInRegisterMode = true;
|
||||
$scope.loadingData = false;
|
||||
$location.path('/register')
|
||||
}else{
|
||||
$location.path('/home')
|
||||
}
|
||||
|
||||
})
|
||||
|
||||
$scope.loadingData = false;
|
||||
|
|
|
@ -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
|
||||
|
||||
}]);
|
||||
|
|
|
@ -2,4 +2,25 @@
|
|||
<div class="loader" ng-if="loadingData">
|
||||
<md-progress-circular md-mode="indeterminate"></md-progress-circular>
|
||||
</div>
|
||||
<md-content layout-padding>
|
||||
<md-card class="gray-font">
|
||||
<div layout="row">
|
||||
<div class="spacer"></div>
|
||||
<div>
|
||||
<h1><i class="fa fa-graduation-cap"></i></h1>
|
||||
</div>
|
||||
<div class="spacer"></div>
|
||||
</div>
|
||||
<div layout="row">
|
||||
<div class="spacer"></div>
|
||||
<div>
|
||||
<h1>Welcome To SE-Hub</h1>
|
||||
<p>
|
||||
This Is your Home Page
|
||||
</p>
|
||||
</div>
|
||||
<div class="spacer"></div>
|
||||
</div>
|
||||
</md-card>
|
||||
</md-content>
|
||||
</div>
|
|
@ -68,6 +68,7 @@
|
|||
|
||||
<!-- Controllers -->
|
||||
<script src="templates/js/controllers/mainController.js"></script>
|
||||
<script src="templates/js/controllers/homeController.js"></script>
|
||||
<script src="templates/js/controllers/registerController.js"></script>
|
||||
|
||||
</body>
|
||||
|
|
|
@ -18,26 +18,37 @@
|
|||
<br></br>
|
||||
<div layout="row" layout-align="center center">
|
||||
<p>Are You A Lecturer?</p>
|
||||
<md-switch ng-click = "lecturerPrivilege(data.cb1)" ng-model="data.cb1" aria-label="Switch 1">
|
||||
Switch 1: {{ data.cb1 }}
|
||||
<div ng-if="data">
|
||||
<!-- <md-progress-circular class="md-hue-2" md-mode="indeterminate">
|
||||
</md-progress-circular> -->
|
||||
</div>
|
||||
<md-switch ng-model="user.isLecturer" aria-label="Switch 1">
|
||||
</md-switch>
|
||||
|
||||
<!-- TODO original -->
|
||||
<!-- <md-switch class="md-primary" md-no-ink aria-label="Switch No Ink" ng-model="data.cb5">
|
||||
</md-switch> -->
|
||||
</div>
|
||||
</div>
|
||||
<div>
|
||||
<div ng-if="user.isLecturer">
|
||||
<div>
|
||||
<md-button ng-click = "lecturer($event)" ng-model="jsonCreateCampus" class="md-raised">Create Campus</md-button>
|
||||
<div class = "createCampus" ng-if="createCampusClicked">
|
||||
<md-input-container>
|
||||
<label>Academic Lecturer Email</label>
|
||||
<input type="text" ng-disabled="!createCampusClicked" ng-model="user.lecAcMail" required/>
|
||||
</md-input-container>
|
||||
<md-input-container>
|
||||
<label>Campus Name</label>
|
||||
<input type="text" ng-disabled="!createCampusClicked" ng-model="user.campusName" required/>
|
||||
</md-input-container>
|
||||
<md-input-container>
|
||||
<label>Campus Avatar Url (optional)</label>
|
||||
<input type="text" ng-disabled="!createCampusClicked" ng-model="user.newCampusAvatar" required/>
|
||||
</md-input-container>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class = "dropDown">
|
||||
<md-select placeholder="Pick your Campus" ng-model="campus" style="z-index: 300" ng-change="dropdownClicked()">
|
||||
<md-option ng-repeat="c in campuses" value="{{c.title}}">{{c.title}}</md-option>
|
||||
<md-option ng-switch="user.isLecturer" ng-repeat="c in campuses" value="{{c.title}}">{{c.title}}</md-option>
|
||||
</md-select>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div layout="col" layout-align="center center">
|
||||
<div>
|
||||
<div class="campusAvatar" ng-if="campusChecked">
|
||||
|
|
Loading…
Reference in a new issue