Skip to content

Commit

Permalink
update admin report format
Browse files Browse the repository at this point in the history
  • Loading branch information
AliSalman committed Feb 3, 2022
1 parent 0b81d03 commit 7e1fb14
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions lms/djangoapps/dashboard/sysadmin.py
Original file line number Diff line number Diff line change
Expand Up @@ -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':
Expand Down

0 comments on commit 7e1fb14

Please sign in to comment.