From 7e1fb149bf8a2f505288991074ebbe16213b48e0 Mon Sep 17 00:00:00 2001 From: AliSalman Date: Thu, 3 Feb 2022 16:20:17 +0500 Subject: [PATCH] update admin report format --- lms/djangoapps/dashboard/sysadmin.py | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/lms/djangoapps/dashboard/sysadmin.py b/lms/djangoapps/dashboard/sysadmin.py index 91b208b39aa..469a22223be 100644 --- a/lms/djangoapps/dashboard/sysadmin.py +++ b/lms/djangoapps/dashboard/sysadmin.py @@ -212,9 +212,17 @@ def post(self, request): track.views.server_track(request, action, {}, page='user_sysdashboard') if action == 'download_users': - header = [_('username'), _('email'), ] - data = ([u.username, u.email] for u in - (User.objects.all().iterator())) + header = [_('username'), _('email'), _('name'), _('country') ] + data = [] + for u in (User.objects.select_related('profile').iterator()): + try: + data.append([u.username, u.email, u.profile.name, u.profile.country]) + except UserProfile.DoesNotExist as err: + data.append([u.username, u.email, '', '']) + msg = _(u'Cannot find user profile with username {username} - {error}').format( + username=u.username, + error=str(err)) + log.warning(msg) return self.return_csv('users_{0}.csv'.format( request.META['SERVER_NAME']), header, data) elif action == 'create_user':