users: Minor fix to return value when getting last admin user

Tests:

- When only when admin user is present, the users list does not show delete
  button next to the admin user. The checkbox for admin group is disabled (but
  checked) for that user in edit user form.

- When there are multiple admin users preset, the users list shows delete button
  against all admin users. The checkbox for admin group is enabled (but checked)
  for all admin users.

Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
This commit is contained in:
Sunil Mohan Adapa 2019-08-23 11:29:34 -07:00 committed by James Valleroy
parent caa266e348
commit 2317e6bd94
No known key found for this signature in database
GPG Key ID: 77C0C75E7B650808
2 changed files with 2 additions and 4 deletions

View File

@ -129,7 +129,7 @@ def get_last_admin_user():
output = actions.superuser_run('users', ['get-group-users', 'admin'])
admin_users = output.strip().split('\n')
if len(admin_users) == 1:
if len(admin_users) == 1 and admin_users[0]:
return admin_users[0]
return None

View File

@ -80,9 +80,7 @@ class UserList(ContextMixin, django.views.generic.ListView):
def get_context_data(self, *args, **kwargs):
context = super(UserList, self).get_context_data(*args, **kwargs)
last_admin_user = get_last_admin_user()
if last_admin_user is not None:
context['last_admin_user'] = last_admin_user
context['last_admin_user'] = get_last_admin_user()
return context