Merge pull request #88 from sagidayan/API_Dev

Api dev
This commit is contained in:
Sagi Dayan 2015-06-29 14:46:34 +03:00
commit 518c0c36ef
3 changed files with 10 additions and 7 deletions

View file

@ -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()))

View file

@ -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()))

View file

@ -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),