avoid annonymous user from redirecting to survey form
WL-150
This commit is contained in:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user