Exemplo n.º 1
0
def waffle_flags():
    """
    Returns the namespaced, cached, audited Waffle flags dictionary for Grades.

    WARNING: do not replicate this pattern. Instead of declaring waffle flag names as strings, you should create
    WaffleFlag and CourseWaffleFlag objects as top-level constants.
    """
    namespace = WaffleFlagNamespace(name=WAFFLE_NAMESPACE, log_prefix=u'Grades: ')
    return {
        # By default, enable rejected exam grade overrides. Can be disabled on a course-by-course basis.
        # TODO: After removing this flag, add a migration to remove waffle flag in a follow-up deployment.
        REJECTED_EXAM_OVERRIDES_GRADE: CourseWaffleFlag(
            namespace,
            REJECTED_EXAM_OVERRIDES_GRADE,
            __name__,
        ),
        # TODO: After removing this flag, add a migration to remove waffle flag in a follow-up deployment.
        ENFORCE_FREEZE_GRADE_AFTER_COURSE_END: CourseWaffleFlag(
            namespace,
            ENFORCE_FREEZE_GRADE_AFTER_COURSE_END,
            __name__,
        ),
        # Have this course override flag so we can selectively turn off the gradebook for courses.
        # TODO: After removing this flag, add a migration to remove waffle flag in a follow-up deployment.
        WRITABLE_GRADEBOOK: CourseWaffleFlag(
            namespace,
            WRITABLE_GRADEBOOK,
            __name__,
        ),
        BULK_MANAGEMENT: CourseWaffleFlag(
            namespace,
            BULK_MANAGEMENT,
            __name__,
        ),
    }
Exemplo n.º 2
0
def waffle_flags():
    """
    Returns the namespaced, cached, audited Waffle flags dictionary for Videos.
    """
    namespace = WaffleFlagNamespace(name=WAFFLE_NAMESPACE, log_prefix=u'Videos: ')
    return {
        DEPRECATE_YOUTUBE: CourseWaffleFlag(
            waffle_namespace=namespace,
            flag_name=DEPRECATE_YOUTUBE,
            module_name=__name__,
        ),
        ENABLE_DEVSTACK_VIDEO_UPLOADS: WaffleFlag(
            waffle_namespace=namespace,
            flag_name=ENABLE_DEVSTACK_VIDEO_UPLOADS,
            module_name=__name__,
        ),
        ENABLE_VEM_PIPELINE: CourseWaffleFlag(
            waffle_namespace=namespace,
            flag_name=ENABLE_VEM_PIPELINE,
            module_name=__name__,
        )
    }
Exemplo n.º 3
0
from lms.djangoapps.experiments.stable_bucketing import stable_bucketing_hash_group
from openedx.features.discounts.models import DiscountPercentageConfig, DiscountRestrictionConfig
from common.djangoapps.student.models import CourseEnrollment
from common.djangoapps.track import segment

# .. toggle_name: discounts.enable_discounting
# .. toggle_implementation: WaffleFlag
# .. toggle_default: False
# .. toggle_description: Toggle discounts always being disabled
# .. toggle_use_cases: temporary
# .. toggle_creation_date: 2019-4-16
# .. toggle_target_removal_date: None
# .. toggle_tickets: REVEM-282
# .. toggle_warnings: This temporary feature toggle does not have a target removal date.
DISCOUNT_APPLICABILITY_FLAG = WaffleFlag(
    waffle_namespace=WaffleFlagNamespace(name=u'discounts'),
    flag_name=u'enable_discounting',
    module_name=__name__,
)

DISCOUNT_APPLICABILITY_HOLDBACK = 'first_purchase_discount_holdback'
REV1008_EXPERIMENT_ID = 16


def get_discount_expiration_date(user, course):
    """
    Returns the date when the discount expires for the user.
    Returns none if the user is not enrolled.
    """
    # anonymous users should never get the discount
    if user.is_anonymous:
Exemplo n.º 4
0
"""
Unified course experience settings and helper methods.
"""
import crum
from django.utils.translation import ugettext as _
from edx_django_utils.monitoring import set_custom_attribute
from waffle import flag_is_active

from edx_toggles.toggles import WaffleFlag, WaffleFlagNamespace
from lms.djangoapps.experiments.flags import ExperimentWaffleFlag
from openedx.core.djangoapps.util.user_messages import UserMessageCollection
from openedx.core.djangoapps.waffle_utils import CourseWaffleFlag

# Namespace for course experience waffle flags.
WAFFLE_FLAG_NAMESPACE = WaffleFlagNamespace(name='course_experience')

