From edac533f2b6b10ba04735bb890c6972df4e22224 Mon Sep 17 00:00:00 2001 From: Sagi Dayan Date: Mon, 29 Jun 2015 14:21:17 +0300 Subject: [PATCH 1/3] AngularJS Service getCoursesByUserID --- templates/js/services/apiService.js | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/templates/js/services/apiService.js b/templates/js/services/apiService.js index d94388f..268ad36 100644 --- a/templates/js/services/apiService.js +++ b/templates/js/services/apiService.js @@ -168,6 +168,15 @@ 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, + data: payLoad + }; + return $http(req); } }; }]); \ No newline at end of file From f0031dca167e3cefd27a66645d4b1adb1317dbdb Mon Sep 17 00:00:00 2001 From: Sagi Dayan Date: Mon, 29 Jun 2015 14:25:20 +0300 Subject: [PATCH 2/3] Fix to the GetCoursesByUserId in Profile --- templates/js/controllers/profileController.js | 37 +++++++++++-------- templates/js/services/apiService.js | 3 +- 2 files changed, 22 insertions(+), 18 deletions(-) diff --git a/templates/js/controllers/profileController.js b/templates/js/controllers/profileController.js index 80bfa6a..208b08a 100644 --- a/templates/js/controllers/profileController.js +++ b/templates/js/controllers/profileController.js @@ -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', diff --git a/templates/js/services/apiService.js b/templates/js/services/apiService.js index 268ad36..5333a51 100644 --- a/templates/js/services/apiService.js +++ b/templates/js/services/apiService.js @@ -173,8 +173,7 @@ service.factory('apiService', ['$http', function($http) { var url = (DEBUG ? "http://localhost:8080" : "http://se-hub.appspot.com") + "/api/courses/getCoursesByUser/" + token + "/" + userId; req = { method : "GET", - url : url, - data: payLoad + url : url }; return $http(req); } From 58ee4f4da512422841256ddf583099165e386895 Mon Sep 17 00:00:00 2001 From: Sagi Dayan Date: Mon, 29 Jun 2015 14:41:21 +0300 Subject: [PATCH 3/3] Extended Github API request calls with ID+Secret --- SE_API/GitHub_API_Connector.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/SE_API/GitHub_API_Connector.py b/SE_API/GitHub_API_Connector.py index 78fbf85..dbafa03 100644 --- a/SE_API/GitHub_API_Connector.py +++ b/SE_API/GitHub_API_Connector.py @@ -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()