misc: don't record errors when evaluating roles for pending bar (#39096)
gitea-wip/wcs/pipeline/head Build started...
Details
gitea-wip/wcs/pipeline/head Build started...
Details
This commit is contained in:
parent
cb0d1b8092
commit
e6eead49b4
|
@ -2906,8 +2906,11 @@ class FormBackOfficeStatusPage(FormStatusPage):
|
|||
related_user_forms = getattr(self.filled, 'related_user_forms', None) or []
|
||||
user_roles = set(get_request().user.get_roles())
|
||||
session = get_session()
|
||||
get_publisher().substitutions.unfeed(lambda x: x is self.filled)
|
||||
for user_formdata in related_user_forms:
|
||||
if user_roles.intersection(user_formdata.actions_roles):
|
||||
if user_roles.intersection(
|
||||
user_formdata.get_actions_roles(condition_kwargs={'record_errors': False})
|
||||
):
|
||||
session.mark_visited_object(user_formdata)
|
||||
|
||||
return response
|
||||
|
@ -3306,10 +3309,10 @@ class FormBackOfficeStatusPage(FormStatusPage):
|
|||
test_mode = form.get_widget('test_mode').parse()
|
||||
if test_mode in ('django-condition', 'python-condition'):
|
||||
condition = Condition(
|
||||
{'value': form.get_widget(test_mode).parse(), 'type': test_mode.split('-')[0]}
|
||||
{'value': form.get_widget(test_mode).parse(), 'type': test_mode.split('-')[0]},
|
||||
log_errors=False,
|
||||
record_errors=False,
|
||||
)
|
||||
condition.log_errors = False
|
||||
condition.record_errors = False
|
||||
try:
|
||||
result = condition.unsafe_evaluate()
|
||||
except Exception as exception:
|
||||
|
|
|
@ -30,12 +30,14 @@ class Condition:
|
|||
record_errors = True
|
||||
log_errors = False
|
||||
|
||||
def __init__(self, condition, context=None):
|
||||
def __init__(self, condition, context=None, record_errors=True, log_errors=False):
|
||||
if not condition:
|
||||
condition = {}
|
||||
self.type = condition.get('type')
|
||||
self.value = condition.get('value')
|
||||
self.context = context or {}
|
||||
self.log_errors = log_errors
|
||||
self.record_errors = record_errors
|
||||
|
||||
def __repr__(self):
|
||||
return '<%s (%s) %r>' % (self.__class__.__name__, self.type, self.value)
|
||||
|
|
|
@ -1060,7 +1060,7 @@ class FormData(StorableObject):
|
|||
|
||||
concerned_roles = property(get_concerned_roles)
|
||||
|
||||
def get_actions_roles(self):
|
||||
def get_actions_roles(self, condition_kwargs=None):
|
||||
if self.is_draft():
|
||||
return []
|
||||
|
||||
|
@ -1073,7 +1073,7 @@ class FormData(StorableObject):
|
|||
if not hasattr(item, 'by') or not item.by:
|
||||
continue
|
||||
with get_publisher().substitutions.temporary_feed(self):
|
||||
if not item.check_condition(self):
|
||||
if not item.check_condition(self, **(condition_kwargs or {})):
|
||||
continue
|
||||
for role in item.by:
|
||||
if role == '_submitter':
|
||||
|
|
|
@ -2084,10 +2084,12 @@ class WorkflowStatusItem(XmlSerialisable):
|
|||
|
||||
return False
|
||||
|
||||
def check_condition(self, formdata):
|
||||
def check_condition(self, formdata, record_errors=True, log_errors=False):
|
||||
context = {'formdata': formdata, 'status_item': self}
|
||||
try:
|
||||
return Condition(self.condition, context).evaluate()
|
||||
return Condition(
|
||||
self.condition, context, record_errors=record_errors, log_errors=log_errors
|
||||
).evaluate()
|
||||
except RuntimeError:
|
||||
return False
|
||||
|
||||
|
|
Loading…
Reference in New Issue