Esempio n. 1
0
 def __init__(self, course_key, request, username=''):
     self.request = request
     self.overview = course_detail(
         self.request,
         username or self.request.user.username,
         course_key,
     )
     # We must compute course load access *before* setting up masquerading,
     # else course staff (who are not enrolled) will not be able view
     # their course from the perspective of a learner.
     self.load_access = check_course_access(
         self.overview,
         self.request.user,
         'load',
         check_if_enrolled=True,
         check_if_authenticated=True,
     )
     self.original_user_is_staff = has_access(self.request.user, 'staff', self.overview).has_access
     self.original_user_is_global_staff = self.request.user.is_staff
     self.course_key = course_key
     self.course = get_course_by_id(self.course_key)
     self.course_masquerade, self.effective_user = setup_masquerade(
         self.request,
         course_key,
         staff_access=self.original_user_is_staff,
     )
     self.request.user = self.effective_user
     self.is_staff = has_access(self.effective_user, 'staff', self.overview).has_access
     self.enrollment_object = CourseEnrollment.get_enrollment(self.effective_user, self.course_key,
                                                              select_related=['celebration', 'user__celebration'])
     self.can_view_legacy_courseware = courseware_legacy_is_visible(
         course_key=course_key,
         is_global_staff=self.original_user_is_global_staff,
     )
Esempio n. 2
0
    def __init__(self, course_key, request, username=''):
        self.request = request
        self.overview = course_detail(
            self.request,
            username or self.request.user.username,
            course_key,
        )

        self.original_user_is_staff = has_access(self.request.user, 'staff',
                                                 self.overview).has_access
        self.original_user_is_global_staff = self.request.user.is_staff
        self.course_key = course_key
        self.course = get_course_by_id(self.course_key)
        self.course_masquerade, self.effective_user = setup_masquerade(
            self.request,
            course_key,
            staff_access=self.original_user_is_staff,
        )
        self.request.user = self.effective_user
        self.is_staff = has_access(self.effective_user, 'staff',
                                   self.overview).has_access
        self.enrollment_object = CourseEnrollment.get_enrollment(
            self.effective_user,
            self.course_key,
            select_related=['celebration', 'user__celebration'])
        self.can_view_legacy_courseware = courseware_legacy_is_visible(
            course_key=course_key,
            is_global_staff=self.original_user_is_global_staff,
        )