COURSE_EXPERIENCE_WAFFLE_FLAG_NAMESPACE = WaffleFlagNamespace(
    name='course_experience')

# Waffle flag to disable the separate course outline page and full width content.
DISABLE_COURSE_OUTLINE_PAGE_FLAG = CourseWaffleFlag(
    COURSE_EXPERIENCE_WAFFLE_FLAG_NAMESPACE, 'disable_course_outline_page',
    __name__)

# Waffle flag to enable a single unified "Course" tab.
DISABLE_UNIFIED_COURSE_TAB_FLAG = CourseWaffleFlag(
    COURSE_EXPERIENCE_WAFFLE_FLAG_NAMESPACE, 'disable_unified_course_tab',
    __name__)

# Waffle flag to enable the sock on the footer of the home and courseware pages.
DISPLAY_COURSE_SOCK_FLAG = CourseWaffleFlag(WAFFLE_FLAG_NAMESPACE,
Exemplo n.º 5
0
"""
Toggles for course home experience.
"""

from edx_toggles.toggles import WaffleFlagNamespace
from lms.djangoapps.experiments.flags import ExperimentWaffleFlag
from openedx.core.djangoapps.waffle_utils import CourseWaffleFlag

WAFFLE_FLAG_NAMESPACE = WaffleFlagNamespace(name='course_home')

COURSE_HOME_MICROFRONTEND = ExperimentWaffleFlag(WAFFLE_FLAG_NAMESPACE,
                                                 'course_home_mfe', __name__)

COURSE_HOME_MICROFRONTEND_DATES_TAB = CourseWaffleFlag(
    WAFFLE_FLAG_NAMESPACE, 'course_home_mfe_dates_tab', __name__)

COURSE_HOME_MICROFRONTEND_OUTLINE_TAB = CourseWaffleFlag(
    WAFFLE_FLAG_NAMESPACE, 'course_home_mfe_outline_tab', __name__)


def course_home_mfe_dates_tab_is_active(course_key):
    return (COURSE_HOME_MICROFRONTEND.is_enabled(course_key)
            and COURSE_HOME_MICROFRONTEND_DATES_TAB.is_enabled(course_key))


def course_home_mfe_outline_tab_is_active(course_key):
    return (COURSE_HOME_MICROFRONTEND.is_enabled(course_key)
            and COURSE_HOME_MICROFRONTEND_OUTLINE_TAB.is_enabled(course_key))
Exemplo n.º 6
0
from lms.djangoapps.courseware.access import has_staff_access_to_preview_mode
from lms.djangoapps.courseware.utils import can_show_verified_upgrade, verified_upgrade_deadline_link
from openedx.core.djangoapps.catalog.utils import get_programs
from openedx.core.djangoapps.django_comment_common.models import Role
from openedx.core.djangoapps.schedules.models import Schedule
from openedx.features.course_duration_limits.access import get_user_course_duration, get_user_course_expiration_date
from common.djangoapps.student.models import CourseEnrollment
from xmodule.partitions.partitions_service import get_all_partitions_for_course, get_user_partition_groups

# Import this for backwards compatibility (so that anyone importing this function from here doesn't break)
from .stable_bucketing import stable_bucketing_hash_group  # pylint: disable=unused-import

logger = logging.getLogger(__name__)

# TODO: clean up as part of REVEM-199 (START)
experiments_namespace = WaffleFlagNamespace(name=u'experiments')

# .. toggle_name: experiments.add_programs
# .. toggle_implementation: WaffleFlag
# .. toggle_default: False
# .. toggle_description: Toggle for adding the current course's program information to user metadata
# .. toggle_use_cases: temporary
# .. toggle_creation_date: 2019-2-25
# .. toggle_target_removal_date: None
# .. toggle_tickets: REVEM-63, REVEM-198
# .. toggle_warnings: This temporary feature toggle does not have a target removal date.
PROGRAM_INFO_FLAG = WaffleFlag(
    waffle_namespace=experiments_namespace,
    flag_name=u'add_programs',
    module_name=__name__,
)
Exemplo n.º 7
0
def waffle_flags():
    """
    Returns the namespaced, cached, audited Waffle Flag class for Studio pages.
    """
    return WaffleFlagNamespace(name=WAFFLE_NAMESPACE, log_prefix=u'Studio: ')
Exemplo n.º 8
0
"""
Toggles for Learner Profile page.
"""


from edx_toggles.toggles import WaffleFlag, WaffleFlagNamespace
from openedx.core.djangoapps.site_configuration import helpers as configuration_helpers

# Namespace for learner profile waffle flags.
WAFFLE_FLAG_NAMESPACE = WaffleFlagNamespace(name='learner_profile')

# Waffle flag to redirect to another learner profile experience.
# .. toggle_name: learner_profile.redirect_to_microfrontend
# .. toggle_implementation: WaffleFlag
# .. toggle_default: False
# .. toggle_description: Supports staged rollout of a new micro-frontend-based implementation of the profile page.
# .. toggle_use_cases: temporary, open_edx
# .. toggle_creation_date: 2019-02-19
# .. toggle_target_removal_date: 2020-12-31
# .. toggle_warnings: Also set settings.PROFILE_MICROFRONTEND_URL and site's ENABLE_PROFILE_MICROFRONTEND.
# .. toggle_tickets: DEPR-17
REDIRECT_TO_PROFILE_MICROFRONTEND = WaffleFlag(WAFFLE_FLAG_NAMESPACE, 'redirect_to_microfrontend', __name__)


def should_redirect_to_profile_microfrontend():
    return (
        configuration_helpers.get_value('ENABLE_PROFILE_MICROFRONTEND') and
        REDIRECT_TO_PROFILE_MICROFRONTEND.is_enabled()
    )
Exemplo n.º 9
0
}
REGISTRATION_UTM_CREATED_AT = 'registration_utm_created_at'
# used to announce a registration
REGISTER_USER = Signal(providing_args=["user", "registration"])

