misc: add support for bullseye's django-tables2 (#62783)
(and its subsequent changes in authentic2 -- #62527)
This commit is contained in:
parent
1c4f35aa6d
commit
1ccf9ec535
|
@ -255,7 +255,7 @@ class AppConfig(django.apps.AppConfig):
|
|||
base_columns = copy.deepcopy(type(table).base_columns)
|
||||
|
||||
if ou and ou.slug == 'usagers':
|
||||
for column_name in ['username', 'link']:
|
||||
for column_name in ['username', 'get_full_name']:
|
||||
if column_name in base_columns:
|
||||
del base_columns[column_name]
|
||||
if column_name in sequence:
|
||||
|
@ -271,8 +271,8 @@ class AppConfig(django.apps.AppConfig):
|
|||
)
|
||||
sequence += ['validated']
|
||||
else:
|
||||
del base_columns['link']
|
||||
sequence.remove('link')
|
||||
del base_columns['get_full_name']
|
||||
sequence.remove('get_full_name')
|
||||
|
||||
table.base_columns = base_columns
|
||||
table.sequence = sequence
|
||||
|
|
|
@ -0,0 +1,33 @@
|
|||
from authentic2.manager.tables import UserTable
|
||||
from authentic2.manager.user_views import UsersView
|
||||
from utils import login
|
||||
|
||||
from authentic2_cut.apps import AppConfig
|
||||
|
||||
|
||||
def test_a2_hook_manager_modify_table(db, rf, admin, monkeypatch, app):
|
||||
class DummyModule:
|
||||
__path__ = [
|
||||
'./dummy',
|
||||
]
|
||||
|
||||
dummy = DummyModule()
|
||||
app_config = AppConfig('authentic2_cut', dummy)
|
||||
user_table = UserTable(data={})
|
||||
request = rf.get('/manage/users/')
|
||||
request.user = admin
|
||||
users_view = UsersView.as_view()(request)
|
||||
|
||||
# base table contains a2 generic column
|
||||
assert 'get_full_name' in list(user_table.sequence)
|
||||
assert len(list(user_table.sequence)) == 6
|
||||
assert 'get_full_name' in user_table.base_columns
|
||||
assert len(list(user_table.base_columns)) == 6
|
||||
|
||||
# does not crash when explicitely run
|
||||
app_config.a2_hook_manager_modify_table(users_view, user_table)
|
||||
|
||||
# and most of all the rendered table does not contain any such column
|
||||
response = login(app, admin, '/manage/users/')
|
||||
assert 'get_full_name' not in response.html
|
||||
assert len(response.pyquery.find('thead').find('tr').children()) == 5
|
10
tox.ini
10
tox.ini
|
@ -6,11 +6,13 @@
|
|||
[tox]
|
||||
toxworkdir = {env:TMPDIR:/tmp}/tox-{env:USER}/authentic2-cut/{env:BRANCH_NAME:}
|
||||
envlist =
|
||||
py3-dj22-drf3{9,12}
|
||||
py3-dj22-drf39-djtables1211
|
||||
py3-dj22-drf312-djtables211
|
||||
|
||||
[tox:jenkins]
|
||||
envlist =
|
||||
py3-dj22-drf3{9,12}
|
||||
py3-dj22-drf39-djtables1211
|
||||
py3-dj22-drf312-djtables211
|
||||
check-migrations
|
||||
code-style
|
||||
pylint
|
||||
|
@ -38,8 +40,8 @@ deps =
|
|||
py3: file-magic
|
||||
drf39: djangorestframework>=3.9.2,<3.10
|
||||
drf312: djangorestframework>=3.12,<3.13
|
||||
dj22: django<2.3
|
||||
django-tables<2.0
|
||||
djtables1211: django-tables2==1.21.1
|
||||
djtables211: django-tables2==2.1.1
|
||||
psycopg2-binary<2.9
|
||||
oldldap: python-ldap<3
|
||||
ldaptools
|
||||
|
|
Loading…
Reference in New Issue