Skip to content

Commit

Permalink
Merge pull request anitab-org#179 from jaerjaerbin/docstringsfortaskdao
Browse files Browse the repository at this point in the history
docs: added doc strings for TaskDao class and its functions
  • Loading branch information
isabelcosta authored Feb 21, 2019
2 parents 226b573 + 82156ec commit 80bacb8
Showing 1 changed file with 57 additions and 0 deletions.
57 changes: 57 additions & 0 deletions app/api/dao/task.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,25 @@


class TaskDAO:
"""Data Access Object for Task functionalities."""

@staticmethod
def create_task(user_id, mentorship_relation_id, data):
"""Creates a new task.
Creates a new task in a mentorship relation if the specified user is already involved in it.
Args:
user_id: The id of the user.
mentorship_relation_id: The id of the mentorship relation.
data: A list containing the description of the task.
Returns:
A two element list where the first element is a dictionary containing a key 'message' indicating
in its value if the task creation was succesful or not as a string. The last element is the HTTP
response code.
"""

description = data['description']

user = UserModel.find_by_id(user_id)
Expand All @@ -30,6 +46,19 @@ def create_task(user_id, mentorship_relation_id, data):

@staticmethod
def list_tasks(user_id, mentorship_relation_id):
"""Retrieves all tasks of a user in a mentorship relation.
Lists all tasks from a mentorship relation for the specified user if the user is involved in a current mentorship relation.
Args:
user_id: The id of the user.
mentorship_relation_id: The id of the mentorship relation.
Returns:
A list containing all the tasks one user has in a mentorship relation. otherwise, it returns a two element list where the first element is
a dictionary containing a key 'message' indicating in its value if there were any problem finding user's tasks in the specified
mentorship relation as a string. The last element is the HTTP response code
"""

user = UserModel.find_by_id(user_id)
if user is None:
Expand All @@ -48,6 +77,20 @@ def list_tasks(user_id, mentorship_relation_id):

@staticmethod
def delete_task(user_id, mentorship_relation_id, task_id):
"""Deletes a specified task from a mentorship relation.
Deletes a task that belongs to a user who is involved in the specified
mentorship relation.
Args:
user_id: The id of the user.
mentorship_relation_id: The id of the mentorship relation.
task_id: The id of the task.
Returns:
A two element list where the first element is a dictionary containing a key 'message' indicating in its value if the
task was deleted succesfully or not as a string. The last element is the HTTP response code.
"""

user = UserModel.find_by_id(user_id)
if user is None:
Expand All @@ -70,6 +113,20 @@ def delete_task(user_id, mentorship_relation_id, task_id):

@staticmethod
def complete_task(user_id, mentorship_relation_id, task_id):
"""Marks a task as completed.
Updates the task that belongs to a user who is involved in the specified
mentorship relation to finished task status.
Args:
user_id: The id of the user.
mentorship_relation_id: The id of the mentorship relation.
task_id: The id of the task.
Returns:
A two element list where the first element is a dictionary containing a key 'message' indicating in its value
if the task was set to complete succesfully or not as a string. The last element is the HTTP response code.
"""

user = UserModel.find_by_id(user_id)
if user is None:
Expand Down

0 comments on commit 80bacb8

Please sign in to comment.