add mode for leader variable

This commit is contained in:
egarette@silique.fr 2023-09-04 19:19:04 +02:00
parent 763c7a4fb8
commit 940b20f5d9
2 changed files with 12 additions and 8 deletions

View file

@ -227,21 +227,22 @@ class Annotator(Walk):
if isinstance(variable, self.objectspace.family):
if not hasattr(variable, 'mode'):
variable.mode = self.objectspace.rougailconfig['default_family_mode']
elif idx == 0 and is_leadership:
variable.mode = None
continue
#elif idx == 0 and is_leadership:
# variable.mode = None
# if variable.path == 'general.piwigo.users.piwigo_users':
# print(variable.path)
# continue
else:
self._change_variable_mode(variable, family_mode, is_leadership)
if self.modes[min_variable_mode] > self.modes[variable.mode]:
min_variable_mode = variable.mode
if not isinstance(family, (self.objectspace.family, self.objectspace.variables)) or \
is_leadership:
# it's Variable, Service, ... and leadership
if not isinstance(family, (self.objectspace.family, self.objectspace.variables)):
# it's Variable, Service, ...
return
if not hasattr(family, 'mode'):
# set the lower variable mode to family
self._set_auto_mode(family, min_variable_mode)
if family.mode != min_variable_mode:
if not is_leadership and family.mode != min_variable_mode:
msg = _(f'the family "{family.name}" is in "{family.mode}" mode but variables and '
f'families inside have the higher modes "{min_variable_mode}"')
raise DictConsistencyError(msg, 62, family.xmlfiles)

View file

@ -66,7 +66,10 @@ class Annotator(Walk):
if variable.multi is not True:
msg = _(f'the variable "{variable.name}" in a leadership must be multi')
raise DictConsistencyError(msg, 32, variable.xmlfiles)
if variable.hidden:
family.hidden = variable.hidden
elif family.hidden:
variable.hidden = family.hidden
if variable.hidden:
variable.frozen = True
variable.force_default_on_freeze = True