0001-manager-select-default-ou-in-users-table-45338.patch
src/authentic2/manager/forms.py | ||
---|---|---|
576 | 576 | |
577 | 577 |
def __init__(self, *args, **kwargs): |
578 | 578 |
self.minimum_chars = kwargs.pop('minimum_chars', 0) |
579 |
initial = kwargs.setdefault('initial', {}) |
|
580 |
initial['ou'] = str(get_default_ou().pk) |
|
579 | 581 |
super(UserSearchForm, self).__init__(*args, **kwargs) |
580 | 582 | |
581 | 583 |
def not_enough_chars(self): |
tests/test_manager.py | ||
---|---|---|
410 | 410 |
options = field.options |
411 | 411 |
assert len(options) == 4 |
412 | 412 |
for key, checked, label in options: |
413 |
assert not checked or key == 'all'
|
|
413 |
assert not checked or key == str(get_default_ou().pk)
|
|
414 | 414 |
assert 'all' in [o[0] for o in options] |
415 | 415 |
assert 'none' in [o[0] for o in options] |
416 | 416 |
# verify table shown |
417 | 417 |
q = response.pyquery.remove_namespaces() |
418 |
assert len(q('table tbody tr')) == 3 |
|
419 |
assert set([e.text for e in q('table tbody td.username')]) == {'admin', 'superuser', |
|
420 |
'admin.ou1'} |
|
418 |
assert len(q('table tbody tr')) == len(User.objects.filter(ou=get_default_ou())) |
|
419 |
assert set([e.text for e in q('table tbody td.username')]) == {'admin'} |
|
421 | 420 | |
422 | 421 |
# test user's role page |
423 | 422 |
response = app.get('/manage/users/%d/roles/' % admin.pk) |
tests/test_user_manager.py | ||
---|---|---|
297 | 297 |
# queries should be batched to keep prefetching working without |
298 | 298 |
# overspending memory for the queryset cache, 4 queries by batches |
299 | 299 |
num_queries = int(4 + 4 * (user_count / DEFAULT_BATCH_SIZE + bool(user_count % DEFAULT_BATCH_SIZE))) |
300 |
num_queries += 1 # get_default_ou form call |
|
300 | 301 |
with django_assert_num_queries(num_queries): |
301 | 302 |
response = response.click('CSV') |
302 | 303 |
table = list(csv.reader(response.text.splitlines())) |
... | ... | |
335 | 336 |
response = login(app, admin, '/manage/users/') |
336 | 337 |
assert response.pyquery('td.username') |
337 | 338 | |
339 |
assert response.pyquery('select#id_search-ou option:selected').val() == str(get_default_ou().pk) |
|
340 |
assert admin.username in response.text |
|
341 |
assert not user_ou1.username in response.text |
|
342 | ||
338 | 343 |
# hide all usernames, from specific and general view |
339 | 344 |
OU.objects.update(show_username=False) |
340 | 345 |
has_show_username.cache.clear() |
341 |
- |