mirror of
https://gitlab.com/KKlochko/tui-rsync.git
synced 2026-08-12 17:57:43 +00:00
Update the repository and service to implement the update action.
This commit is contained in:
+13
-1
@@ -8,6 +8,7 @@ from tui_rsync.core.components.backup_plan.domain import BackupPlan
|
||||
from tui_rsync.core.shared_kernel.components.common import UUID
|
||||
|
||||
from tui_rsync.infrastructure.orm.models import BackupPlanModel, DestinationModel
|
||||
from ..commands import RemoveBackupBackupPlanDestinationsCommand
|
||||
|
||||
|
||||
class BackupPlanRepository(BackupPlanRepositoryPort):
|
||||
@@ -30,7 +31,18 @@ class BackupPlanRepository(BackupPlanRepositoryPort):
|
||||
return BackupPlanDTO.to_domain(model)
|
||||
|
||||
def update(self, backup_plan: BackupPlan):
|
||||
pass
|
||||
updated_model = BackupPlanDTO.to_model(backup_plan)
|
||||
model = BackupPlanModel.get_or_none(BackupPlanModel.id == updated_model.id)
|
||||
remove_backup_plan_destinations_command = RemoveBackupBackupPlanDestinationsCommand(self.databaseManager)
|
||||
|
||||
model.label = updated_model.label
|
||||
model.source = updated_model.source
|
||||
|
||||
remove_backup_plan_destinations_command.execute(backup_plan.id)
|
||||
|
||||
model.save()
|
||||
for destination in updated_model.destinations:
|
||||
destination.save(force_insert=True)
|
||||
|
||||
def delete(self, uuid: UUID) -> bool:
|
||||
deleted = BackupPlanModel.delete().where(BackupPlanModel.id == uuid.id).execute()
|
||||
|
||||
@@ -17,7 +17,7 @@ class BackupPlanService:
|
||||
return self.backup_plan_repository.get_by_id(uuid)
|
||||
|
||||
def update(self, backup_plan: BackupPlan):
|
||||
pass
|
||||
return self.backup_plan_repository.update(backup_plan)
|
||||
|
||||
def delete(self, uuid: UUID) -> bool:
|
||||
return self.backup_plan_repository.delete(uuid)
|
||||
|
||||
Reference in New Issue
Block a user