mirror of https://gitlab.com/KKlochko/tui-rsync
				
				
				
			
							parent
							
								
									cae4ce50c5
								
							
						
					
					
						commit
						d652469748
					
				@ -1,4 +1,5 @@
 | 
				
			||||
from .remove_all_backup_plans_command import RemoveAllBackupBackupPlansCommand
 | 
				
			||||
from .remove_backup_plan_destinations_command import RemoveBackupBackupPlanDestinationsCommand
 | 
				
			||||
from .remove_backup_plan_command import RemoveBackupBackupPlanCommand
 | 
				
			||||
 | 
				
			||||
__all__ = ['RemoveAllBackupBackupPlansCommand', 'RemoveBackupBackupPlanDestinationsCommand']
 | 
				
			||||
__all__ = ['RemoveAllBackupBackupPlansCommand', 'RemoveBackupBackupPlanCommand', 'RemoveBackupBackupPlanDestinationsCommand']
 | 
				
			||||
 | 
				
			||||
@ -0,0 +1,18 @@
 | 
				
			||||
from tui_rsync.core.ports.orm import DatabaseManagerPort
 | 
				
			||||
from tui_rsync.core.shared_kernel.components.common import UUID
 | 
				
			||||
from tui_rsync.core.shared_kernel.ports.Exceptions import CommandException
 | 
				
			||||
from tui_rsync.infrastructure.orm.models import DestinationModel, BackupPlanModel
 | 
				
			||||
 | 
				
			||||
 | 
				
			||||
class RemoveBackupBackupPlanCommand:
 | 
				
			||||
    def __init__(self, database_manager: DatabaseManagerPort):
 | 
				
			||||
        self.databaseManager = database_manager
 | 
				
			||||
 | 
				
			||||
    def execute(self, uuid: UUID) -> bool:
 | 
				
			||||
        deleted = BackupPlanModel.delete().where(BackupPlanModel.id == uuid.id).execute()
 | 
				
			||||
        deleted = DestinationModel.delete().where(DestinationModel.source == uuid.id).execute() | deleted
 | 
				
			||||
 | 
				
			||||
        if deleted == 0:
 | 
				
			||||
            raise CommandException("Failed to delete the backup plan, because it doesn't exist.")
 | 
				
			||||
 | 
				
			||||
        return True
 | 
				
			||||
					Loading…
					
					
				
		Reference in new issue