Merge branches 'QA' and 'master' of https://github.com/sagidayan/SE-Hub into QA
This commit is contained in:
commit
1f01d2522d
9 changed files with 262 additions and 85 deletions
|
@ -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()
|
||||
|
||||
|
||||
|
|
|
@ -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/<string:token>', methods=["POST"])
|
||||
|
@ -83,8 +83,9 @@ def updateUser(token):
|
|||
<b>Payload</b><br>
|
||||
- JSON Object, Example: <br>
|
||||
{<br>
|
||||
'name': 'Campus name',<br>
|
||||
'isLecturer': '@campus.ac.com',<br>
|
||||
'name': 'new name',<br>
|
||||
'isLecturer': true,<br>
|
||||
'campusName': 'JCE'<br>
|
||||
}<br>
|
||||
<br>
|
||||
<b>Response</b>
|
||||
|
@ -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")
|
||||
|
||||
|
||||
|
|
|
@ -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=[])
|
||||
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
.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;
|
||||
}
|
|
@ -6,5 +6,4 @@ angular.module('SeHub')
|
|||
{
|
||||
|
||||
|
||||
|
||||
}]);
|
|
@ -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;
|
||||
|
||||
}]);
|
||||
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"
|
||||
}];
|
||||
|
||||
}]);
|
|
@ -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
|
||||
}]);
|
||||
|
|
|
@ -21,10 +21,32 @@
|
|||
</md-toolbar>
|
||||
<div layout="row" flex>
|
||||
<md-sidenav layout="column" class="md-sidenav-left md-whiteframe-z2" md-component-id="left" md-is-locked-open="$mdMedia('gt-sm')">
|
||||
<md-content>
|
||||
<center>
|
||||
<h1><i class="fa fa-compass"></i> Menu</h1>
|
||||
</center>
|
||||
<!-- <div class="user-pane-menu">
|
||||
<img ng-src="{{user.avatar_url}}" alt="">
|
||||
</div> -->
|
||||
<md-content class="se-menu">
|
||||
<div ng-if="!isInRegisterMode">
|
||||
<div class="user-box" layout="row" layout-padding>
|
||||
<div flex="30"> <!-- Avatar -->
|
||||
<img ng-src="{{user.avatar_url}}" alt="">
|
||||
</div>
|
||||
<div class="user-data" layout="column" flex>
|
||||
<div>
|
||||
{{user.name}}
|
||||
</div>
|
||||
<div>
|
||||
{{user.email}}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<ul>
|
||||
<a ng-repeat="item in menuItems" ng-href="{{item.route}}">
|
||||
<li ng-class="[item.style]"><i ng-class="item.icon"></i> {{item.title}}</li>
|
||||
<md-divider ng-if="!$last"></md-divider>
|
||||
</a>
|
||||
</ul>
|
||||
</div>
|
||||
<div ng-if="loadingData">
|
||||
<md-progress-circular></md-progress-circular>
|
||||
</div>
|
||||
|
|
|
@ -25,19 +25,19 @@
|
|||
<div>
|
||||
<div ng-if="user.isLecturer">
|
||||
<div>
|
||||
<md-button ng-click = "lecturer($event)" ng-model="jsonCreateCampus" class="md-raised">Create Campus</md-button>
|
||||
<md-button ng-click = "createCampus($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/>
|
||||
<label>Academic Suffix Email</label>
|
||||
<input type="text" ng-model="user.campusSuffixMail" ng-minlength="1" required/>
|
||||
</md-input-container>
|
||||
<md-input-container>
|
||||
<label>Campus Name</label>
|
||||
<input type="text" ng-disabled="!createCampusClicked" ng-model="user.campusName" required/>
|
||||
<input type="text" ng-if="createCampusClicked" ng-model="user.campusName" ng-minlength="1" required !important/>
|
||||
</md-input-container>
|
||||
<md-input-container>
|
||||
<label>Campus Avatar Url (optional)</label>
|
||||
<input type="text" ng-disabled="!createCampusClicked" ng-model="user.newCampusAvatar" required/>
|
||||
<input type="text" ng-if="createCampusClicked" ng-model="user.newCampusAvatar"/>
|
||||
</md-input-container>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -48,7 +48,6 @@
|
|||
</md-select>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div layout="col" layout-align="center center">
|
||||
<div>
|
||||
<div class="campusAvatar" ng-if="campusChecked">
|
||||
|
@ -76,13 +75,6 @@
|
|||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<!-- <div> // TODO return
|
||||
<p>
|
||||
<b>Note:</b> This setting can be changed in the future. <br>
|
||||
But Choose Now for easy Registration...
|
||||
</p>
|
||||
</div> -->
|
||||
|
||||
</md-card>
|
||||
</md-content>
|
||||
</div>
|
Loading…
Reference in a new issue