Compare commits
2 Commits
release/0.
...
release/0.
Author | SHA1 | Date | |
---|---|---|---|
f48878b324 | |||
70389d70cd |
@ -1,5 +1,5 @@
|
|||||||
from .api import Config
|
from .api import Config
|
||||||
|
|
||||||
__version__ = "0.2"
|
__version__ = "0.4"
|
||||||
__all__ = ('Config',)
|
__all__ = ('Config',)
|
||||||
|
|
||||||
|
@ -326,11 +326,11 @@ class TiramisuOptionValue(_Value):
|
|||||||
def set(self, value):
|
def set(self, value):
|
||||||
type_ = self.schema['type']
|
type_ = self.schema['type']
|
||||||
leader_old_value = undefined
|
leader_old_value = undefined
|
||||||
if self.config.is_hidden(self.path, self.index):
|
remote = self.config.form.get(self.path, {}).get('remote', False)
|
||||||
|
if not remote and self.config.is_hidden(self.path, self.index):
|
||||||
raise PropertiesOptionError(None, {'disabled'}, None, opt_type='option')
|
raise PropertiesOptionError(None, {'disabled'}, None, opt_type='option')
|
||||||
if self.config.isleader(self.path):
|
if self.config.isleader(self.path):
|
||||||
leader_old_value = self.config.get_value(self.path)
|
leader_old_value = self.config.get_value(self.path)
|
||||||
remote = self.config.form.get(self.path, {}).get('remote', False)
|
|
||||||
if self.index is None and self.schema.get('isMulti', False):
|
if self.index is None and self.schema.get('isMulti', False):
|
||||||
if not isinstance(value, list):
|
if not isinstance(value, list):
|
||||||
raise ValueError('value must be a list')
|
raise ValueError('value must be a list')
|
||||||
@ -644,6 +644,7 @@ class Config:
|
|||||||
# config
|
# config
|
||||||
def __init__(self,
|
def __init__(self,
|
||||||
dico):
|
dico):
|
||||||
|
self._unrestraint = False
|
||||||
if DEBUG:
|
if DEBUG:
|
||||||
from pprint import pprint
|
from pprint import pprint
|
||||||
pprint(dico)
|
pprint(dico)
|
||||||
@ -668,6 +669,7 @@ class Config:
|
|||||||
self.root = first_path.rsplit('.', 1)[0]
|
self.root = first_path.rsplit('.', 1)[0]
|
||||||
else:
|
else:
|
||||||
self.root = ''
|
self.root = ''
|
||||||
|
self.dico = dico
|
||||||
|
|
||||||
def __getattr__(self,
|
def __getattr__(self,
|
||||||
subfunc: str) -> Any:
|
subfunc: str) -> Any:
|
||||||
@ -682,6 +684,11 @@ class Config:
|
|||||||
if subfunc == 'owner':
|
if subfunc == 'owner':
|
||||||
return ContextOwner(self,
|
return ContextOwner(self,
|
||||||
self.schema)
|
self.schema)
|
||||||
|
if subfunc == 'unrestraint':
|
||||||
|
ret = Config(self.dico)
|
||||||
|
ret._unrestraint = True
|
||||||
|
ret.temp = self.temp
|
||||||
|
return ret
|
||||||
raise APIError(_('please specify a valid sub function ({})').format(subfunc))
|
raise APIError(_('please specify a valid sub function ({})').format(subfunc))
|
||||||
|
|
||||||
def add_value(self,
|
def add_value(self,
|
||||||
@ -847,6 +854,8 @@ class Config:
|
|||||||
path: str,
|
path: str,
|
||||||
index: Optional[int],
|
index: Optional[int],
|
||||||
permissive: bool=False) -> bool:
|
permissive: bool=False) -> bool:
|
||||||
|
if self._unrestraint:
|
||||||
|
return False
|
||||||
if permissive:
|
if permissive:
|
||||||
property_ = 'hidden'
|
property_ = 'hidden'
|
||||||
needs = True
|
needs = True
|
||||||
|
Reference in New Issue
Block a user