From bd224fb7d8d2be2681b675f1b5c0a527f9165413 Mon Sep 17 00:00:00 2001 From: aranzaiger Date: Mon, 29 Jun 2015 14:10:46 +0300 Subject: [PATCH 1/2] added project data from github to GET function --- SE_API/ProjectRoutes.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/SE_API/ProjectRoutes.py b/SE_API/ProjectRoutes.py index 5406544..084bc12 100644 --- a/SE_API/ProjectRoutes.py +++ b/SE_API/ProjectRoutes.py @@ -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), From 2064e19d2b12ab2212a172467b625f7bbe233cc6 Mon Sep 17 00:00:00 2001 From: aranzaiger Date: Mon, 29 Jun 2015 14:28:48 +0300 Subject: [PATCH 2/2] fix big allowing to add user to project/course/campus more then once --- SE_API/CampusRoutes.py | 4 ++-- SE_API/CourseRoutes.py | 4 ++-- SE_API/ProjectRoutes.py | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/SE_API/CampusRoutes.py b/SE_API/CampusRoutes.py index 2d5e4c0..40ec281 100644 --- a/SE_API/CampusRoutes.py +++ b/SE_API/CampusRoutes.py @@ -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())) diff --git a/SE_API/CourseRoutes.py b/SE_API/CourseRoutes.py index c651a60..4a282bc 100644 --- a/SE_API/CourseRoutes.py +++ b/SE_API/CourseRoutes.py @@ -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())) diff --git a/SE_API/ProjectRoutes.py b/SE_API/ProjectRoutes.py index 084bc12..59127c9 100644 --- a/SE_API/ProjectRoutes.py +++ b/SE_API/ProjectRoutes.py @@ -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()))