Merge branch 'master' of https://github.com/sagidayan/SE-Hub into UI
This commit is contained in:
commit
a80df36fcb
6 changed files with 44 additions and 26 deletions
|
@ -126,8 +126,8 @@ def joinCampus(token, campusId):
|
|||
if campus is None:
|
||||
return bad_request("No such course")
|
||||
|
||||
if user.key().id() in campus.membersId:
|
||||
return no_content("User is already member in Project")
|
||||
if str(user.key().id()) in campus.membersId:
|
||||
return bad_request("User is already member in Project")
|
||||
|
||||
campus.membersId.append(str(user.key().id()))
|
||||
user.courses_id_list.append(str(campus.key().id()))
|
||||
|
|
|
@ -149,8 +149,8 @@ def joinCourse(token, courseId):
|
|||
if course is None:
|
||||
return bad_request("No such course")
|
||||
|
||||
if user.key().id() in course.membersId:
|
||||
return no_content("User is already member in Project")
|
||||
if str(user.key().id()) in course.membersId:
|
||||
return bad_request("User is already member in Course")
|
||||
|
||||
course.membersId.append(str(user.key().id()))
|
||||
user.courses_id_list.append(str(course.key().id()))
|
||||
|
|
|
@ -1,21 +1,23 @@
|
|||
__author__ = 'sagi'
|
||||
import requests
|
||||
from GithubAPI.GithubAPI import GitHubAPI_Keys
|
||||
|
||||
githubKeys = GitHubAPI_Keys()
|
||||
|
||||
def get_repo_general_info(repo_url):
|
||||
url = 'https://api.github.com/repos/' + repo_url
|
||||
url = 'https://api.github.com/repos/' + repo_url + '?client_id='+githubKeys.getId()+'&client_secret=' + githubKeys.getSecret()
|
||||
req = requests.get(url)
|
||||
return req.json()
|
||||
|
||||
|
||||
def get_repo_stats(repo_url):
|
||||
url = 'https://api.github.com/repos/' + repo_url + '/stats/contributors'
|
||||
url = 'https://api.github.com/repos/' + repo_url + '/stats/contributors' + '?client_id='+githubKeys.getId()+'&client_secret=' + githubKeys.getSecret()
|
||||
req = requests.get(url)
|
||||
return req.json()
|
||||
|
||||
|
||||
def get_repo_issues(repo_url):
|
||||
url = 'https://api.github.com/repos/' + repo_url + '/issues'
|
||||
url = 'https://api.github.com/repos/' + repo_url + '/issues' + '?client_id=' + githubKeys.getId() + '&client_secret=' + githubKeys.getSecret()
|
||||
req = requests.get(url)
|
||||
return req.json()
|
||||
|
||||
|
|
|
@ -122,8 +122,8 @@ def joinProject(token, projectId):
|
|||
if project is None:
|
||||
return bad_request("No such Project")
|
||||
|
||||
if user.key().id() in project.membersId:
|
||||
return no_content("User is already member in Project")
|
||||
if str(user.key().id()) in project.membersId:
|
||||
return bad_request("User is already member in Project")
|
||||
|
||||
project.membersId.append(str(user.key().id()))
|
||||
|
||||
|
@ -174,6 +174,7 @@ def getProjectsByCourse(token, courseId):
|
|||
|
||||
if get_user_by_token(token) is None:
|
||||
return bad_request("Bad User Token")
|
||||
|
||||
arr = []
|
||||
query = Project.all()
|
||||
query.filter("courseId = ", int(courseId))
|
||||
|
@ -233,7 +234,9 @@ def getProjectsByUser(token):
|
|||
arr = []
|
||||
for p in user.projects_id_list:
|
||||
project = Project.get_by_id(int(p))
|
||||
arr.append(dict(json.loads(project.to_JSON())))
|
||||
projDict = dict(json.loads(project.to_JSON()))
|
||||
projDict['info'] = get_github_data(project.gitRepository)
|
||||
arr.append(projDict)
|
||||
|
||||
if len(arr) != 0:
|
||||
return Response(response=json.dumps(arr),
|
||||
|
|
|
@ -18,6 +18,11 @@ angular.module('SeHub')
|
|||
apiService.getCampusesByUserId(token, id).success(function(data) {
|
||||
$scope.campuses = data;
|
||||
console.log(data);
|
||||
apiService.getCoursesByUserID(token, id).success(function(data){
|
||||
$scope.courses = data;
|
||||
}).error(function(err){
|
||||
console.error('In apiService.getCoursesByUserID', err);
|
||||
})
|
||||
|
||||
$scope.loadingData = false;
|
||||
}).error(function(err) {
|
||||
|
@ -53,22 +58,22 @@ angular.module('SeHub')
|
|||
/**
|
||||
* DEBUG DATA
|
||||
*/
|
||||
$scope.courses = [{
|
||||
"courseName": "Advance Math",
|
||||
"campusName": "JCE",
|
||||
"startDate": {
|
||||
"year": 2015,
|
||||
"month": 4,
|
||||
"day": 3
|
||||
},
|
||||
"endDate": {
|
||||
"year": 2016,
|
||||
"month": 5,
|
||||
"day": 14
|
||||
},
|
||||
"taskFlag": false,
|
||||
"campus_avatar": "https://yt3.ggpht.com/--ZkWxybWGOM/AAAAAAAAAAI/AAAAAAAAAAA/_nAICC_kzzI/s88-c-k-no/photo.jpg"
|
||||
}];
|
||||
// $scope.courses = [{
|
||||
// "courseName": "Advance Math",
|
||||
// "campusName": "JCE",
|
||||
// "startDate": {
|
||||
// "year": 2015,
|
||||
// "month": 4,
|
||||
// "day": 3
|
||||
// },
|
||||
// "endDate": {
|
||||
// "year": 2016,
|
||||
// "month": 5,
|
||||
// "day": 14
|
||||
// },
|
||||
// "taskFlag": false,
|
||||
// "campus_avatar": "https://yt3.ggpht.com/--ZkWxybWGOM/AAAAAAAAAAI/AAAAAAAAAAA/_nAICC_kzzI/s88-c-k-no/photo.jpg"
|
||||
// }];
|
||||
|
||||
// $scope.campuses = [{
|
||||
// 'title': 'JCE',
|
||||
|
|
|
@ -177,6 +177,14 @@ service.factory('apiService', ['$http', function($http) {
|
|||
data: payLoad
|
||||
};
|
||||
return $http(req);
|
||||
},
|
||||
getCoursesByUserID: function(token, userId){
|
||||
var url = (DEBUG ? "http://localhost:8080" : "http://se-hub.appspot.com") + "/api/courses/getCoursesByUser/" + token + "/" + userId;
|
||||
req = {
|
||||
method : "GET",
|
||||
url : url
|
||||
};
|
||||
return $http(req);
|
||||
}
|
||||
};
|
||||
}]);
|
Loading…
Reference in a new issue