better multi's mandatory support
This commit is contained in:
parent
4ec269f2b9
commit
64fc2df3d2
|
@ -157,12 +157,12 @@ class _Value:
|
||||||
for index in range(leadership_len):
|
for index in range(leadership_len):
|
||||||
value = self.config.get_value(key,
|
value = self.config.get_value(key,
|
||||||
index)
|
index)
|
||||||
self._display_warnings(key, value, option['type'], option['name'], withwarning)
|
self._display_warnings(key, value, option['type'], key, withwarning)
|
||||||
values.append(value)
|
values.append(value)
|
||||||
ret[key] = values
|
ret[key] = values
|
||||||
else:
|
else:
|
||||||
value = self.config.get_value(key)
|
value = self.config.get_value(key)
|
||||||
self._display_warnings(key, value, option['type'], option['name'], withwarning)
|
self._display_warnings(key, value, option['type'], key, withwarning)
|
||||||
ret[key] = value
|
ret[key] = value
|
||||||
if schema.get('type') == 'array':
|
if schema.get('type') == 'array':
|
||||||
leadership_len = len(value)
|
leadership_len = len(value)
|
||||||
|
@ -248,12 +248,12 @@ class TiramisuOptionValue(_Value):
|
||||||
if self.index is None:
|
if self.index is None:
|
||||||
raise APIError(_('index must be set with the follower option "{}"').format(self.path))
|
raise APIError(_('index must be set with the follower option "{}"').format(self.path))
|
||||||
value = self.config.get_value(self.path, self.index)
|
value = self.config.get_value(self.path, self.index)
|
||||||
self._display_warnings(self.path, value, self.schema['type'], self.schema['name'])
|
self._display_warnings(self.path, value, self.schema['type'], self.path)
|
||||||
return value
|
return value
|
||||||
if self.index is not None:
|
if self.index is not None:
|
||||||
raise APIError(_('index must only be set with a follower option, not for "{}"').format(self.path))
|
raise APIError(_('index must only be set with a follower option, not for "{}"').format(self.path))
|
||||||
value = self.config.get_value(self.path)
|
value = self.config.get_value(self.path)
|
||||||
self._display_warnings(self.path, value, self.schema['type'], self.schema['name'])
|
self._display_warnings(self.path, value, self.schema['type'], self.path)
|
||||||
return value
|
return value
|
||||||
|
|
||||||
def list(self):
|
def list(self):
|
||||||
|
@ -294,7 +294,7 @@ class TiramisuOptionValue(_Value):
|
||||||
value,
|
value,
|
||||||
remote,
|
remote,
|
||||||
leader_old_value)
|
leader_old_value)
|
||||||
self._display_warnings(self.path, value, type_, self.schema['name'])
|
self._display_warnings(self.path, value, type_, self.path)
|
||||||
|
|
||||||
def reset(self):
|
def reset(self):
|
||||||
self.config.delete_value(self.path,
|
self.config.delete_value(self.path,
|
||||||
|
@ -525,8 +525,8 @@ class ContextValue(_Value):
|
||||||
def mandatory(self):
|
def mandatory(self):
|
||||||
for key, value in self.dict().items():
|
for key, value in self.dict().items():
|
||||||
if self.config.isfollower(key):
|
if self.config.isfollower(key):
|
||||||
# FIXME test with index
|
|
||||||
if self.model.get(key, {}).get(None, {}).get('required'):
|
if self.model.get(key, {}).get(None, {}).get('required'):
|
||||||
|
# FIXME test with index
|
||||||
if self.config.get_schema(key).get('isSubMulti'):
|
if self.config.get_schema(key).get('isSubMulti'):
|
||||||
for val in value:
|
for val in value:
|
||||||
if not val or None in val or '' in val:
|
if not val or None in val or '' in val:
|
||||||
|
@ -534,8 +534,12 @@ class ContextValue(_Value):
|
||||||
break
|
break
|
||||||
elif None in value or '' in value:
|
elif None in value or '' in value:
|
||||||
yield key
|
yield key
|
||||||
elif value is None or \
|
elif self.config.get_schema(key).get('isMulti'):
|
||||||
(self.config.get_schema(key).get('isMulti') and (not value or None in value or '' in value)):
|
if self.model.get(key, {}).get('required') and (None in value or '' in value):
|
||||||
|
yield key
|
||||||
|
if self.model.get(key, {}).get('needs_len') and not value:
|
||||||
|
yield key
|
||||||
|
elif self.model.get(key, {}).get('required') and value is None:
|
||||||
yield key
|
yield key
|
||||||
|
|
||||||
|
|
||||||
|
@ -971,6 +975,8 @@ class Config:
|
||||||
if value is None:
|
if value is None:
|
||||||
match = True
|
match = True
|
||||||
else:
|
else:
|
||||||
|
if isinstance(value, int):
|
||||||
|
value = str(value)
|
||||||
match = self.form[path]['pattern'].search(value)
|
match = self.form[path]['pattern'].search(value)
|
||||||
if not remote:
|
if not remote:
|
||||||
if not match:
|
if not match:
|
||||||
|
|
Loading…
Reference in New Issue