0001-datasources-add-an-option-to-hide-disabled-users-585.patch
tests/test_datasource_users.py | ||
---|---|---|
112 | 112 |
assert data_sources.get_structured_items({'type': datasource.slug}) == [] |
113 | 113 |
assert data_sources.get_structured_items(datasource.extended_data_source) == [] |
114 | 114 |
assert tmpl.render(context) == '' |
115 | ||
116 |
datasource.users_excluded_roles = [] |
|
117 |
datasource.store() |
|
118 |
users[1].is_active = False |
|
119 |
users[1].store() |
|
120 |
assert not datasource.include_disabled_users |
|
121 |
assert data_sources.get_structured_items({'type': datasource.slug}) == [{'id': 1, 'text': 'John Doe 0'}] |
|
122 |
assert data_sources.get_structured_items(datasource.extended_data_source) == [ |
|
123 |
{'id': 1, 'text': 'John Doe 0'} |
|
124 |
] |
|
125 |
assert tmpl.render(context) == 'John Doe 0' |
|
126 | ||
127 |
datasource.include_disabled_users = True |
|
128 |
datasource.store() |
|
129 |
assert data_sources.get_structured_items({'type': datasource.slug}) == [ |
|
130 |
{'id': 1, 'text': 'John Doe 0'}, |
|
131 |
{'id': 2, 'text': 'John Doe 1'}, |
|
132 |
] |
|
133 |
assert data_sources.get_structured_items(datasource.extended_data_source) == [ |
|
134 |
{'id': 1, 'text': 'John Doe 0'}, |
|
135 |
{'id': 2, 'text': 'John Doe 1'}, |
|
136 |
] |
|
137 |
assert tmpl.render(context) == 'John Doe 0, John Doe 1' |
wcs/admin/data_sources.py | ||
---|---|---|
180 | 180 |
add_element_label=_('Add Role'), |
181 | 181 |
element_kwargs={'render_br': False, 'options': options}, |
182 | 182 |
) |
183 |
form.add( |
|
184 |
CheckboxWidget, |
|
185 |
'include_disabled_users', |
|
186 |
title=_('Include disabled users'), |
|
187 |
value=self.datasource.include_disabled_users, |
|
188 |
) |
|
183 | 189 |
if self.datasource.slug and not self.datasource.is_used(): |
184 | 190 |
form.add( |
185 | 191 |
SlugWidget, |
wcs/data_sources.py | ||
---|---|---|
319 | 319 |
excluded_roles=data_source.get('excluded_roles'), |
320 | 320 |
order_by='name', |
321 | 321 |
) |
322 |
return [{'id': u.id, 'text': u.name} for u in users] |
|
322 | ||
323 |
include_disabled_users = data_source.get('include_disabled_users') |
|
324 |
return [{'id': u.id, 'text': u.name} for u in users if u.is_active or include_disabled_users] |
|
323 | 325 | |
324 | 326 |
if data_source.get('type') == 'formula': |
325 | 327 |
# the result of a python expression, it must be a list. |
... | ... | |
471 | 473 |
users_included_roles = None |
472 | 474 |
users_excluded_roles = None |
473 | 475 |
category_id = None |
476 |
include_disabled_users = False |
|
474 | 477 | |
475 | 478 |
SLUG_DASH = '_' |
476 | 479 | |
... | ... | |
494 | 497 |
('record_on_errors', 'bool'), |
495 | 498 |
('users_included_roles', 'str_list'), |
496 | 499 |
('users_excluded_roles', 'str_list'), |
500 |
('include_disabled_users', 'bool'), |
|
497 | 501 |
] |
498 | 502 | |
499 | 503 |
def __init__(self, name=None): |
... | ... | |
553 | 557 |
{ |
554 | 558 |
'included_roles': self.users_included_roles, |
555 | 559 |
'excluded_roles': self.users_excluded_roles, |
560 |
'include_disabled_users': self.include_disabled_users, |
|
556 | 561 |
} |
557 | 562 |
) |
558 | 563 |
return data_source |
wcs/templates/wcs/backoffice/data-source.html | ||
---|---|---|
43 | 43 |
{% endfor %} |
44 | 44 |
</ul> |
45 | 45 |
</li> |
46 |
<li>{% trans "Include disabled users :" %} |
|
47 |
{% if datasource.include_disabled_users %} |
|
48 |
{% trans "Yes" %} |
|
49 |
{% else %} |
|
50 |
{% trans "No" %} |
|
51 |
{% endif %} |
|
52 |
</li> |
|
46 | 53 |
{% endspaceless %} |
47 | 54 |
{% endif %} |
48 | 55 |
{% if datasource.cache_duration %} |
49 |
- |