Projet

Général

Profil

0002-admin-display-if-user-is-inactive-50033.patch

Lauréline Guérin, 15 janvier 2021 15:07

Télécharger (4,16 ko)

Voir les différences:

Subject: [PATCH 2/2] admin: display if user is inactive (#50033)

 tests/admin_pages/test_user.py       | 15 ++++++++++++++-
 wcs/admin/users.py                   | 12 +++++++++---
 wcs/qommon/static/css/dc2/admin.scss |  6 ++++++
 3 files changed, 29 insertions(+), 4 deletions(-)
tests/admin_pages/test_user.py
64 64
def test_users_new_with_account(pub):
65 65
    pub.user_class.wipe()
66 66
    PasswordAccount.wipe()
67
    create_superuser(pub)
67
    user = create_superuser(pub)
68 68
    user_count = pub.user_class.count()
69 69
    account_count = PasswordAccount.count()
70 70
    app = login(get_app(pub))
......
77 77
    assert resp.location == 'http://example.net/backoffice/users/'
78 78
    resp = resp.follow()
79 79
    assert 'a second user' in resp.text
80
    assert 'user-inactive' not in resp.text
80 81
    resp = resp.click('a second user')
81 82
    assert 'User - a second user' in resp.text
82 83
    assert pub.user_class.count() == user_count + 1
83 84
    assert PasswordAccount.count() == account_count + 1
84 85

  
86
    user = pub.user_class.get(int(user.id) + 1)
87
    user.is_active = False
88
    user.store()
89
    resp = app.get('/backoffice/users/')
90
    assert 'user-inactive' in resp.text
91

  
85 92

  
86 93
def test_users_edit(pub):
87 94
    pub.user_class.wipe()
......
91 98

  
92 99
    app = login(get_app(pub))
93 100
    resp = app.get('/backoffice/users/%s/' % user.id)
101
    assert 'This user is not active.' not in resp.text
94 102
    resp = resp.click(href='edit')
95 103
    resp.forms[0]['is_admin'].checked = True
96 104
    resp = resp.forms[0].submit('submit')
97 105
    assert resp.location == 'http://example.net/backoffice/users/%s/' % user.id
98 106
    resp = resp.follow()
99 107

  
108
    user.is_active = False
109
    user.store()
110
    resp = app.get('/backoffice/users/%s/' % user.id)
111
    assert 'This user is not active.' in resp.text
112

  
100 113

  
101 114
def test_users_edit_new_account(pub):
102 115
    pub.user_class.wipe()
wcs/admin/users.py
171 171
        r += htmltext('</div>') # splitcontent-left
172 172

  
173 173
        r += htmltext('<div class="splitcontent-right">')
174
        if not self.user.is_active:
175
            r += htmltext('<div class="infonotice">%s</div>') % _('This user is not active.')
174 176
        r += htmltext('<div class="bo-block">')
175 177
        r += htmltext('<h3>%s</h3>') % _('Roles')
176 178

  
......
376 378

  
377 379
        r += htmltext('<ul class="biglist">')
378 380
        for user in users:
381
            user_classes = []
382
            if not user.is_active:
383
                user_classes.append('user-inactive')
379 384
            if user.is_admin:
380
                r += htmltext('<li class="user-is-admin">')
385
                user_classes.append('user-is-admin')
381 386
            elif user.roles:
382
                r += htmltext('<li class="user-has-roles">')
387
                user_classes.append('user-has-roles')
383 388
            else:
384
                r += htmltext('<li class="simple-user">')
389
                user_classes.append('simple-user')
390
            r += htmltext('<li class="%s">' % ' '.join(user_classes))
385 391
            r += htmltext('<strong class="label"><a href="%s/">%s</a></strong>') % (user.id, user.display_name)
386 392
            if user.email and False:
387 393
                r += htmltext('<p class="details">')
wcs/qommon/static/css/dc2/admin.scss
518 518
	content: "\f023"; /* lock */
519 519
}
520 520

  
521
ul.biglist li.user-inactive {
522
	background-color: #ddd;
523
    a {
524
	    opacity: 0.5;
525
    }
526
}
521 527
ul.biglist li.user-is-admin strong a {
522 528
	border-left: 5px solid #0099ff;
523 529
}
524
-