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:
|
if campus is None:
|
||||||
return bad_request("No such course")
|
return bad_request("No such course")
|
||||||
|
|
||||||
if user.key().id() in campus.membersId:
|
if str(user.key().id()) in campus.membersId:
|
||||||
return no_content("User is already member in Project")
|
return bad_request("User is already member in Project")
|
||||||
|
|
||||||
campus.membersId.append(str(user.key().id()))
|
campus.membersId.append(str(user.key().id()))
|
||||||
user.courses_id_list.append(str(campus.key().id()))
|
user.courses_id_list.append(str(campus.key().id()))
|
||||||
|
|
|
@ -149,8 +149,8 @@ def joinCourse(token, courseId):
|
||||||
if course is None:
|
if course is None:
|
||||||
return bad_request("No such course")
|
return bad_request("No such course")
|
||||||
|
|
||||||
if user.key().id() in course.membersId:
|
if str(user.key().id()) in course.membersId:
|
||||||
return no_content("User is already member in Project")
|
return bad_request("User is already member in Course")
|
||||||
|
|
||||||
course.membersId.append(str(user.key().id()))
|
course.membersId.append(str(user.key().id()))
|
||||||
user.courses_id_list.append(str(course.key().id()))
|
user.courses_id_list.append(str(course.key().id()))
|
||||||
|
|
|
@ -1,21 +1,23 @@
|
||||||
__author__ = 'sagi'
|
__author__ = 'sagi'
|
||||||
import requests
|
import requests
|
||||||
|
from GithubAPI.GithubAPI import GitHubAPI_Keys
|
||||||
|
|
||||||
|
githubKeys = GitHubAPI_Keys()
|
||||||
|
|
||||||
def get_repo_general_info(repo_url):
|
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)
|
req = requests.get(url)
|
||||||
return req.json()
|
return req.json()
|
||||||
|
|
||||||
|
|
||||||
def get_repo_stats(repo_url):
|
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)
|
req = requests.get(url)
|
||||||
return req.json()
|
return req.json()
|
||||||
|
|
||||||
|
|
||||||
def get_repo_issues(repo_url):
|
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)
|
req = requests.get(url)
|
||||||
return req.json()
|
return req.json()
|
||||||
|
|
||||||
|
|
|
@ -122,8 +122,8 @@ def joinProject(token, projectId):
|
||||||
if project is None:
|
if project is None:
|
||||||
return bad_request("No such Project")
|
return bad_request("No such Project")
|
||||||
|
|
||||||
if user.key().id() in project.membersId:
|
if str(user.key().id()) in project.membersId:
|
||||||
return no_content("User is already member in Project")
|
return bad_request("User is already member in Project")
|
||||||
|
|
||||||
project.membersId.append(str(user.key().id()))
|
project.membersId.append(str(user.key().id()))
|
||||||
|
|
||||||
|
@ -174,6 +174,7 @@ def getProjectsByCourse(token, courseId):
|
||||||
|
|
||||||
if get_user_by_token(token) is None:
|
if get_user_by_token(token) is None:
|
||||||
return bad_request("Bad User Token")
|
return bad_request("Bad User Token")
|
||||||
|
|
||||||
arr = []
|
arr = []
|
||||||
query = Project.all()
|
query = Project.all()
|
||||||
query.filter("courseId = ", int(courseId))
|
query.filter("courseId = ", int(courseId))
|
||||||
|
@ -233,7 +234,9 @@ def getProjectsByUser(token):
|
||||||
arr = []
|
arr = []
|
||||||
for p in user.projects_id_list:
|
for p in user.projects_id_list:
|
||||||
project = Project.get_by_id(int(p))
|
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:
|
if len(arr) != 0:
|
||||||
return Response(response=json.dumps(arr),
|
return Response(response=json.dumps(arr),
|
||||||
|
|
|
@ -18,6 +18,11 @@ angular.module('SeHub')
|
||||||
apiService.getCampusesByUserId(token, id).success(function(data) {
|
apiService.getCampusesByUserId(token, id).success(function(data) {
|
||||||
$scope.campuses = data;
|
$scope.campuses = data;
|
||||||
console.log(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;
|
$scope.loadingData = false;
|
||||||
}).error(function(err) {
|
}).error(function(err) {
|
||||||
|
@ -53,22 +58,22 @@ angular.module('SeHub')
|
||||||
/**
|
/**
|
||||||
* DEBUG DATA
|
* DEBUG DATA
|
||||||
*/
|
*/
|
||||||
$scope.courses = [{
|
// $scope.courses = [{
|
||||||
"courseName": "Advance Math",
|
// "courseName": "Advance Math",
|
||||||
"campusName": "JCE",
|
// "campusName": "JCE",
|
||||||
"startDate": {
|
// "startDate": {
|
||||||
"year": 2015,
|
// "year": 2015,
|
||||||
"month": 4,
|
// "month": 4,
|
||||||
"day": 3
|
// "day": 3
|
||||||
},
|
// },
|
||||||
"endDate": {
|
// "endDate": {
|
||||||
"year": 2016,
|
// "year": 2016,
|
||||||
"month": 5,
|
// "month": 5,
|
||||||
"day": 14
|
// "day": 14
|
||||||
},
|
// },
|
||||||
"taskFlag": false,
|
// "taskFlag": false,
|
||||||
"campus_avatar": "https://yt3.ggpht.com/--ZkWxybWGOM/AAAAAAAAAAI/AAAAAAAAAAA/_nAICC_kzzI/s88-c-k-no/photo.jpg"
|
// "campus_avatar": "https://yt3.ggpht.com/--ZkWxybWGOM/AAAAAAAAAAI/AAAAAAAAAAA/_nAICC_kzzI/s88-c-k-no/photo.jpg"
|
||||||
}];
|
// }];
|
||||||
|
|
||||||
// $scope.campuses = [{
|
// $scope.campuses = [{
|
||||||
// 'title': 'JCE',
|
// 'title': 'JCE',
|
||||||
|
|
|
@ -177,6 +177,14 @@ service.factory('apiService', ['$http', function($http) {
|
||||||
data: payLoad
|
data: payLoad
|
||||||
};
|
};
|
||||||
return $http(req);
|
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