add owner method
This commit is contained in:
parent
a91f32401a
commit
1d995ecf56
|
@ -186,6 +186,33 @@ class _Value:
|
|||
return value
|
||||
|
||||
|
||||
class TiramisuOptionOwner:
|
||||
# config.option(path).owner
|
||||
def __init__(self,
|
||||
config: 'Config',
|
||||
schema: Dict,
|
||||
model: List[Dict],
|
||||
form: List[Dict],
|
||||
temp: List[Dict],
|
||||
path: str,
|
||||
index: int) -> None:
|
||||
self.config = config
|
||||
self.schema = schema
|
||||
self.model = model
|
||||
self.form = form
|
||||
self.temp = temp
|
||||
self.path = path
|
||||
self.index = index
|
||||
|
||||
def isdefault(self) -> Any:
|
||||
owner = 'default'
|
||||
if self.path in self.temp:
|
||||
owner = self.temp[self.path]['owner']
|
||||
elif self.path in self.model and 'owner' in self.model[self.path]:
|
||||
owner = self.model[self.path]['owner']
|
||||
return owner == 'default'
|
||||
|
||||
|
||||
class TiramisuOptionValue(_Value):
|
||||
# config.option(path).value
|
||||
def __init__(self,
|
||||
|
@ -198,8 +225,6 @@ class TiramisuOptionValue(_Value):
|
|||
index: int) -> None:
|
||||
self.config = config
|
||||
self.schema = schema
|
||||
if schema.get('properties') != None:
|
||||
raise Exception('pouet')
|
||||
self.model = model
|
||||
self.form = form
|
||||
self.temp = temp
|
||||
|
@ -328,6 +353,14 @@ class TiramisuOption:
|
|||
self.temp,
|
||||
self.path,
|
||||
self.index)
|
||||
if subfunc == 'owner':
|
||||
return TiramisuOptionOwner(self.config,
|
||||
self.schema,
|
||||
self.model,
|
||||
self.form,
|
||||
self.temp,
|
||||
self.path,
|
||||
self.index)
|
||||
if subfunc == 'property':
|
||||
if self.index != None:
|
||||
raise NotImplementedError()
|
||||
|
@ -487,7 +520,7 @@ class Config:
|
|||
index: Optional[int],
|
||||
remote: bool) -> None:
|
||||
schema = self.get_schema(path)
|
||||
value = schema['value'];
|
||||
value = schema.get('value');
|
||||
if value is None and schema.get('isMulti', False):
|
||||
value = []
|
||||
self.updates_value('delete',
|
||||
|
|
Loading…
Reference in New Issue