diff --git a/SE_API/ProjectRoutes.py b/SE_API/ProjectRoutes.py index b879634..5406544 100644 --- a/SE_API/ProjectRoutes.py +++ b/SE_API/ProjectRoutes.py @@ -231,7 +231,7 @@ def getProjectsByUser(token): arr = [] - for p in user['projects_id_list']: + for p in user.projects_id_list: project = Project.get_by_id(int(p)) arr.append(dict(json.loads(project.to_JSON()))) diff --git a/SE_API/TaskRoutes.py b/SE_API/TaskRoutes.py index ab36b2e..136a2ab 100644 --- a/SE_API/TaskRoutes.py +++ b/SE_API/TaskRoutes.py @@ -153,14 +153,15 @@ def create_task(token): #---------------------------------------------------------- -@task_routes.route('/api/tasks/getAllTasks/', methods=["GET"]) +@task_routes.route('/api/tasks/getAllTasksByCourse//', methods=["GET"]) @auto.doc() -def getAllTasks(courseName): +def getAllTasksByCourse(token, courseId): """ - >This Call will return an array of all Tasks in a course by date + >This Call will return an array of all Tasks in a course ordered by date
Route Parameters
- - name: 'course name' + - SeToken: token
+ - courseId: 1234567890

Payload
@@ -173,7 +174,7 @@ def getAllTasks(courseName): {
'title' : 'Task1',
- 'courseName' : 'advance Math',
+ 'courseId' : 12345678,
'description' : 'prepare by sunday',
'dueDate' : { 'year' : 2015, @@ -186,10 +187,12 @@ def getAllTasks(courseName):

""" + if get_user_by_token(token) is None: + return bad_request("Bad User Token") arr = [] query = Task.all() - query.filter("courseName = ", courseName) + query.filter("courseId = ", courseId) for t in query.run(): taskDic =dict(json.loads(t.to_JSON())) @@ -211,14 +214,15 @@ def getAllTasks(courseName): return no_content() -@task_routes.route('/api/tasks/getAllFutureTasks/', methods=["GET"]) +@task_routes.route('/api/tasks/getAllFutureTasks//', methods=["GET"]) @auto.doc() -def getAllFutureTasks(courseName): +def getAllFutureTasks(token, courseId): """ >This Call will return an array of all Future Tasks in a course, ordered by date
Route Parameters
- - name: 'course name' + - SeToken: token
+ - courseId: 1234567890

Payload
@@ -245,9 +249,12 @@ def getAllFutureTasks(courseName):
""" + if get_user_by_token(token) is None: + return bad_request("Bad User Token") + arr = [] query = Task.all() - query.filter("courseName = ", courseName) + query.filter("courseId = ", courseId) for t in query.run(): taskDic =dict(json.loads(t.to_JSON())) @@ -271,14 +278,15 @@ def getAllFutureTasks(courseName): -@task_routes.route('/api/tasks/getTaskComponents/', methods=["GET"]) +@task_routes.route('/api/tasks/getTaskComponents//', methods=["GET"]) @auto.doc() -def getTaskComponents(taskId): +def getTaskComponents(token, taskId): """ >This Call will return an array of all components for a given task
Route Parameters
- - taskId: integer + - SeToken: token
+ - taskId: 1234567890

Payload
@@ -311,6 +319,9 @@ def getTaskComponents(taskId):
""" + if get_user_by_token(token) is None: + return bad_request("Bad User Token") + arr = [] query = TaskComponent.all() query.filter("taskId = ", taskId) @@ -336,15 +347,15 @@ def getTaskComponents(taskId): -@task_routes.route('/api/tasks/deleteTask//', methods=['DELETE']) +@task_routes.route('/api/tasks/deleteTask//', methods=['DELETE']) @auto.doc() -def deleteTask(token,taskid): +def deleteTask(token, taskId): """ This Call will delete a specific Task
Route Parameters
- seToken: 'seToken' - - taskid: 'taskid' + - taskId: 'taskid'

Payload
@@ -373,7 +384,7 @@ def deleteTask(token,taskid): #return forbidden("lecturer is not owner of course") user = get_user_by_token(token) - c = Task.get_by_id(int(taskid)) + c = Task.get_by_id(int(taskId)) if c is None: return bad_request("no such Task") @@ -384,15 +395,15 @@ def deleteTask(token,taskid): return accepted("Task deleted") -@task_routes.route('/api/tasks/deleteTaskComponents//', methods=['DELETE']) +@task_routes.route('/api/tasks/deleteTaskComponents//', methods=['DELETE']) @auto.doc() -def deleteTaskComponents(token,taskid): +def deleteTaskComponents(token,taskId): """ This Call will delete a specific Task's components
Route Parameters
- seToken: 'seToken' - - taskid: 'taskid' + - taskId: 'taskid'

Payload
@@ -421,7 +432,7 @@ def deleteTaskComponents(token,taskid): #return forbidden("lecturer is not owner of course") user = get_user_by_token(token) - t = Task.get_by_id(int(taskid)) + t = Task.get_by_id(int(taskId)) if t is None: return bad_request("no such Task") diff --git a/SE_API/UserRoutes.py b/SE_API/UserRoutes.py index c7f9f9c..a21e997 100644 --- a/SE_API/UserRoutes.py +++ b/SE_API/UserRoutes.py @@ -53,7 +53,6 @@ def updateUser(token): {
'name': 'new name',
'isLecturer': true,
- 'campusName': 'JCE'
}

Response @@ -80,10 +79,6 @@ def updateUser(token): except Exception: pass - try: - user.campusName = payload['campusName'] - except Exception: - pass try: user.isLecturer = payload['isLecturer'] diff --git a/models/Task.py b/models/Task.py index cdbaae9..5449fa2 100644 --- a/models/Task.py +++ b/models/Task.py @@ -6,14 +6,14 @@ from google.appengine.ext import db class Task(db.Model): title = db.StringProperty(required=True) - courseName = db.StringProperty(required=True) + courseId = db.IntegerProperty(required=True) description = db.StringProperty(required=True,default=" ") dueDate = db.DateProperty(required=True) isPersonal = db.BooleanProperty(required=True, default=True) def to_JSON(self): data = {'title' : self.title, - 'courseName' : self.courseName, + 'courseId' : self.courseId, 'description' : self.description, 'dueDate' : { 'year': self.dueDate.year, diff --git a/models/User.py b/models/User.py index bb60c2b..b413008 100644 --- a/models/User.py +++ b/models/User.py @@ -12,7 +12,6 @@ class User(db.Model): seToken = db.StringProperty(required=True) avatar_url = db.StringProperty(required=True) isFirstLogin = db.BooleanProperty(default=True) - campusName = db.StringProperty(required=True, default=" ") campuses_id_list = db.StringListProperty(default=[]) courses_id_list = db.StringListProperty(default=[]) projects_id_list = db.StringListProperty(default=[]) @@ -24,7 +23,6 @@ class User(db.Model): 'isLecturer' : self.isLecturer, 'avatar_url' : self.avatar_url, 'isFirstLogin' : self.isFirstLogin, - 'campusName': self.campusName, 'campuses_id_list': self.campuses_id_list, 'courses_id_list': self.courses_id_list, 'projects_id_list': self.projects_id_list,