Support cascade deletion
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
from .operation import *
|
||||
from .database import *
|
||||
|
||||
|
||||
LINK_STATUS_OPEN = 'OPEN'
|
||||
@@ -39,7 +39,7 @@ class Status(object):
|
||||
return { 'type': self.type, 'link': self.link, 'status': self.status, 'setting': self.setting }
|
||||
|
||||
|
||||
def set_status_cache(name: str, cs: ChangeSet) -> DbChangeSet:
|
||||
def set_status_cmd(name: str, cs: ChangeSet) -> DbChangeSet:
|
||||
old = Status(get_status(name, cs.operations[0]['link']))
|
||||
raw_new = get_status(name, cs.operations[0]['link'])
|
||||
|
||||
@@ -65,7 +65,7 @@ def set_status_cache(name: str, cs: ChangeSet) -> DbChangeSet:
|
||||
|
||||
|
||||
def set_status(name: str, cs: ChangeSet) -> ChangeSet:
|
||||
return execute_command(name, set_status_cache(name, cs))
|
||||
return execute_command(name, set_status_cmd(name, cs))
|
||||
|
||||
|
||||
class InpStatus:
|
||||
@@ -121,3 +121,10 @@ def inp_out_status(name: str) -> list[str]:
|
||||
if setting != '':
|
||||
lines.append(f'{link} {setting}')
|
||||
return lines
|
||||
|
||||
|
||||
def delete_status_by_link(name: str, link: str) -> ChangeSet:
|
||||
row = try_read(name, f"select * from status where link = '{link}'")
|
||||
if row == None:
|
||||
return ChangeSet()
|
||||
return ChangeSet(g_update_prefix | {'type': 'status', 'link': link, 'status': None, 'setting': None})
|
||||
|
||||
Reference in New Issue
Block a user