tik_manager4.objects.subproject

Attributes

LOG

Classes

Subproject

Subproject object to hold subproject data and hierarchy.

Module Contents

class Subproject(parent_sub=None, metadata=None, **kwargs)

Bases: tik_manager4.objects.entity.Entity

Subproject object to hold subproject data and hierarchy.

Subproject objects doesn’t have any settings file. They are populated by the project object using the project_structure.json.

add_sub_project(name, parent_sub=None, uid=None, **properties)

Add a subproject.

Requires permissions. Does NOT create folders or store in the persistent database. Either parent_sub or uid is required.

Args:

name (str): Name of the subproject. parent_sub (Subproject, optional): Parent subproject object. uid (int, optional): Unique id of the subproject. deleted (bool, optional): Whether the subproject is deleted or not.

Default is False.

**properties (dict): Any extra properties to be added to the subproject.

Returns:
Subproject or int: The created subproject object if successful,

-1 otherwise.

add_task(name, categories, task_type=None, metadata_overrides=None, uid=None, force_edit=False)

Add a task to the subproject.

Args:

name (str): Name of the task. categories (list): List of categories. task_type (str, optional): Type of the task. If not given,

it is inherited from the parent subproject (mode).

metadata_overrides (dict, optional): Metadata overrides for the task. uid (int, optional): Unique id of the task. force_edit (bool, optional): If True, and if a task with the same name

exists, it will be edited with the given settings..

Returns:

Task or int: The created task object if successful, -1 otherwise.

create_folders(root, sub=None)

Create folders for subprojects and categories below given root path.

Args:

root (str): The root path. sub (Subproject, optional): The subproject object. If not given the

current subproject is used.

delete_task(task_name)

Delete the task from the subproject.

Args:

task_name (str): Name of the task to delete.

Returns:
tuple: (state(int), message(str)): 1 if the operation is

successful, -1 otherwise. A message is returned as well.

destroy()

Destroy the subproject object.

This will tag the subproject and all its children as deleted. The subproject will not be removed from the database as it is getting controlled with the project object.

find_sub_by_id(uid)

Find the subproject by id.

Args:

uid (int): Unique id of the subproject.

Returns:
Subproject or int: The subproject object if successful,

-1 otherwise.

find_sub_by_path(path)

Find the subproject by path.

Args:

path (str): The path of the subproject.

Returns:
Subproject or int: The subproject object if successful,

-1 otherwise.

find_subs_by_wildcard(wildcard)

Find the subproject by wildcard.

Args:

wildcard (str): The wildcard to match.

Returns:

list: List of subprojects matching the wildcard.

find_task_by_id(uid, query_all=False)

Find the task by id.

Args:

uid (int): Unique id of the task. query_all (bool, optional): If True, returns deleted tasks as well.

Returns:

Task or int: The task object if successful, -1 otherwise.

find_tasks_by_wildcard(wildcard, query_all=False)

Return the tasks matching the wildcard.

Search recursively for all subprojects and the tasks inside them.

Args:

wildcard (str): The wildcard to match. query_all (bool, optional): If True, returns deleted tasks as well.

Returns:

list: List of tasks matching the wildcard.

get_path_by_uid(uid)

Get the path of the subproject by uid.

Args:

uid (int): Unique id of the subproject.

Returns:

str: The path of the subproject.

get_project()

The project object.

get_sub_tree()

Return the subproject tree as a dictionary.

get_task_by_id(uid, query_all=False)

Get the task by id.

Search through only the tasks under this subproject.

Args:

uid (int): Unique id of the task. query_all (bool, optional): If True, returns deleted tasks as well.

Returns:

Task or int: The task object if successful, -1 otherwise.

get_tasks_by_wildcard(name, query_all=False)

Get the task by name.

Search through only the tasks under this subproject.

Args:

name (str): The wildcard to match. query_all (bool, optional): If True, returns deleted tasks as well.

Returns:

list: List of tasks that match the wildcard.

get_uid_by_path(path)

Get the uid of the subproject by path.

Args:

path (str): The path of the subproject.

Returns:

int: The unique id of the subproject.

is_empty()

Check if the subproject is empty.

static is_subproject_empty(sub)

Check if the subproject has other subprojects or tasks.

Args:

sub (Subproject): The subproject object to check.

Returns:
bool: True if the subproject has no other subs or tasks,

False otherwise.

static is_task_empty(task)

Check all categories and return True if all are empty.

Args:

task (Task): The task object to check.

replace_metadata(metadata)

Replace the metadata with the given one.

resurrect()

Resurrect the subproject if it is deleted.

revive()

Revive the subproject if it is deleted. This is a soft recover. DATABASE IS NOT TOUCHED.

scan_tasks()

Scan the subproject for tasks.

Returns:

dict: The tasks under the subproject.

set_sub_tree(data)

Create the subproject from the data dictionary.

This is for building back the hierarchy from json data.

Args:

data (dict): The dictionary data to build the subproject.

property all_tasks
All tasks, including the deleted ones under the subproject.
property deleted
Whether the subproject is deleted or not.
property metadata
The metadata associated with the subproject.
object_type
property parent
The Parent subproject.
property parent_sub
The parent subproject.
property subs
All subprojects as dictionary.
property tasks
Return all NON-DELETED tasks under the subproject as dictionary where each key
is the name of the task and value is a task object.
property type
The type of the subproject.
LOG