Todo
In this page, I'll lay out all the methods available on the todo class
💡 TIP
As mentioned in the introduction, Todo
class is a table and any sql operations can be performed using sqlalchemy
attr
description
The description of the workspace
description: Mapped[str] = mapped_column(default="")
attr
due
The due date for the workspace
due: Mapped[Optional[datetime]] = mapped_column(default=None)
attr
effort
The effort value for the workspace
effort: Mapped[int] = mapped_column(default=0)
attr
recurrence
The recurrence for the given todo
recurrence: Mapped[Optional[timedelta]] = mapped_column(default=None)
attr
urgency
The urgency for the workspace (from 0
to 4
)
due: Mapped[Optional[datetime]] = mapped_column(default=None)
attr
pending
Whether the todo is completed or not (True
if not completed)
pending: Mapped[bool] = mapped_column(default=True)
attr
parent_workspace
The parent workspace of the todo ( will be None
if the todo is a subtask for another Todo
)
parent_workspace: Mapped[Optional["Workspace"]] = relationship(
"Workspace",
back_populates="todos",
)
attr
parent_todo
The parent todo of the todo ( will be None
if the todo is not a subtask for another Todo
)
parent_workspace: Mapped[Optional["Workspace"]] = relationship(
"Workspace",
back_populates="todos",
)
attr
todos
The sub-todos for the todo
todos: Mapped[List["Todo"]] = relationship(
"Todo",
back_populates="parent_todo",
cascade="all, delete-orphan",
order_by=order_index,
)
classmethod
from_id
from_id(id: str | int) -> Todo
Returns the todo object with the given id
Parameters:
Param | Default | Description |
---|---|---|
id | The id of the todo object you want to get |
Returns:
Type | Default | Description |
---|---|---|
Self | The todo object |
Raises:
Type | Default | Description |
---|---|---|
ValueError | If an invalid ID is passed |
classmethod
all
all() -> List[Todo]
Returns all the todos from the database
Returns:
Type | Default | Description |
---|---|---|
List[Todo] | List of the todos present in the database |
property
parent
parent -> Workspace | Todo
Returns the parent of the todo object
Returns:
Type | Default | Description |
---|---|---|
Workspace or Todo | The parent of the todo object |
property
nest_level
nest_level -> int
Returns the nested level from the root
Returns:
Type | Default | Description |
---|---|---|
int | Depth of the nesting |
property
tags
tags -> List[str]
Returns all the tags in the todo (words starting with @
)
Returns:
Type | Default | Description |
---|---|---|
List[str] | List of the tags |
property
status
status -> str
Returns the status of the todo (one of completed
/pending
/overdue
)
Returns:
Type | Default | Description |
---|---|---|
str | Status of the todo |
property
is_completed
is_completed -> bool
Returns if the todo is completed or not
Returns:
Type | Default | Description |
---|---|---|
bool | If the todo is completed |
property
is_pending
is_pending -> bool
Returns if the todo is pending or not
Returns:
Type | Default | Description |
---|---|---|
bool | If the todo is pending |
property
is_overdue
is_overdue -> bool
Returns if the todo is overdue or not
Returns:
Type | Default | Description |
---|---|---|
bool | If the todo is overdue |
method
siblings
siblings() -> List[Todo]
Returns the siblings for the todo (including self)
Returns:
Type | Default | Description |
---|---|---|
List[Self] | List of the siblings (including self) |
method
sort_siblings
sort_siblings(field: str)
Sorts all the siblings by the given field
Parameters:
Param | Default | Description |
---|---|---|
field | The field/column you'd want to sort the todo with |
Raises:
Type | Default | Description |
---|---|---|
AttributeError | If an invalid field is passed |
method
add_todo
add_todo() -> Todo
Adds a todo to the todo object
Returns:
Type | Default | Description |
---|---|---|
Todo | The newly added todo |
method
shift_down
Shifts the todo down by one index (Nothing happens if its the first todo)
shift_down()
method
shift_up
Shifts the todo down by one index (Nothing happens if its the last todo)
shift_up()
method
save
Saves any modifications done on the attributes to the database
save()
method
increase_urgency
increase_urgency()
Increases the urgency for the todo (max 4
)
method
decrease_urgency
decrease_urgency()
Decreases the urgency for the todo (min 0
)
method
toggle_complete
toggle_complete()
Toggles the pending status of a todo
property
is_due_today
is_due_today() -> bool
Returns if the todo is due on the same day
Returns:
Type | Default | Description |
---|---|---|
bool | If the todo is overdue |