X-Git-Url: https://plomlompom.com/repos/foo.html?a=blobdiff_plain;f=plomtask%2Fconditions.py;h=70365ce6a1d3d5eb4aa49077eb95e62cf1444bb0;hb=eba83bdbf91206ad3af19810f27ca6e24e484555;hp=8ab4282080b4898f8d08da4e443f8ac3d64131ee;hpb=eb16b47ddcaefaeab2f616419ea746cc32346893;p=plomtask
diff --git a/plomtask/conditions.py b/plomtask/conditions.py
index 8ab4282..70365ce 100644
--- a/plomtask/conditions.py
+++ b/plomtask/conditions.py
@@ -1,7 +1,5 @@
"""Non-doable elements of ProcessStep/Todo chains."""
from __future__ import annotations
-from typing import Any
-from sqlite3 import Row
from plomtask.db import DatabaseConnection, BaseModel
from plomtask.versioned_attributes import VersionedAttribute
from plomtask.exceptions import HandledException
@@ -12,6 +10,7 @@ class Condition(BaseModel[int]):
table_name = 'conditions'
to_save = ['is_active']
to_save_versioned = ['title', 'description']
+ to_search = ['title.newest', 'description.newest']
def __init__(self, id_: int | None, is_active: bool = False) -> None:
super().__init__(id_)
@@ -20,17 +19,6 @@ class Condition(BaseModel[int]):
self.description = VersionedAttribute(self, 'condition_descriptions',
'')
- @classmethod
- def from_table_row(cls, db_conn: DatabaseConnection,
- row: Row | list[Any]) -> Condition:
- """Build condition from row, including VersionedAttributes."""
- condition = super().from_table_row(db_conn, row)
- for name in ('title', 'description'):
- table_name = f'condition_{name}s'
- for row_ in db_conn.row_where(table_name, 'parent', row[0]):
- getattr(condition, name).history_from_row(row_)
- return condition
-
def remove(self, db_conn: DatabaseConnection) -> None:
"""Remove from DB, with VersionedAttributes.