'Retrieves the specified course, or raises an Http404 error if it does not exist.
Also checks to ensure the user has permissions to view the course'

def get_course_or_404(self):

    try:
        course_id = self.kwargs.get('course_id')
        course_key = CourseKey.from_string(course_id)
        course = courses.get_course(course_key)
        self.check_course_permissions(self.request.user, course_key)
        return course
    except ValueError:
        raise Http404