# .. toggle_name: registration.enable_failure_logging
# .. toggle_implementation: WaffleFlag
# .. toggle_default: False
# .. toggle_description: Enable verbose logging of registration failure messages
# .. toggle_use_cases: temporary
# .. toggle_creation_date: 2020-04-30
# .. toggle_target_removal_date: 2020-06-01
# .. toggle_warnings: This temporary feature toggle does not have a target removal date.
# .. toggle_tickets: None
REGISTRATION_FAILURE_LOGGING_FLAG = WaffleFlag(
    waffle_namespace=WaffleFlagNamespace(name=u'registration'),
    flag_name=u'enable_failure_logging',
    module_name=__name__,
)
REAL_IP_KEY = 'openedx.core.djangoapps.util.ratelimit.real_ip'


@transaction.non_atomic_requests
def create_account_with_params(request, params):
    """
    Given a request and a dict of parameters (which may or may not have come
    from the request), create an account for the requesting user, including
    creating a comments service user object and sending an activation email.
    This also takes external/third-party auth into account, updates that as
    necessary, and authenticates the user for the request's session.
Exemplo n.º 10
0
"""
Toggles for verify_student app
"""

from edx_toggles.toggles import WaffleFlag, WaffleFlagNamespace

# Namespace for verify_students waffle flags.
WAFFLE_FLAG_NAMESPACE = WaffleFlagNamespace(name='verify_student')

# Waffle flag to use new email templates for sending ID verification emails.
# .. toggle_name: verify_student.use_new_email_templates
# .. toggle_implementation: WaffleFlag
# .. toggle_default: False
# .. toggle_description: Supports staged rollout to students for a new email templates
#   implementation for ID verification.
# .. toggle_use_cases: temporary, open_edx
# .. toggle_creation_date: 2020-06-25
# .. toggle_target_removal_date: None
# .. toggle_warnings: This temporary feature toggle does not have a target removal date.
# .. toggle_tickets: PROD-1639
USE_NEW_EMAIL_TEMPLATES = WaffleFlag(
    waffle_namespace=WAFFLE_FLAG_NAMESPACE,
    flag_name='use_new_email_templates',
    module_name=__name__,
)


def use_new_templates_for_id_verification_emails():
    return USE_NEW_EMAIL_TEMPLATES.is_enabled()
Exemplo n.º 11
0
"""
This module contains various configuration settings via
waffle switches for the instructor_task app.
"""

from edx_toggles.toggles import WaffleFlagNamespace, WaffleSwitchNamespace
from openedx.core.djangoapps.waffle_utils import CourseWaffleFlag

WAFFLE_NAMESPACE = 'instructor_task'
INSTRUCTOR_TASK_WAFFLE_FLAG_NAMESPACE = WaffleFlagNamespace(
    name=WAFFLE_NAMESPACE)
WAFFLE_SWITCHES = WaffleSwitchNamespace(name=WAFFLE_NAMESPACE)

# Waffle switches
OPTIMIZE_GET_LEARNERS_FOR_COURSE = 'optimize_get_learners_for_course'

# Course override flags
GENERATE_PROBLEM_GRADE_REPORT_VERIFIED_ONLY = 'generate_problem_grade_report_verified_only'
GENERATE_COURSE_GRADE_REPORT_VERIFIED_ONLY = 'generate_course_grade_report_verified_only'


def waffle_flags():
    """
    Returns the namespaced, cached, audited Waffle flags dictionary for Grades.
    """
    return {
        GENERATE_PROBLEM_GRADE_REPORT_VERIFIED_ONLY:
        CourseWaffleFlag(
            waffle_namespace=INSTRUCTOR_TASK_WAFFLE_FLAG_NAMESPACE,
            flag_name=GENERATE_PROBLEM_GRADE_REPORT_VERIFIED_ONLY,
            module_name=__name__,
Exemplo n.º 12
0
"""
Toggles for Course API.
"""


from edx_toggles.toggles import WaffleFlag, WaffleFlagNamespace

COURSE_BLOCKS_API_NAMESPACE = WaffleFlagNamespace(name=u'course_blocks_api')

# .. toggle_name: course_blocks_api.hide_access_denials
# .. toggle_implementation: WaffleFlag
# .. toggle_default: False
# .. toggle_description: Waffle flag to hide access denial messages in the course blocks.
# .. toggle_use_cases: temporary, open_edx
# .. toggle_creation_date: 2019-09-27
# .. toggle_target_removal_date: None
# .. toggle_warnings: This temporary feature toggle does not have a target removal date.
# .. toggle_tickets: None
HIDE_ACCESS_DENIALS_FLAG = WaffleFlag(
    waffle_namespace=COURSE_BLOCKS_API_NAMESPACE,
    flag_name=u'hide_access_denials',
    module_name=__name__,
)
Exemplo n.º 13
0
"""
Waffle flags for Branding app.
"""
from edx_toggles.toggles import WaffleFlag, WaffleFlagNamespace


WAFFLE_FLAG_NAMESPACE = WaffleFlagNamespace(name='branding')
# Waffle flag for testing purpose only. When setting the flag in prod,
# make sure to have the following settings. Use "dwft_branding.enable_branding_logs=1"
# in the browser query to enable the flag.
# .. toggle_name: branding.enable_branding_logs
# .. toggle_everyone: unknown
# .. toggle_testing: True
# .. toggle_implementation: WaffleFlag
# .. toggle_default: False
# .. toggle_description: Supports testing for re-branding work.
# .. toggle_category: branding
# .. toggle_use_cases: open_edx
# .. toggle_creation_date: 2020-11-22
# .. toggle_target_removal_date: 2021-01-01
# .. toggle_warnings: n/a
# .. toggle_tickets: TNL-7695
# .. toggle_status: supported
ENABLE_BRANDING_LOGS = WaffleFlag(
    waffle_namespace=WAFFLE_FLAG_NAMESPACE,
    flag_name='enable_branding_logs',
)


def app_logs_enabled():
    """Check if app logging is enabled. """
Exemplo n.º 14
0
"""
Contains configuration for schedules app
"""

from edx_toggles.toggles import WaffleFlag, WaffleFlagNamespace, WaffleSwitch, WaffleSwitchNamespace
from openedx.core.djangoapps.waffle_utils import CourseWaffleFlag

WAFFLE_FLAG_NAMESPACE = WaffleFlagNamespace(name='schedules')
WAFFLE_SWITCH_NAMESPACE = WaffleSwitchNamespace(name='schedules')

CREATE_SCHEDULE_WAFFLE_FLAG = CourseWaffleFlag(
    waffle_namespace=WAFFLE_FLAG_NAMESPACE,
    flag_name='create_schedules_for_course',
    module_name=__name__,
)

COURSE_UPDATE_WAFFLE_FLAG = CourseWaffleFlag(
    waffle_namespace=WAFFLE_FLAG_NAMESPACE,
    flag_name='send_updates_for_course',
    module_name=__name__,
)

DEBUG_MESSAGE_WAFFLE_FLAG = WaffleFlag(WAFFLE_FLAG_NAMESPACE,
                                       'enable_debugging', __name__)

COURSE_UPDATE_SHOW_UNSUBSCRIBE_WAFFLE_SWITCH = WaffleSwitch(
    WAFFLE_SWITCH_NAMESPACE, 'course_update_show_unsubscribe', __name__)
Exemplo n.º 15
0
    'video_images_handler',
    'transcript_preferences_handler',
    'generate_video_upload_link_handler',
]

LOGGER = logging.getLogger(__name__)

# Waffle switches namespace for videos
WAFFLE_NAMESPACE = 'videos'
WAFFLE_SWITCHES = WaffleSwitchNamespace(name=WAFFLE_NAMESPACE)

# Waffle switch for enabling/disabling video image upload feature
VIDEO_IMAGE_UPLOAD_ENABLED = 'video_image_upload_enabled'

# Waffle flag namespace for studio
WAFFLE_STUDIO_FLAG_NAMESPACE = WaffleFlagNamespace(name=u'studio')

ENABLE_VIDEO_UPLOAD_PAGINATION = CourseWaffleFlag(
    waffle_namespace=WAFFLE_STUDIO_FLAG_NAMESPACE,
    flag_name=u'enable_video_upload_pagination',
    module_name=__name__,
)
# Default expiration, in seconds, of one-time URLs used for uploading videos.
KEY_EXPIRATION_IN_SECONDS = 86400

VIDEO_SUPPORTED_FILE_FORMATS = {
    '.mp4': 'video/mp4',
    '.mov': 'video/quicktime',
}

VIDEO_UPLOAD_MAX_FILE_SIZE_GB = 5
Exemplo n.º 16
0
"""
This module contains various configuration settings via
waffle switches for the course_details view.
"""

from edx_toggles.toggles import WaffleFlagNamespace, WaffleSwitchNamespace
from openedx.core.djangoapps.waffle_utils import CourseWaffleFlag

COURSE_DETAIL_WAFFLE_NAMESPACE = 'course_detail'
COURSE_DETAIL_WAFFLE_FLAG_NAMESPACE = WaffleFlagNamespace(
    name=COURSE_DETAIL_WAFFLE_NAMESPACE)
WAFFLE_SWITCHES = WaffleSwitchNamespace(name=COURSE_DETAIL_WAFFLE_NAMESPACE)

# Course Override Flag
COURSE_DETAIL_UPDATE_CERTIFICATE_DATE = u'course_detail_update_certificate_date'


def waffle_flags():
    """
    Returns the namespaced, cached, audited Waffle flags dictionary for course detail.
    """
    return {
        COURSE_DETAIL_UPDATE_CERTIFICATE_DATE:
        CourseWaffleFlag(
            waffle_namespace=COURSE_DETAIL_WAFFLE_NAMESPACE,
            flag_name=COURSE_DETAIL_UPDATE_CERTIFICATE_DATE,
            module_name=__name__,
        )
    }

Exemplo n.º 17
0
    CourseEnrollmentAttribute,
    DashboardConfiguration,
    PendingSecondaryEmailChange,
    UserProfile
)
from common.djangoapps.util.milestones_helpers import get_pre_requisite_courses_not_completed
from xmodule.modulestore.django import modulestore

#Added by Mahendra
from lms.djangoapps.add_manager.models import user_view_counter, disclaimer_agreement_status
#added by Dev
from openedx.core.djangoapps.content.course_overviews.models import CourseOverview

log = logging.getLogger("edx.student")

experiments_namespace = WaffleFlagNamespace(name=u'student.experiments')


def get_org_black_and_whitelist_for_site():
    """
    Returns the org blacklist and whitelist for the current site.

    Returns:
        (org_whitelist, org_blacklist): A tuple of lists of orgs that serve as
            either a blacklist or a whitelist of orgs for the current site. The
            whitelist takes precedence, and the blacklist is used if the
            whitelist is None.
    """
    # Default blacklist is empty.
    org_blacklist = None
    # Whitelist the orgs configured for the current site.  Each site outside
Exemplo n.º 18
0
"""
Waffle flags for instructor dashboard.
"""

from edx_toggles.toggles import WaffleFlag, WaffleFlagNamespace
from openedx.core.djangoapps.waffle_utils import CourseWaffleFlag

WAFFLE_NAMESPACE = 'instructor'
# Namespace for instructor waffle flags.
WAFFLE_FLAG_NAMESPACE = WaffleFlagNamespace(name=WAFFLE_NAMESPACE)

# Waffle flag enable new data download UI on specific course.
# .. toggle_name: instructor.enable_data_download_v2
# .. toggle_implementation: WaffleFlag
# .. toggle_default: False
# .. toggle_description: instructor
# .. toggle_use_cases: open_edx
# .. toggle_creation_date: 2020-07-8
# .. toggle_target_removal_date: None
# .. toggle_warnings: ??
# .. toggle_tickets: PROD-1309
DATA_DOWNLOAD_V2 = CourseWaffleFlag(
    waffle_namespace=WaffleFlagNamespace(name=WAFFLE_NAMESPACE,
                                         log_prefix='instructor_dashboard: '),
    flag_name='enable_data_download_v2',
)

# Waffle flag to use optimised is_small_course.
# .. toggle_name: verify_student.optimised_is_small_course
# .. toggle_implementation: WaffleFlag
# .. toggle_default: False