diff --git a/lms/djangoapps/dashboard/tests/test_sysadmin.py b/lms/djangoapps/dashboard/tests/test_sysadmin.py index f4c802b059..d2ad4a9280 100644 --- a/lms/djangoapps/dashboard/tests/test_sysadmin.py +++ b/lms/djangoapps/dashboard/tests/test_sysadmin.py @@ -552,6 +552,33 @@ class TestSysAdminMongoCourseImport(SysadminBaseTestCase): 'course_id': 'Not/Real/Testing'})) self.assertEqual(404, response.status_code) + def test_gitlog_no_logs(self): + """ + Make sure the template behaves well when rendered despite there not being any logs. + (This is for courses imported using methods other than the git_add_course command) + """ + + self._setstaff_login() + self._mkdir(getattr(settings, 'GIT_REPO_DIR')) + + self._add_edx4edx() + + # Simulate a lack of git import logs + import_logs = CourseImportLog.objects.all() + import_logs.delete() + + response = self.client.get( + reverse('gitlogs_detail', kwargs={ + 'course_id': 'MITx/edx4edx/edx4edx' + }) + ) + self.assertIn( + 'No git import logs have been recorded for this course.', + response.content + ) + + self._rm_edx4edx() + def test_gitlog_courseteam_access(self): """ Ensure course team users are allowed to access only their own course. diff --git a/lms/templates/sysadmin_dashboard_gitlogs.html b/lms/templates/sysadmin_dashboard_gitlogs.html index 6217114a78..9d1e224209 100644 --- a/lms/templates/sysadmin_dashboard_gitlogs.html +++ b/lms/templates/sysadmin_dashboard_gitlogs.html @@ -97,6 +97,8 @@ textarea { logs = cilset[:10] else: logs = cilset[:2] + + cil = None %> % for cil in logs: <% @@ -114,7 +116,14 @@ textarea { %if course_id is not None:
${cil.import_log | h}
+
+ %if cil is not None:
+ ${cil.import_log | h}
+ %else:
+ ## Translators: git is a version-control system; see http://git-scm.com/about
+ ${_('No git import logs have been recorded for this course.')}
+ %endif
+