0001-formdata-handle-function-name-variables-with-combine.patch
tests/test_formdata.py | ||
---|---|---|
2141 | 2141 |
static_vars = formdata.get_static_substitution_variables() |
2142 | 2142 |
assert static_vars['form_role_receiver_name'] == 'userA, userB' |
2143 | 2143 | |
2144 |
# combined roles and users |
|
2145 |
role = pub.role_class('test combined') |
|
2146 |
role.store() |
|
2147 |
formdata.workflow_roles = {'_receiver': [str(role.id), '_user:%s' % user1.id, '_user:%s' % user2.id]} |
|
2148 |
formdata.store() |
|
2149 |
pub.substitutions.feed(formdata) |
|
2150 |
condition = Condition( |
|
2151 |
{'type': 'django', 'value': 'form_role_receiver_name == "test combined, userA, userB"'} |
|
2152 |
) |
|
2153 |
assert condition.evaluate() is True |
|
2154 |
static_vars = formdata.get_static_substitution_variables() |
|
2155 |
assert static_vars['form_role_receiver_name'] == 'test combined, userA, userB' |
|
2156 | ||
2157 |
formdata.workflow_roles = {'_receiver': ['_user:%s' % user1.id, '_user:%s' % user2.id, str(role.id)]} |
|
2158 |
formdata.store() |
|
2159 |
pub.substitutions.feed(formdata) |
|
2160 |
condition = Condition( |
|
2161 |
{'type': 'django', 'value': 'form_role_receiver_name == "userA, userB, test combined"'} |
|
2162 |
) |
|
2163 |
assert condition.evaluate() is True |
|
2164 |
static_vars = formdata.get_static_substitution_variables() |
|
2165 |
assert static_vars['form_role_receiver_name'] == 'userA, userB, test combined' |
|
2166 | ||
2144 | 2167 | |
2145 | 2168 |
def test_lazy_now_and_today(pub, variable_test_data): |
2146 | 2169 |
for condition_value in ( |
wcs/formdata.py | ||
---|---|---|
113 | 113 |
_prefix = '%s%s_' % (prefix, role_type.replace('-', '_').strip('_')) |
114 | 114 |
if not isinstance(role_ids, list): |
115 | 115 |
role_ids = [role_ids] |
116 |
if str(role_ids[0]).startswith('_user:'): |
|
116 |
if any(x for x in role_ids if str(x).startswith('_user:')): |
|
117 |
# there's some direct user attribution, only get names |
|
117 | 118 |
try: |
118 |
users = [get_publisher().user_class.get(role_id.split(':')[1]) for role_id in role_ids] |
|
119 |
users_and_roles = [ |
|
120 |
get_publisher().user_class.get(role_id.split(':')[1]) |
|
121 |
if ':' in role_id |
|
122 |
else get_publisher().role_class.get(role_id) |
|
123 |
for role_id in role_ids |
|
124 |
] |
|
119 | 125 |
except KeyError: |
120 | 126 |
continue |
121 |
d['%sname' % _prefix] = ', '.join([u.name for u in users]) |
|
127 |
d['%sname' % _prefix] = ', '.join([u.name for u in users_and_roles])
|
|
122 | 128 |
continue |
123 | 129 | |
124 | 130 |
role_id = role_ids[0] |
125 |
- |