0001-misc-don-t-record-errors-when-evaluating-roles-for-p.patch
wcs/backoffice/management.py | ||
---|---|---|
2666 | 2666 |
related_user_forms = getattr(self.filled, 'related_user_forms', None) or [] |
2667 | 2667 |
user_roles = set(get_request().user.get_roles()) |
2668 | 2668 |
session = get_session() |
2669 |
get_publisher().substitutions.unfeed(lambda x: x is self.filled) |
|
2669 | 2670 |
for user_formdata in related_user_forms: |
2670 |
if user_roles.intersection(user_formdata.actions_roles): |
|
2671 |
if user_roles.intersection(user_formdata.get_actions_roles( |
|
2672 |
condition_kwargs={'record_errors': False})): |
|
2671 | 2673 |
session.mark_visited_object(user_formdata) |
2672 | 2674 | |
2673 | 2675 |
return response |
... | ... | |
2975 | 2977 |
if test_mode in ('django-condition', 'python-condition'): |
2976 | 2978 |
condition = Condition({ |
2977 | 2979 |
'value': form.get_widget(test_mode).parse(), |
2978 |
'type': test_mode.split('-')[0]})
|
|
2979 |
condition.log_errors = False
|
|
2980 |
condition.record_errors = False
|
|
2980 |
'type': test_mode.split('-')[0]},
|
|
2981 |
log_errors=False,
|
|
2982 |
record_errors=False)
|
|
2981 | 2983 |
try: |
2982 | 2984 |
result = condition.unsafe_evaluate() |
2983 | 2985 |
except Exception as exception: |
wcs/conditions.py | ||
---|---|---|
29 | 29 |
record_errors = True |
30 | 30 |
log_errors = False |
31 | 31 | |
32 |
def __init__(self, condition, context={}): |
|
32 |
def __init__(self, condition, context={}, record_errors=True, log_errors=False):
|
|
33 | 33 |
if not condition: |
34 | 34 |
condition = {} |
35 | 35 |
self.type = condition.get('type') |
36 | 36 |
self.value = condition.get('value') |
37 | 37 |
self.context = context |
38 |
self.log_errors = log_errors |
|
39 |
self.record_errors = record_errors |
|
38 | 40 | |
39 | 41 |
def __repr__(self): |
40 | 42 |
return '<%s (%s) %r>' % (self.__class__.__name__, self.type, self.value) |
wcs/formdata.py | ||
---|---|---|
935 | 935 | |
936 | 936 |
concerned_roles = property(get_concerned_roles) |
937 | 937 | |
938 |
def get_actions_roles(self): |
|
938 |
def get_actions_roles(self, condition_kwargs=None):
|
|
939 | 939 |
if self.is_draft(): |
940 | 940 |
return [] |
941 | 941 | |
... | ... | |
949 | 949 |
if not hasattr(item, 'by') or not item.by: |
950 | 950 |
continue |
951 | 951 |
with get_publisher().substitutions.temporary_feed(self): |
952 |
if not item.check_condition(self): |
|
952 |
if not item.check_condition(self, **(condition_kwargs or {})):
|
|
953 | 953 |
continue |
954 | 954 |
for role in item.by: |
955 | 955 |
if role == '_submitter': |
wcs/workflows.py | ||
---|---|---|
1844 | 1844 | |
1845 | 1845 |
return False |
1846 | 1846 | |
1847 |
def check_condition(self, formdata): |
|
1847 |
def check_condition(self, formdata, record_errors=True, log_errors=False):
|
|
1848 | 1848 |
context = {'formdata': formdata, 'status_item': self} |
1849 | 1849 |
try: |
1850 |
return Condition(self.condition, context).evaluate() |
|
1850 |
return Condition(self.condition, context, |
|
1851 |
record_errors=record_errors, log_errors=log_errors).evaluate() |
|
1851 | 1852 |
except RuntimeError: |
1852 | 1853 |
return False |
1853 | 1854 | |
1854 |
- |