home
·
contact
·
privacy
projects
/
plomtask
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Disallow deletion of Processes in use.
[plomtask]
/
plomtask
/
processes.py
diff --git
a/plomtask/processes.py
b/plomtask/processes.py
index 0a9b95b3f5faf89fd5a4a9a0991c7bb9a70ca9c5..375a0bee622081fd8690cc0e6c1a8ae5241685e1 100644
(file)
--- a/
plomtask/processes.py
+++ b/
plomtask/processes.py
@@
-6,7
+6,8
@@
from sqlite3 import Row
from plomtask.db import DatabaseConnection, BaseModel
from plomtask.misc import VersionedAttribute
from plomtask.conditions import Condition, ConditionsRelations
from plomtask.db import DatabaseConnection, BaseModel
from plomtask.misc import VersionedAttribute
from plomtask.conditions import Condition, ConditionsRelations
-from plomtask.exceptions import NotFoundException, BadFormatException
+from plomtask.exceptions import (NotFoundException, BadFormatException,
+ HandledException)
@dataclass
@dataclass
@@
-172,6
+173,10
@@
class Process(BaseModel[int], ConditionsRelations):
def remove(self, db_conn: DatabaseConnection) -> None:
"""Remove from DB, with dependencies."""
assert isinstance(self.id_, int)
def remove(self, db_conn: DatabaseConnection) -> None:
"""Remove from DB, with dependencies."""
assert isinstance(self.id_, int)
+ for _ in db_conn.row_where('process_steps', 'step_process', self.id_):
+ raise HandledException('cannot remove Process in use')
+ for _ in db_conn.row_where('todos', 'process', self.id_):
+ raise HandledException('cannot remove Process in use')
db_conn.delete_where('process_conditions', 'process', self.id_)
db_conn.delete_where('process_enables', 'process', self.id_)
db_conn.delete_where('process_disables', 'process', self.id_)
db_conn.delete_where('process_conditions', 'process', self.id_)
db_conn.delete_where('process_enables', 'process', self.id_)
db_conn.delete_where('process_disables', 'process', self.id_)