From 2317e6bd94f9f97e0d5fb04b14bf92c1110737c7 Mon Sep 17 00:00:00 2001 From: Sunil Mohan Adapa Date: Fri, 23 Aug 2019 11:29:34 -0700 Subject: [PATCH] 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 Reviewed-by: James Valleroy --- plinth/modules/users/__init__.py | 2 +- plinth/modules/users/views.py | 4 +--- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/plinth/modules/users/__init__.py b/plinth/modules/users/__init__.py index 5acf793ab..747dae9c5 100644 --- a/plinth/modules/users/__init__.py +++ b/plinth/modules/users/__init__.py @@ -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 diff --git a/plinth/modules/users/views.py b/plinth/modules/users/views.py index 29a7e0fc9..668a8b03a 100644 --- a/plinth/modules/users/views.py +++ b/plinth/modules/users/views.py @@ -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