-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #22 from it-goats/feature/ITG-44
[ITG-44] Implementacja endpointu GET do pobrania zadań będących w relacji z danym zadaniem
- Loading branch information
Showing
10 changed files
with
147 additions
and
54 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
from bode.app import db | ||
from bode.models.task import Task | ||
from bode.models.task_relation import RelationType, TaskRelation | ||
|
||
|
||
def delete_task(task_id): | ||
"""Function deletes task, all it's relations and all it's subtasks reursively.""" | ||
|
||
def is_subtask_relation(relation, task_id): | ||
return relation.type == RelationType.Subtask.value and str(relation.first_task_id) == task_id | ||
|
||
relation_task_pairs = TaskRelation.get_related_tasks(task_id) | ||
|
||
for relation, related_task in relation_task_pairs: | ||
TaskRelation.delete(relation.id) | ||
if is_subtask_relation(relation, task_id): | ||
delete_task(str(related_task.id)) | ||
|
||
task = Task.get(task_id) | ||
db.session.delete(task) | ||
db.session.commit() | ||
return task |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters