admin: display if user is inactive (#50033)

This commit is contained in:
Lauréline Guérin 2021-01-15 15:02:48 +01:00
parent 9f2e23348b
commit 88a6d5ae9e
No known key found for this signature in database
GPG Key ID: 1FAB9B9B4F93D473
3 changed files with 30 additions and 4 deletions

View File

@ -64,7 +64,7 @@ def test_users_new(pub):
def test_users_new_with_account(pub):
pub.user_class.wipe()
PasswordAccount.wipe()
create_superuser(pub)
user = create_superuser(pub)
user_count = pub.user_class.count()
account_count = PasswordAccount.count()
app = login(get_app(pub))
@ -77,11 +77,18 @@ def test_users_new_with_account(pub):
assert resp.location == 'http://example.net/backoffice/users/'
resp = resp.follow()
assert 'a second user' in resp.text
assert 'user-inactive' not in resp.text
resp = resp.click('a second user')
assert 'User - a second user' in resp.text
assert pub.user_class.count() == user_count + 1
assert PasswordAccount.count() == account_count + 1
user = pub.user_class.get(int(user.id) + 1)
user.is_active = False
user.store()
resp = app.get('/backoffice/users/')
assert 'user-inactive' in resp.text
def test_users_edit(pub):
pub.user_class.wipe()
@ -91,12 +98,18 @@ def test_users_edit(pub):
app = login(get_app(pub))
resp = app.get('/backoffice/users/%s/' % user.id)
assert 'This user is not active.' not in resp.text
resp = resp.click(href='edit')
resp.forms[0]['is_admin'].checked = True
resp = resp.forms[0].submit('submit')
assert resp.location == 'http://example.net/backoffice/users/%s/' % user.id
resp = resp.follow()
user.is_active = False
user.store()
resp = app.get('/backoffice/users/%s/' % user.id)
assert 'This user is not active.' in resp.text
def test_users_edit_new_account(pub):
pub.user_class.wipe()

View File

@ -171,6 +171,8 @@ class UserPage(Directory):
r += htmltext('</div>') # splitcontent-left
r += htmltext('<div class="splitcontent-right">')
if not self.user.is_active:
r += htmltext('<div class="infonotice">%s</div>') % _('This user is not active.')
r += htmltext('<div class="bo-block">')
r += htmltext('<h3>%s</h3>') % _('Roles')
@ -376,12 +378,16 @@ class UsersDirectory(Directory):
r += htmltext('<ul class="biglist">')
for user in users:
user_classes = []
if not user.is_active:
user_classes.append('user-inactive')
if user.is_admin:
r += htmltext('<li class="user-is-admin">')
user_classes.append('user-is-admin')
elif user.roles:
r += htmltext('<li class="user-has-roles">')
user_classes.append('user-has-roles')
else:
r += htmltext('<li class="simple-user">')
user_classes.append('simple-user')
r += htmltext('<li class="%s">' % ' '.join(user_classes))
r += htmltext('<strong class="label"><a href="%s/">%s</a></strong>') % (user.id, user.display_name)
if user.email and False:
r += htmltext('<p class="details">')

View File

@ -504,6 +504,13 @@ tr.advisory-lock td:first-child::before {
content: "\f023"; /* lock */
}
ul.biglist li.user-inactive {
background-color: #ddd;
a {
opacity: 0.5;
}
}
ul.biglist li.user-is-admin strong a {
border-left: 5px solid #0099ff;
}