From be45f04af76b710a7f8d58f38ff51db94fb0ba1f Mon Sep 17 00:00:00 2001 From: KKlochko Date: Fri, 23 Jun 2023 19:09:45 +0300 Subject: [PATCH] Add the method to add destionation to a source. --- tui_rsync/models/models.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/tui_rsync/models/models.py b/tui_rsync/models/models.py index a67ff81..71f2eb3 100644 --- a/tui_rsync/models/models.py +++ b/tui_rsync/models/models.py @@ -76,12 +76,20 @@ class Source(BaseModel): destinations=[], args=src_sync_cmd ) + for destination in destinations: - des_path, _ = Path.get_or_create(path=destination) - src_des, _ = Destination.get_or_create(source=src, path=des_path) + src.add_destionation(destination) + src.save() return src + def add_destionation(self, destination): + destination_path, _ = Path.get_or_create(path=destination) + src_destination, _ = Destination.get_or_create( + source=self, + path=destination_path + ) + def update_label(self, new_label): self.label = new_label self.save()