Skip to content
Snippets Groups Projects
Unverified Commit d05c250d authored by David Ormsbee's avatar David Ormsbee Committed by GitHub
Browse files

Merge pull request #25474 from mitodl/umar/sysadmin-190

remove users listing and staff listing download csv from the sysadmin
parents 39a22734 52ac0e03
Branches
Tags
No related merge requests found
......@@ -30,8 +30,7 @@ edX installations using Shibboleth and certificate-based authentication.
The courses tabs manages adding/updating courses from git, deleting courses, and provides course listing information,
including commit hash, date and author for course imported from git.
The Staffing tab provides a view of staffing and enrollment in courses that include an option to download the data
as a csv.
The Staffing tab provides a view of staffing and enrollment in courses.
The Gitlogs tab provides a view into the import log of courses from git repositories. It is convenient for allowing
course teams to see what may be wrong wit their xml. This is the only view that allows permits access by course
......
......@@ -31,7 +31,7 @@ would need to be added and/or moved into the cms application
3. Delete a course
https://github.com/edx/edx-platform/blob/master/lms/djangoapps/dashboard/sysadmin.py#L383-L408
https://github.com/edx/edx-platform/blob/b4556a4bec/lms/djangoapps/dashboard/sysadmin.py#L344-L369
These APIs can be removed entirely, as they are adequately covered by existing functionality:
......@@ -43,7 +43,7 @@ These APIs can be removed entirely, as they are adequately covered by existing f
2. Staffing and Enrollment
https://github.com/edx/edx-platform/blob/master/lms/djangoapps/dashboard/sysadmin.py#L419-L477
https://github.com/edx/edx-platform/blob/b4556a4bec/lms/djangoapps/dashboard/sysadmin.py#L380-L413
This functionality may be redundant to features in the Insights application.
......
......@@ -10,13 +10,12 @@ import os
import subprocess
import mongoengine
import unicodecsv as csv
from django.conf import settings
from django.contrib.auth.decorators import login_required
from django.contrib.auth.models import User
from django.core.paginator import EmptyPage, PageNotAnInteger, Paginator
from django.db import IntegrityError
from django.http import Http404, HttpResponse
from django.http import Http404
from django.utils.decorators import method_decorator
from django.utils.html import escape
from django.utils.translation import ugettext as _
......@@ -71,38 +70,6 @@ class SysadminDashboardView(TemplateView):
return self.def_ms.get_courses()
def return_csv(self, filename, header, data):
"""
Convenient function for handling the http response of a csv.
data should be iterable and is used to stream object over http
"""
csv_file = StringIO()
writer = csv.writer(csv_file, dialect='excel', quotechar='"',
quoting=csv.QUOTE_ALL)
writer.writerow(header)
# Setup streaming of the data
def read_and_flush():
"""Read and clear buffer for optimization"""
csv_file.seek(0)
csv_data = csv_file.read()
csv_file.seek(0)
csv_file.truncate()
return csv_data
def csv_data():
"""Generator for handling potentially large CSVs"""
for row in data:
writer.writerow(row)
csv_data = read_and_flush()
yield csv_data
response = HttpResponse(csv_data(), content_type='text/csv')
response['Content-Disposition'] = u'attachment; filename={0}'.format(
filename)
return response
class Users(SysadminDashboardView):
"""
......@@ -211,13 +178,7 @@ class Users(SysadminDashboardView):
action = request.POST.get('action', '')
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()))
return self.return_csv('users_{0}.csv'.format(
request.META['SERVER_NAME']), header, data)
elif action == 'create_user':
if action == 'create_user':
uname = request.POST.get('student_uname', '').strip()
name = request.POST.get('student_fullname', '').strip()
password = request.POST.get('student_password', '').strip()
......@@ -419,7 +380,7 @@ class Courses(SysadminDashboardView):
class Staffing(SysadminDashboardView):
"""
The status view provides a view of staffing and enrollment in
courses that include an option to download the data as a csv.
courses.
"""
def get(self, request):
......@@ -451,31 +412,6 @@ class Staffing(SysadminDashboardView):
}
return render_to_response(self.template_name, context)
def post(self, request):
"""Handle all actions from staffing and enrollment view"""
action = request.POST.get('action', '')
track.views.server_track(request, action, {},
page='staffing_sysdashboard')
if action == 'get_staff_csv':
data = []
roles = [CourseInstructorRole, CourseStaffRole, ]
for course in self.get_courses():
for role in roles:
for user in role(course.id).users_with_role():
datum = [course.id, role, user.username, user.email,
user.profile.name.encode('utf-8')]
data.append(datum)
header = [_('course_id'),
_('role'), _('username'),
_('email'), _('full_name'), ]
return self.return_csv('staff_{0}.csv'.format(
request.META['SERVER_NAME']), header, data)
return self.get(request)
class GitLogs(TemplateView):
"""
......
......@@ -102,11 +102,6 @@ textarea {
</div>
<hr />
<p>
<button type="submit" name="action" value="download_users" style="width: 350px;">
${_('Download list of all users (csv file)')}
</button>
</p>
<p>
<button type="submit" name="action" value="repair_eamap" style="width: 350px;">
......@@ -123,12 +118,6 @@ textarea {
<p>${_("Go to each individual course's Instructor dashboard to manage course enrollment.")}</p>
<hr />
<h3>${_('Manage course staff and instructors')}</h3><br/>
<form name="action" method="POST">
<input type="hidden" name="csrfmiddlewaretoken" value="${ csrf_token }" />
<button type="submit" name="action" value="get_staff_csv">${_('Download staff and instructor list (csv file)')}</button>
</form>
%endif
%if modeflag.get('courses'):
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment