From bc22e8a8bd6a5c48fd13c25a1e6eb2773dba8b5b Mon Sep 17 00:00:00 2001 From: KKlochko Date: Tue, 21 Jan 2025 21:55:58 +0200 Subject: [PATCH] Add command to remove backup plan's destinations. --- .../backup_plan/application/commands/__init__.py | 3 ++- .../remove_backup_plan_destinations_command.py | 12 ++++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) create mode 100644 tui_rsync/core/components/backup_plan/application/commands/remove_backup_plan_destinations_command.py diff --git a/tui_rsync/core/components/backup_plan/application/commands/__init__.py b/tui_rsync/core/components/backup_plan/application/commands/__init__.py index 7d15909..f8095d5 100644 --- a/tui_rsync/core/components/backup_plan/application/commands/__init__.py +++ b/tui_rsync/core/components/backup_plan/application/commands/__init__.py @@ -1,3 +1,4 @@ from .remove_all_backup_plans_command import RemoveAllBackupBackupPlansCommand +from .remove_backup_plan_destinations_command import RemoveBackupBackupPlanDestinationsCommand -__all__ = ['RemoveAllBackupBackupPlansCommand'] +__all__ = ['RemoveAllBackupBackupPlansCommand', 'RemoveBackupBackupPlanDestinationsCommand'] diff --git a/tui_rsync/core/components/backup_plan/application/commands/remove_backup_plan_destinations_command.py b/tui_rsync/core/components/backup_plan/application/commands/remove_backup_plan_destinations_command.py new file mode 100644 index 0000000..1575705 --- /dev/null +++ b/tui_rsync/core/components/backup_plan/application/commands/remove_backup_plan_destinations_command.py @@ -0,0 +1,12 @@ +from tui_rsync.core.ports.orm import DatabaseManagerPort +from tui_rsync.core.shared_kernel.components.common import UUID +from tui_rsync.infrastructure.orm.models import DestinationModel + + +class RemoveBackupBackupPlanDestinationsCommand: + def __init__(self, database_manager: DatabaseManagerPort): + self.databaseManager = database_manager + + def execute(self, backup_plan_uuid: UUID) -> bool: + rows = DestinationModel.delete().where(DestinationModel.source == backup_plan_uuid.id).execute() + return rows != 0