mirror of
https://gitlab.com/KKlochko/tui-rsync.git
synced 2026-08-12 17:57:43 +00:00
(Added) source update args function.
This commit is contained in:
@@ -37,6 +37,11 @@ class Path(BaseModel):
|
||||
class SyncCommand(BaseModel):
|
||||
command = CharField()
|
||||
|
||||
@staticmethod
|
||||
def get_sync_command(args):
|
||||
sync_cmd, _ = SyncCommand.get_or_create(command=args)
|
||||
return sync_cmd
|
||||
|
||||
def __str__(self) -> str:
|
||||
return self.command
|
||||
|
||||
@@ -45,6 +50,16 @@ class Source(BaseModel):
|
||||
source = ForeignKeyField(Path)
|
||||
args = ForeignKeyField(SyncCommand)
|
||||
|
||||
@staticmethod
|
||||
def is_exist(label) -> bool:
|
||||
return Source.select().where(Source.label == label).exists()
|
||||
|
||||
@staticmethod
|
||||
def get_source(label):
|
||||
if not Source.is_exist(label):
|
||||
return None
|
||||
return Source.select().where(Source.label == label).get()
|
||||
|
||||
@staticmethod
|
||||
def create_save(label:str, source:str, destinations:list[str], args:str):
|
||||
src_path, _ = Path.get_or_create(path=source)
|
||||
@@ -61,6 +76,11 @@ class Source(BaseModel):
|
||||
src.save()
|
||||
return src
|
||||
|
||||
def update_args(self, args):
|
||||
args_obj = SyncCommand.get_sync_command(args)
|
||||
self.args = args_obj
|
||||
self.save()
|
||||
|
||||
def __str__(self) -> str:
|
||||
return f"{self.label}"
|
||||
|
||||
|
||||
Reference in New Issue
Block a user