From c826b06f02861ef33f40c06019c9960dfa4d5036 Mon Sep 17 00:00:00 2001 From: aranzaiger Date: Sun, 2 Aug 2015 12:34:20 +0300 Subject: [PATCH 1/4] added getAllFutureTasks --- SE_API/TaskRoutes.py | 71 ++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 69 insertions(+), 2 deletions(-) diff --git a/SE_API/TaskRoutes.py b/SE_API/TaskRoutes.py index a7ec923..e9f2363 100644 --- a/SE_API/TaskRoutes.py +++ b/SE_API/TaskRoutes.py @@ -218,9 +218,9 @@ def getAllTasksByCourse(token, courseId): return no_content() -@task_routes.route('/api/tasks/getAllFutureTasks//', methods=["GET"]) +@task_routes.route('/api/tasks/getAllFutureCampusTasks//', methods=["GET"]) @auto.doc() -def getAllFutureTasks(token, courseId): +def getAllFutureCampusTasks(token, courseId): """ >This Call will return an array of all Future Tasks in a course, ordered by date
@@ -284,6 +284,73 @@ def getAllFutureTasks(token, courseId): else: return no_content() +@task_routes.route('/api/tasks/getAllFutureTasks/', methods=["GET"]) +@auto.doc() +def getAllFutureCampusTasks(token): + """ + >This Call will return an array of all Future Tasks ordered by date +
+ Route Parameters
+ - SeToken: token
+
+
+ Payload
+ - NONE +
+
+ Response +
+ 200 - JSON Example:
+ + {
+ 'title' : 'Task1',
+ 'courseName' : 'advance Math',
+ 'description' : 'prepare by sunday',
+ 'dueDate' : { + 'year' : 2015, + 'month' : 12, + 'day' : 23 + }
+ 'isPersonal' : true,
+ 'task_id' : 589689456894
+ }
+
+
+ """ + + user = get_user_by_token + if user is None: + return bad_request("Bad User Token") + + arr = [] + + for courseId in user.courses_id_list: + query = Task.all() + + try: + query.filter("courseId = ", int(courseId)) + except Exception as e: + return bad_request("Bad id format") + + for t in query.run(): + taskDic =dict(json.loads(t.to_JSON())) + #add a key 'forSortDate' for sorting dates + taskTime = datetime.datetime(taskDic['dueDate']['year'], taskDic['dueDate']['month'], taskDic['dueDate']['day']) + if taskTime >= datetime.date.today(): + taskDic['forSortDate'] = taskTime + arr.append(taskDic) + + #sort array by date, and remove added key + arr = sorted(arr, key=itemgetter('forSortDate'), reverse=False) + for i in arr: + del i['forSortDate'] + + if len(arr) != 0: + return Response(response=json.dumps(arr), + status=200, + mimetype="application/json") + else: + return no_content() @task_routes.route('/api/tasks/getTaskComponents//', methods=["GET"]) From dc41da5007f2471f27e9d3cc0f726342140803ae Mon Sep 17 00:00:00 2001 From: aranzaiger Date: Sun, 2 Aug 2015 12:35:06 +0300 Subject: [PATCH 2/4] removing all users from project when it is deleted by creator --- SE_API/ProjectRoutes.py | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/SE_API/ProjectRoutes.py b/SE_API/ProjectRoutes.py index 943f8bf..a2d1383 100644 --- a/SE_API/ProjectRoutes.py +++ b/SE_API/ProjectRoutes.py @@ -372,12 +372,22 @@ def deleteProject(token,projectId): if p is None: return bad_request("no such Project") - if p.master_id == user.key().id(): - db.delete(p) - db.save - return accepted("Project deleted") + if p.master_id != user.key().id(): + return forbidden("user is not owner of Project") + + #remove all users related to project + for uId in p.membersId: + user = User.get_by_id(uId) + if user is None: + return bad_request("trying to remove a user from project failed") + user.projects_id_list.remove(p.key().id()) + db.put(user) + + + db.delete(p) + db.save + return accepted("Project deleted") - return forbidden("user is not owner of Project") From 2b0fc51b8b230a17d7e4094ae0690c3898d78b83 Mon Sep 17 00:00:00 2001 From: aranzaiger Date: Sun, 2 Aug 2015 12:53:10 +0300 Subject: [PATCH 3/4] fix --- SE_API/TaskRoutes.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SE_API/TaskRoutes.py b/SE_API/TaskRoutes.py index e9f2363..c587901 100644 --- a/SE_API/TaskRoutes.py +++ b/SE_API/TaskRoutes.py @@ -286,7 +286,7 @@ def getAllFutureCampusTasks(token, courseId): @task_routes.route('/api/tasks/getAllFutureTasks/', methods=["GET"]) @auto.doc() -def getAllFutureCampusTasks(token): +def getAllFutureTasks(token): """ >This Call will return an array of all Future Tasks ordered by date
From b853793bbbfeffd780b4fd82ce5e594bda3dd8c4 Mon Sep 17 00:00:00 2001 From: aranzaiger Date: Sun, 2 Aug 2015 13:11:22 +0300 Subject: [PATCH 4/4] fix --- models/Message.py | 2 +- models/Task.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/models/Message.py b/models/Message.py index 67906f9..1a64564 100644 --- a/models/Message.py +++ b/models/Message.py @@ -8,7 +8,7 @@ from models.Course import Course class Message(db.Model): groupId = db.IntegerProperty(required=True) - message = db.StringProperty(required=True) + message = db.StringProperty(required=True, multiline=True) msgDate = db.DateTimeProperty(required=True) master_id = db.IntegerProperty(required=True) isProject = db.BooleanProperty(default=False) diff --git a/models/Task.py b/models/Task.py index 5449fa2..1dd422a 100644 --- a/models/Task.py +++ b/models/Task.py @@ -15,7 +15,7 @@ class Task(db.Model): data = {'title' : self.title, 'courseId' : self.courseId, 'description' : self.description, - 'dueDate' : { + 'dueDate' : { 'year': self.dueDate.year, 'month': self.dueDate.month, 'day': self.dueDate.day