Beispiel #1
0
def delete_task_tree(user, task):
    for index, subtask in enumerate(task.subtasks.all()):
        if subtask.subtasks.exists():
            delete_task_tree(user, subtask)
        tags_list = subtask.tags.all()
        delete_orphan_tags(subtask, tags_list)
        if subtask.shared_with.exists():
            update_log(user, subtask, LOG_TASK_DELETE)
        subtask.delete()
Beispiel #2
0
def update_tag_set(task_object, latest_tags):
    '''
    Takes input a task object and a list of the latest tags.
    All the task's tags have to be replaced by the new tags. This function
    deletes the task's old tags, and adds the new ones
    '''
    to_be_deleted = list(set(task_object.tags.all()) - set(latest_tags))
    to_be_added = list(set(latest_tags) - set(task_object.tags.all()))
    task_object.tags.remove(*to_be_deleted)
    delete_orphan_tags(task_object, to_be_deleted)
    task_object.tags.add(*to_be_added)
Beispiel #3
0
def delete_single_task(user, task):
    tags_list = task.tags.all()
    delete_orphan_tags(task, tags_list)
    if task.shared_with.exists():
        update_log(user, task, LOG_TASK_DELETE)
    task.delete()