Commit 6dae34a3 by zubair-arbi

Merge pull request #5923 from edx/zub/bugfix/wl-150-survey-form-error-on-info-page

avoid annonymous user from redirecting to survey form
parents 7ada9569 b7d526b9
......@@ -106,6 +106,20 @@ class SurveyViewsTests(LoginEnrollmentTestCase):
"""
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):
"""
Verifies that going to the courseware with an answered survey, there is no redirect
......
......@@ -586,7 +586,7 @@ def course_info(request, course_id):
# check to see if there is a required survey that must be taken before
# 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)]))
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