diff --git a/lms/djangoapps/class_dashboard/dashboard_data.py b/lms/djangoapps/class_dashboard/dashboard_data.py index c4a04d54c4..ede9d87170 100644 --- a/lms/djangoapps/class_dashboard/dashboard_data.py +++ b/lms/djangoapps/class_dashboard/dashboard_data.py @@ -3,6 +3,7 @@ Computes the data to display on the Instructor Dashboard """ from __future__ import absolute_import +import decimal import json from django.db.models import Count @@ -534,7 +535,7 @@ def get_students_problem_grades(request, csv=False): for student in students: percent = 0 if student['max_grade'] > 0: - percent = round(student['grade'] * 100 / student['max_grade']) + percent = round(decimal.Decimal(student['grade'] * 100 / student['max_grade']), 1) results.append([student['student__profile__name'], student['student__username'], student['grade'], percent]) response = create_csv_response(filename, header, results) @@ -599,5 +600,5 @@ def sanitize_filename(filename): """ filename = filename.replace(" ", "_") filename = filename.encode('utf-8') - filename = filename[0:25] + '.csv' + filename = filename[0:25].decode('utf-8') + '.csv' return filename diff --git a/lms/djangoapps/dashboard/git_import.py b/lms/djangoapps/dashboard/git_import.py index 224e1c2aff..bfb5379f49 100644 --- a/lms/djangoapps/dashboard/git_import.py +++ b/lms/djangoapps/dashboard/git_import.py @@ -230,7 +230,7 @@ def add_repo(repo, rdir_in, branch=None): cwd = os.path.abspath(cwd) try: - ret_git = cmd_log(cmd, cwd=cwd) + ret_git = cmd_log(cmd, cwd=cwd).decode('utf-8') except subprocess.CalledProcessError as ex: log.exception(u'Error running git pull: %r', ex.output) raise GitImportErrorCannotPull() @@ -246,7 +246,7 @@ def add_repo(repo, rdir_in, branch=None): log.exception(u'Unable to get git log: %r', ex.output) raise GitImportErrorBadRepo() - ret_git += u'\nCommit ID: {0}'.format(commit_id) + ret_git += u'\nCommit ID: {0}'.format(commit_id.decode('utf-8')) # get branch cmd = ['git', 'symbolic-ref', '--short', 'HEAD', ] diff --git a/lms/djangoapps/dashboard/sysadmin.py b/lms/djangoapps/dashboard/sysadmin.py index 69f9c83569..08930c32b2 100644 --- a/lms/djangoapps/dashboard/sysadmin.py +++ b/lms/djangoapps/dashboard/sysadmin.py @@ -261,7 +261,7 @@ class Courses(SysadminDashboardView): cmd = ['git', 'log', '-1', u'--format=format:{ "commit": "%H", "author": "%an %ae", "date": "%ad"}', ] try: - output_json = json.loads(subprocess.check_output(cmd, cwd=gdir)) + output_json = json.loads(subprocess.check_output(cmd, cwd=gdir).decode('utf-8')) info = [output_json['commit'], output_json['date'], output_json['author'], ] diff --git a/lms/djangoapps/dashboard/tests/test_sysadmin.py b/lms/djangoapps/dashboard/tests/test_sysadmin.py index 3e1d12fe97..deec7afdd2 100644 --- a/lms/djangoapps/dashboard/tests/test_sysadmin.py +++ b/lms/djangoapps/dashboard/tests/test_sysadmin.py @@ -212,14 +212,13 @@ class TestSysAdminMongoCourseImport(SysadminBaseTestCase): response = self.client.get(reverse('gitlogs')) # Check that our earlier import has a log with a link to details - self.assertIn('/gitlogs/course-v1:MITx+edx4edx+edx4edx', response.content) + self.assertIn('/gitlogs/course-v1:MITx+edx4edx+edx4edx', response.content.decode('utf-8')) response = self.client.get( reverse('gitlogs_detail', kwargs={ 'course_id': 'course-v1:MITx+edx4edx+edx4edx'})) - self.assertIn('======> IMPORTING course', - response.content) + self.assertIn('======> IMPORTING course', response.content.decode('utf-8')) self._rm_edx4edx() @@ -285,10 +284,7 @@ class TestSysAdminMongoCourseImport(SysadminBaseTestCase): 'course_id': 'course-v1:MITx+edx4edx+edx4edx' }) ) - self.assertIn( - 'No git import logs have been recorded for this course.', - response.content - ) + self.assertIn('No git import logs have been recorded for this course.', response.content.decode('utf-8')) self._rm_edx4edx() @@ -362,7 +358,6 @@ class TestSysAdminMongoCourseImport(SysadminBaseTestCase): reverse('gitlogs_detail', kwargs={ 'course_id': 'course-v1:MITx+edx4edx+edx4edx' })) - self.assertIn('======> IMPORTING course', - response.content) + self.assertIn('======> IMPORTING course', response.content.decode('utf-8')) self._rm_edx4edx()