Add more checking for region api

This commit is contained in:
WQY\qiong
2023-04-29 17:58:29 +08:00
parent d66087225f
commit 538284f502

View File

@@ -32,7 +32,8 @@ def _set_region(name: str, cs: ChangeSet) -> DbChangeSet:
def set_region(name: str, cs: ChangeSet) -> ChangeSet:
if 'id' not in cs.operations[0] or 'boundary' not in cs.operations[0]:
return ChangeSet()
if len(cs.operations[0]['boundary']) < 3:
b = cs.operations[0]['boundary']
if len(b) < 4 or b[0] != b[-1]:
return ChangeSet()
if get_region(name, cs.operations[0]['id']) == {}:
return ChangeSet()
@@ -54,7 +55,8 @@ def _add_region(name: str, cs: ChangeSet) -> DbChangeSet:
def add_region(name: str, cs: ChangeSet) -> ChangeSet:
if 'id' not in cs.operations[0] or 'boundary' not in cs.operations[0]:
return ChangeSet()
if len(cs.operations[0]['boundary']) < 3:
b = cs.operations[0]['boundary']
if len(b) < 4 or b[0] != b[-1]:
return ChangeSet()
if get_region(name, cs.operations[0]['id']) != {}:
return ChangeSet()