Commit 3aecac7a by Carson Gee

Correct exception raising bug for non global staff accessing missing course git logs

parent d35a56bc
...@@ -370,7 +370,7 @@ class Courses(SysadminDashboardView): ...@@ -370,7 +370,7 @@ class Courses(SysadminDashboardView):
msg = u'' msg = u''
logging.debug('Adding course using git repo {0}'.format(gitloc)) log.debug('Adding course using git repo {0}'.format(gitloc))
# Grab logging output for debugging imports # Grab logging output for debugging imports
output = StringIO.StringIO() output = StringIO.StringIO()
...@@ -674,7 +674,7 @@ class GitLogs(TemplateView): ...@@ -674,7 +674,7 @@ class GitLogs(TemplateView):
else: else:
mdb = mongoengine.connect(mongo_db['db'], host=mongo_db['host']) mdb = mongoengine.connect(mongo_db['db'], host=mongo_db['host'])
except mongoengine.connection.ConnectionError: except mongoengine.connection.ConnectionError:
logging.exception('Unable to connect to mongodb to save log, ' log.exception('Unable to connect to mongodb to save log, '
'please check MONGODB_LOG settings.') 'please check MONGODB_LOG settings.')
if course_id is None: if course_id is None:
...@@ -686,8 +686,8 @@ class GitLogs(TemplateView): ...@@ -686,8 +686,8 @@ class GitLogs(TemplateView):
try: try:
course = get_course_by_id(course_id) course = get_course_by_id(course_id)
except Exception: # pylint: disable=broad-except except Exception: # pylint: disable=broad-except
cilset = None log.info('Cannot find course {0}'.format(course_id))
error_msg = _('Cannot find course {0}').format(course_id) raise Http404
# Allow only course team, instructors, and staff # Allow only course team, instructors, and staff
if not (request.user.is_staff or if not (request.user.is_staff or
......
...@@ -467,7 +467,7 @@ class TestSysAdminMongoCourseImport(SysadminBaseTestCase): ...@@ -467,7 +467,7 @@ class TestSysAdminMongoCourseImport(SysadminBaseTestCase):
response = self.client.get( response = self.client.get(
reverse('gitlogs_detail', kwargs={ reverse('gitlogs_detail', kwargs={
'course_id': 'Not/Real/Testing'})) 'course_id': 'Not/Real/Testing'}))
self.assertIn(_('Cannot find course'), response.content) self.assertEqual(404, response.status_code)
def test_gitlog_courseteam_access(self): def test_gitlog_courseteam_access(self):
""" """
......
Markdown is supported
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