Beispiel #1
0
    def is_microfrontend_enabled_for_user(self):
        """
        This method is the "opposite" of _redirect_to_learning_mfe in
        lms/djangoapps/courseware/views/index.py. But not exactly...

        1. It needs to respect the global
           ENABLE_COURSEWARE_MICROFRONTEND feature flag and redirect users
           out of the MFE experience if it's turned off.
        2. It needs to redirect for old Mongo courses.
        3. It does NOT need to worry about exams - the MFE will handle
           those on its own. As of this writing, it will redirect back to
           the LMS experience, but that may change soon.
        4. Finally, it needs to redirect users who are bucketed out of
           the MFE experience, but who aren't staff. Staff are allowed to
           stay.
        """
        # REDIRECT: feature disabled globally
        if not settings.FEATURES.get('ENABLE_COURSEWARE_MICROFRONTEND'):
            return False
        # REDIRECT: Old Mongo courses, until removed from platform
        if self.course_key.deprecated:
            return False
        # REDIRECT: If the user isn't staff, redirect if they're bucketed into the old LMS experience.
        if not self.original_user_is_staff and not REDIRECT_TO_COURSEWARE_MICROFRONTEND.is_enabled(
                self.course_key):
            return False
        # STAY: If the user has made it past all the above, they're good to stay!
        return True
Beispiel #2
0
def create_course_enrollment_celebration(sender, instance, created, **kwargs):
    """
    Creates celebration rows when enrollments are created

    This is how we distinguish between new enrollments that we want to celebrate and old ones
    that existed before we introduced a given celebration.
    """
    if not created:
        return

    # The UI for celebrations is only supported on the MFE right now, so don't turn on
    # celebrations unless this enrollment's course is MFE-enabled.
    if not REDIRECT_TO_COURSEWARE_MICROFRONTEND.is_enabled(instance.course_id):
        return

    try:
        CourseEnrollmentCelebration.objects.create(
            enrollment=instance,
            celebrate_first_section=True,
        )
    except IntegrityError:
        # A celebration object was already created. Shouldn't happen, but ignore it if it does.
        pass