Commit b7d526b9 by zubair-arbi

avoid annonymous user from redirecting to survey form

WL-150
parent d02747ff
...@@ -106,6 +106,20 @@ class SurveyViewsTests(LoginEnrollmentTestCase): ...@@ -106,6 +106,20 @@ class SurveyViewsTests(LoginEnrollmentTestCase):
""" """
self._assert_survey_redirect(self.course) self._assert_survey_redirect(self.course)
def test_anonymous_user_visiting_course_with_survey(self):
"""
Verifies that anonymous user going to the courseware info with an unanswered survey is not
redirected to survery and info page renders without server error.
"""
self.logout()
resp = self.client.get(
reverse(
'info',
kwargs={'course_id': unicode(self.course.id)}
)
)
self.assertEquals(resp.status_code, 200)
def test_visiting_course_with_existing_answers(self): def test_visiting_course_with_existing_answers(self):
""" """
Verifies that going to the courseware with an answered survey, there is no redirect Verifies that going to the courseware with an answered survey, there is no redirect
......
...@@ -586,7 +586,7 @@ def course_info(request, course_id): ...@@ -586,7 +586,7 @@ def course_info(request, course_id):
# check to see if there is a required survey that must be taken before # check to see if there is a required survey that must be taken before
# the user can access the course. # the user can access the course.
if survey.utils.must_answer_survey(course, request.user): if request.user.is_authenticated() and survey.utils.must_answer_survey(course, request.user):
return redirect(reverse('course_survey', args=[unicode(course.id)])) return redirect(reverse('course_survey', args=[unicode(course.id)]))
staff_access = has_access(request.user, 'staff', course) staff_access = has_access(request.user, 'staff', course)
......
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