Merge branch 'master' of https://github.com/sagidayan/SE-Hub into UI
# Conflicts: # templates/js/services/apiService.js
This commit is contained in:
commit
5ec2ed20bd
9 changed files with 203 additions and 48 deletions
|
@ -192,7 +192,65 @@ def getCampusesByUser(token):
|
|||
return bad_request("Bad user Token")
|
||||
|
||||
arr = []
|
||||
for i in user['campuses_id_list']:
|
||||
for i in user.campuses_id_list:
|
||||
campus = Campus.get_by_id(int(i))
|
||||
arr.append(dict(json.loads(campus.to_JSON())))
|
||||
|
||||
if len(arr) != 0:
|
||||
return Response(response=json.dumps(arr),
|
||||
status=200,
|
||||
mimetype="application/json")
|
||||
else:
|
||||
return Response(response=[],
|
||||
status=200,
|
||||
mimetype="application/json")
|
||||
|
||||
@campus_routes.route('/api/campuses/getCampusesByUserID/', defaults={'token': None, 'id': None})
|
||||
@campus_routes.route('/api/campuses/getCampusesByUserID/<string:token>/<string:id>', methods=['GET'])
|
||||
@auto.doc()
|
||||
def getCampusesByUserID(token, id):
|
||||
"""
|
||||
<span class="card-title">This Call will return an array of all Campuses of a certain User By ID</span>
|
||||
<br>
|
||||
<b>Route Parameters</b><br>
|
||||
- token: 'seToken' of requesting user
|
||||
- The ID of <b>Wanted</b> User Campuses
|
||||
<br>
|
||||
<br>
|
||||
<b>Payload</b><br>
|
||||
- NONE <br>
|
||||
<br>
|
||||
<br>
|
||||
<b>Response</b>
|
||||
<br>
|
||||
200 - JSON Array, Example:<br>
|
||||
[<br>
|
||||
{
|
||||
'title': 'JCE',<br>
|
||||
'email_ending': '@post.jce.ac.il',<br>
|
||||
'master_user_id': 123453433341, (User that created the campus)<br>
|
||||
'avatar_url': 'http://some.domain.com/imagefile.jpg',<br>
|
||||
'id' : 1234567890<br>
|
||||
},<br>
|
||||
....<br>
|
||||
{<br>
|
||||
...<br>
|
||||
}req<br>
|
||||
]<br>
|
||||
<br>
|
||||
403 - Invalid Token<br>
|
||||
"""
|
||||
|
||||
user = get_user_by_token(token)
|
||||
if user is None:
|
||||
return forbidden("Invalid Token")
|
||||
|
||||
user = get_user_by_id(int(id))
|
||||
if user is None:
|
||||
return no_content("No User")
|
||||
|
||||
arr = []
|
||||
for i in user.campuses_id_list:
|
||||
campus = Campus.get_by_id(int(i))
|
||||
arr.append(dict(json.loads(campus.to_JSON())))
|
||||
|
||||
|
|
|
@ -268,6 +268,66 @@ def getUserByToken(token):
|
|||
status=200,
|
||||
mimetype="application/json") # Real response!
|
||||
|
||||
return no_content("No User Found")
|
||||
|
||||
@user_routes.route('/api/users/getUserById/', defaults={'token': None, 'id': None})
|
||||
@user_routes.route('/api/users/getUserById/<string:token>/<string:id>', methods=["GET"])
|
||||
@auto.doc()
|
||||
def getUserById(token, id):
|
||||
"""
|
||||
<span class="card-title">>This Call will return a user by a given UserId</span>
|
||||
<br>
|
||||
<b>Route Parameters</b><br>
|
||||
- seToken: 'seToken'
|
||||
<br>
|
||||
<br>
|
||||
<b>Payload</b><br>
|
||||
- NONE
|
||||
<br>
|
||||
<br>
|
||||
<b>Response</b>
|
||||
<br>
|
||||
200 - JSON Example:<br>
|
||||
<code>
|
||||
{<br>
|
||||
'username': 'DarkLord',<br>
|
||||
'name': 'Darth Vader',<br>
|
||||
'email': 'darkLord@death.planet,<br>
|
||||
'isLecturer': 'True',<br>
|
||||
'seToken': 'xxxxxx-xxxxx-xxxxx-xxxxxx',<br>
|
||||
'avatar_url': 'http://location.git.com/somthing'<br>
|
||||
'isFirstLogin': False,<br>
|
||||
'campuses_id_list': [{<br>
|
||||
'master_user_id': 111,<br>
|
||||
'id': 5629499534213120,<br>
|
||||
'email_ending': "@post.jce.ac.il",<br>
|
||||
'avatar_url': "https://yt3.ggpht.com/--ZkWxybWGOM/AAAAAAAAAAI/AAAAAAAAAAA/_nAICC_kzzI/s88-c-k-no/photo.jpg",<br>
|
||||
'title': "JCE"
|
||||
}],<br>
|
||||
'courses_id_list': ['a','b','c'],<br>
|
||||
'id': 234253523<br>
|
||||
}<br>
|
||||
</code>
|
||||
<br>
|
||||
403 - No User Found
|
||||
"""
|
||||
if token is None or id is None:
|
||||
return no_content("No Token/ID, No User Found")
|
||||
|
||||
if get_user_by_token(token) is None:
|
||||
return forbidden('Invalid Token')
|
||||
|
||||
u = get_user_by_id(int(id))
|
||||
if u is None:
|
||||
return no_content('No user Found')
|
||||
|
||||
for index, c in enumerate(u.campuses_id_list):
|
||||
c = json.loads(Campus.get_by_id(int(c)).to_JSON())
|
||||
u.campuses_id_list[index] = c
|
||||
|
||||
return Response(response=u.to_JSON(),
|
||||
status=200,
|
||||
mimetype="application/json") # Real response!
|
||||
|
||||
return no_content("No User Found")
|
||||
|
||||
|
|
|
@ -13,6 +13,10 @@ def get_user_by_token(token):
|
|||
return u
|
||||
return None
|
||||
|
||||
def get_user_by_id(id):
|
||||
u = User.get_by_id(id)
|
||||
return u
|
||||
|
||||
def get_campus_by_campusName(campusName):
|
||||
query = Campus.all()
|
||||
query.filter("title = ", campusName)
|
||||
|
|
|
@ -54,8 +54,8 @@
|
|||
SE-Hub Docs Index
|
||||
</h1>
|
||||
|
||||
|
||||
<div>
|
||||
<center>
|
||||
<div style="width: 40%">
|
||||
<ul class="collection">
|
||||
<li class="collection-item dismissable"><div>Users Related API<a href="/api/users/help" class="secondary-content"><i class="mdi-content-send"></i></a></div></li>
|
||||
<li class="collection-item dismissable"><div>Campuses Related API<a href="/api/campuses/help" class="secondary-content"><i class="mdi-content-send"></i></a></div></li>
|
||||
|
@ -66,7 +66,7 @@
|
|||
<li class="collection-item dismissable"><div>Miscellaneous Methods<a href="/api/help/misc" class="secondary-content"><i class="mdi-content-send"></i></a></div></li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
</center>
|
||||
<footer class="page-footer">
|
||||
<div class="container">
|
||||
<div class="row">
|
||||
|
|
|
@ -46,7 +46,7 @@ app.config(['$routeProvider', '$locationProvider',
|
|||
templateUrl: 'templates/views/tasks.html',
|
||||
controller: 'tasksController'
|
||||
})
|
||||
.when('/myClasses', {
|
||||
.when('/myClasses/:campusId', {
|
||||
templateUrl: 'templates/views/myClasses.html',
|
||||
controller: 'myClassesController'
|
||||
})
|
||||
|
@ -54,7 +54,7 @@ app.config(['$routeProvider', '$locationProvider',
|
|||
templateUrl: 'templates/views/newTask.html',
|
||||
controller: 'newTasksController'
|
||||
})
|
||||
.when('/projects', {
|
||||
.when('/projects/:classId', {
|
||||
templateUrl: 'templates/views/projects.html',
|
||||
controller: 'projectsController'
|
||||
})
|
||||
|
|
|
@ -22,21 +22,16 @@ angular.module('SeHub')
|
|||
"icon": "fa fa-tachometer",
|
||||
"style": "selected",
|
||||
"route": "/home"
|
||||
}, {
|
||||
"title": "My Campuses",
|
||||
"icon": "fa fa-university",
|
||||
}, {
|
||||
"title": "Courses",
|
||||
"icon": "fa fa-graduation-cap",
|
||||
"style": "",
|
||||
"route": "/campuses"
|
||||
}, {
|
||||
"title": "My Classes",
|
||||
"icon": "fa fa-graduation-cap",
|
||||
"style": "",
|
||||
"route": "/myClasses"
|
||||
}, {
|
||||
"title": "My Projects",
|
||||
"title": "Projects",
|
||||
"icon": "fa fa-cube",
|
||||
"style": "",
|
||||
"route": "/projects"
|
||||
"route": "/myClasses"
|
||||
}, {
|
||||
"title": "Tasks",
|
||||
"icon": "fa fa-clipboard",
|
||||
|
|
|
@ -1,31 +1,33 @@
|
|||
angular.module('SeHub')
|
||||
.controller('profileController', ['$scope', '$rootScope', 'dataService', 'apiService',
|
||||
'$cookies', '$location', '$routeParams',
|
||||
'$cookies', '$location', '$routeParams',
|
||||
function($scope, $rootScope, dataService, apiService, $cookies, $location, $routeParams) {
|
||||
|
||||
var token = $cookies['com.sehub.www'];
|
||||
|
||||
var id = $routeParams.id;
|
||||
$scope.loadingData = true;
|
||||
$scope.isInRegisterMode = false;
|
||||
|
||||
$scope.title = "Profile " + $routeParams.id;
|
||||
$scope.title = "Profile";
|
||||
|
||||
apiService.getUserByToken(token).success(function(data) {
|
||||
apiService.getUserById(token, id).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;
|
||||
apiService.getCampusesByUserId(token, id).success(function(data) {
|
||||
$scope.campuses = data;
|
||||
console.log(data);
|
||||
|
||||
$scope.loadingData = false;
|
||||
$location.path('/register')
|
||||
}
|
||||
}).error(function(err) {
|
||||
console.error(err);
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
|
||||
|
||||
$scope.isEditMode = false;
|
||||
$scope.profileMode = "Edit Profile";
|
||||
$scope.profileModeIcon = "fa fa-pencil";
|
||||
|
@ -68,17 +70,17 @@ angular.module('SeHub')
|
|||
"campus_avatar": "https://yt3.ggpht.com/--ZkWxybWGOM/AAAAAAAAAAI/AAAAAAAAAAA/_nAICC_kzzI/s88-c-k-no/photo.jpg"
|
||||
}];
|
||||
|
||||
$scope.campuses = [{
|
||||
'title': 'JCE',
|
||||
'email_ending': '@post.jce.ac.il',
|
||||
'master_user_id': 123453433341,
|
||||
'avatar_url': 'https://yt3.ggpht.com/--ZkWxybWGOM/AAAAAAAAAAI/AAAAAAAAAAA/_nAICC_kzzI/s88-c-k-no/photo.jpg'
|
||||
}, {
|
||||
'title': 'Stanford',
|
||||
'email_ending': '@post.jce.ac.il',
|
||||
'master_user_id': 123453433341,
|
||||
'avatar_url': 'https://encrypted-tbn1.gstatic.com/images?q=tbn:ANd9GcR9M4uQgaJP1zyiCGw-dK31hU8buWqeuOi9vTXBd4Y8hQcFTZqA'
|
||||
}];
|
||||
// $scope.campuses = [{
|
||||
// 'title': 'JCE',
|
||||
// 'email_ending': '@post.jce.ac.il',
|
||||
// 'master_user_id': 123453433341,
|
||||
// 'avatar_url': 'https://yt3.ggpht.com/--ZkWxybWGOM/AAAAAAAAAAI/AAAAAAAAAAA/_nAICC_kzzI/s88-c-k-no/photo.jpg'
|
||||
// }, {
|
||||
// 'title': 'Stanford',
|
||||
// 'email_ending': '@post.jce.ac.il',
|
||||
// 'master_user_id': 123453433341,
|
||||
// 'avatar_url': 'https://encrypted-tbn1.gstatic.com/images?q=tbn:ANd9GcR9M4uQgaJP1zyiCGw-dK31hU8buWqeuOi9vTXBd4Y8hQcFTZqA'
|
||||
// }];
|
||||
|
||||
|
||||
$scope.labels = ['Commits', 'Issues Assigned', 'Messages', 'Open Tasks'];
|
||||
|
@ -89,9 +91,7 @@ angular.module('SeHub')
|
|||
[28, 48, 40, 3]
|
||||
];
|
||||
|
||||
$scope.isUser = function(){
|
||||
return $scope.user.id.toString() === $routeParams.id;
|
||||
}
|
||||
$scope.isUser = $scope.$parent.user.id.toString() /*The Actual User*/ === $routeParams.id /*The Profile User*/;
|
||||
|
||||
}
|
||||
]);
|
|
@ -48,14 +48,25 @@ service.factory('apiService', ['$http', function($http) {
|
|||
req = {
|
||||
method : "GET",
|
||||
url : url
|
||||
|
||||
};
|
||||
return $http(req);
|
||||
},
|
||||
getAllMessages: function(){
|
||||
getAllCourses: function(token){
|
||||
var url = (DEBUG ? "http://localhost:8080" : "http://se-hub.appspot.com") + "/api/courses/getAll/" + token;
|
||||
req = {
|
||||
method : "GET",
|
||||
url : url
|
||||
|
||||
};
|
||||
return $http(req);
|
||||
},
|
||||
getAllMessages: function(token){
|
||||
var url = (DEBUG ? "http://localhost:8080" : "http://se-hub.appspot.com") + "/api/courses/getAllMessages/" + token;
|
||||
req = {
|
||||
method : "GET",
|
||||
url : url
|
||||
|
||||
};
|
||||
return $http(req);
|
||||
},
|
||||
|
@ -65,6 +76,7 @@ service.factory('apiService', ['$http', function($http) {
|
|||
method : "POST",
|
||||
url : url,
|
||||
data: payLoad
|
||||
|
||||
};
|
||||
return $http(req);
|
||||
},
|
||||
|
@ -73,6 +85,7 @@ service.factory('apiService', ['$http', function($http) {
|
|||
req = {
|
||||
method : "GET",
|
||||
url : url
|
||||
|
||||
};
|
||||
return $http(req);
|
||||
},
|
||||
|
@ -82,14 +95,18 @@ service.factory('apiService', ['$http', function($http) {
|
|||
method : "POST",
|
||||
url : url,
|
||||
data: payLoad
|
||||
|
||||
};
|
||||
return $http(req);
|
||||
},
|
||||
getCampusesByUser: function(token){
|
||||
var url = (DEBUG ? "http://localhost:8080" : "http://se-hub.appspot.com") + "/api/courses/getCampusesByUser/" + token;
|
||||
getCampusesByUser: function(token){
|
||||
var url = (DEBUG ? "http://localhost:8080" : "http://se-hub.appspot.com") + "/api/campuses/getCampusesByUser/" + token;
|
||||
req = {
|
||||
method : "GET",
|
||||
url : url
|
||||
|
||||
};
|
||||
return $http(req);
|
||||
},
|
||||
|
@ -98,6 +115,7 @@ service.factory('apiService', ['$http', function($http) {
|
|||
req = {
|
||||
method : "GET",
|
||||
url : url
|
||||
|
||||
};
|
||||
return $http(req);
|
||||
},
|
||||
|
@ -106,6 +124,24 @@ service.factory('apiService', ['$http', function($http) {
|
|||
req = {
|
||||
method : "GET",
|
||||
url : url
|
||||
|
||||
};
|
||||
return $http(req);
|
||||
},
|
||||
getUserById: function(token, id){
|
||||
var url = (DEBUG ? "http://localhost:8080" : "http://se-hub.appspot.com") + "/api/users/getUserById/" + token + "/" + id;
|
||||
req = {
|
||||
method : "GET",
|
||||
url : url
|
||||
};
|
||||
return $http(req);
|
||||
},
|
||||
getCampusesByUserId: function(token, id){
|
||||
var url = (DEBUG ? "http://localhost:8080" : "http://se-hub.appspot.com") + "/api/campuses/getCampusesByUserID/" + token + "/" + id;
|
||||
req = {
|
||||
method : "GET",
|
||||
url : url
|
||||
|
||||
};
|
||||
return $http(req);
|
||||
}
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
<div>
|
||||
<div class="loader" ng-if="loadingData">
|
||||
<div class="loader" ng-if="loadingData" layout="row" layout-align="center">
|
||||
|
||||
<md-progress-circular md-mode="indeterminate"></md-progress-circular>
|
||||
|
||||
</div>
|
||||
<md-content layout-padding>
|
||||
<md-card layout-padding>
|
||||
|
@ -15,7 +17,7 @@
|
|||
<img ng-src="{{user.avatar_url}}" alt="" style="width:20%">
|
||||
</div>
|
||||
<div flex="70%">
|
||||
<md-button class="md-raised" ng-click="changeProfileMode()" ng-if="isUser()">
|
||||
<md-button class="md-raised" ng-click="changeProfileMode()" ng-if="isUser">
|
||||
<i ng-class="profileModeIcon"></i> {{profileMode}}
|
||||
</md-button>
|
||||
</div>
|
||||
|
@ -78,7 +80,7 @@
|
|||
</div>
|
||||
<div class="spacer"></div>
|
||||
<div>
|
||||
<md-button class="">
|
||||
<md-button class="" ng-if="isUser">
|
||||
X
|
||||
</md-button>
|
||||
</div>
|
||||
|
@ -96,11 +98,11 @@
|
|||
<img alt="{{ person.name }}" ng-src="{{ campus.avatar_url }}" class="md-avatar" />
|
||||
</div>
|
||||
<div class="port_spacer">
|
||||
{{ campus.title }} -
|
||||
<strong>{{ campus.title }}</strong> {{campus.email_ending}}
|
||||
</div>
|
||||
<div class="spacer"></div>
|
||||
<div>
|
||||
<md-button class="">
|
||||
<md-button class="" ng-if="isUser">
|
||||
X
|
||||
</md-button>
|
||||
</div>
|
||||
|
|
Loading…
Reference in a new issue