'utm_content': 'registration_utm_content', } 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. REGISTRATION_FAILURE_LOGGING_FLAG = LegacyWaffleFlag( waffle_namespace=LegacyWaffleFlagNamespace(name='registration'), flag_name='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.
""" Toggles for Course API. """ from edx_toggles.toggles import LegacyWaffleFlag, LegacyWaffleFlagNamespace COURSE_BLOCKS_API_NAMESPACE = LegacyWaffleFlagNamespace(name='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. HIDE_ACCESS_DENIALS_FLAG = LegacyWaffleFlag( waffle_namespace=COURSE_BLOCKS_API_NAMESPACE, flag_name='hide_access_denials', module_name=__name__, )
""" This module contains various configuration settings via waffle switches for the instructor_task app. """ from edx_toggles.toggles import LegacyWaffleFlagNamespace, LegacyWaffleSwitchNamespace from openedx.core.djangoapps.waffle_utils import CourseWaffleFlag WAFFLE_NAMESPACE = 'instructor_task' INSTRUCTOR_TASK_WAFFLE_FLAG_NAMESPACE = LegacyWaffleFlagNamespace( name=WAFFLE_NAMESPACE) WAFFLE_SWITCHES = LegacyWaffleSwitchNamespace(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__,
from django.conf import settings from django.test.client import RequestFactory from django.utils.deprecation import MiddlewareMixin from edx_django_utils.monitoring import set_custom_attribute from opaque_keys import InvalidKeyError from opaque_keys.edx.keys import CourseKey from six.moves.urllib.parse import urlparse from edx_toggles.toggles import LegacyWaffleFlag, LegacyWaffleFlagNamespace from openedx.core.djangoapps.site_configuration import helpers as configuration_helpers # accommodates course api urls, excluding any course api routes that do not fall under v*/courses, such as v1/blocks. COURSE_REGEX = re.compile(r'^(.*?/courses/)(?!v[0-9]+/[^/]+){}'.format( settings.COURSE_ID_PATTERN)) WAFFLE_FLAG_NAMESPACE = LegacyWaffleFlagNamespace(name='request_utils') CAPTURE_COOKIE_SIZES = LegacyWaffleFlag(WAFFLE_FLAG_NAMESPACE, 'capture_cookie_sizes', __name__) log = logging.getLogger(__name__) def get_request_or_stub(): """ Return the current request or a stub request. If called outside the context of a request, construct a fake request that can be used to build an absolute URI. This is useful in cases where we need to pass in a request object but don't have an active request (for example, in tests, celery tasks, and XBlocks). """
""" Waffle flags for instructor dashboard. """ from edx_toggles.toggles import LegacyWaffleFlag, LegacyWaffleFlagNamespace from openedx.core.djangoapps.waffle_utils import CourseWaffleFlag WAFFLE_NAMESPACE = 'instructor' # Namespace for instructor waffle flags. WAFFLE_FLAG_NAMESPACE = LegacyWaffleFlagNamespace(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=LegacyWaffleFlagNamespace( name=WAFFLE_NAMESPACE, log_prefix='instructor_dashboard: '), flag_name='enable_data_download_v2', module_name=__name__, ) # Waffle flag to use optimised is_small_course. # .. toggle_name: verify_student.optimised_is_small_course # .. toggle_implementation: WaffleFlag
from lms.djangoapps.certificates.models import (CertificateInvalidation, CertificateStatuses, CertificateWhitelist, GeneratedCertificate) from lms.djangoapps.certificates.queue import XQueueCertInterface from lms.djangoapps.certificates.tasks import CERTIFICATE_DELAY_SECONDS, generate_certificate from lms.djangoapps.certificates.utils import emit_certificate_event, has_html_certificates_enabled from lms.djangoapps.instructor.access import list_with_level from lms.djangoapps.verify_student.services import IDVerificationService from openedx.core.djangoapps.certificates.api import auto_certificate_generation_enabled from openedx.core.djangoapps.waffle_utils import CourseWaffleFlag from xmodule.modulestore.django import modulestore log = logging.getLogger(__name__) WAFFLE_FLAG_NAMESPACE = LegacyWaffleFlagNamespace(name='certificates_revamp') # .. toggle_name: certificates_revamp.use_allowlist # .. toggle_implementation: CourseWaffleFlag # .. toggle_default: False # .. toggle_description: Waffle flag to enable the course certificates allowlist (aka V2 of the certificate whitelist) # on a per-course run basis. # .. toggle_use_cases: temporary # .. toggle_creation_date: 2021-01-27 # .. toggle_target_removal_date: 2022-01-27 # .. toggle_tickets: MICROBA-918 CERTIFICATES_USE_ALLOWLIST = CourseWaffleFlag( waffle_namespace=WAFFLE_FLAG_NAMESPACE, flag_name='use_allowlist', module_name=__name__, )
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 = LegacyWaffleFlagNamespace(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 = LegacyWaffleFlag( waffle_namespace=experiments_namespace, flag_name=u'add_programs', module_name=__name__, )
""" Feature toggles used for effort estimation. """ from edx_toggles.toggles import LegacyWaffleFlagNamespace from openedx.core.djangoapps.waffle_utils import CourseWaffleFlag WAFFLE_FLAG_NAMESPACE = LegacyWaffleFlagNamespace(name='effort_estimation') # .. toggle_name: effort_estimation.disabled # .. toggle_implementation: CourseWaffleFlag # .. toggle_default: False # .. toggle_description: If effort estimations are confusing for a given course (e.g. the course team has added manual # estimates), you can turn them off case by case here. # .. toggle_use_cases: opt_out # .. toggle_creation_date: 2021-07-27 EFFORT_ESTIMATION_DISABLED_FLAG = CourseWaffleFlag(WAFFLE_FLAG_NAMESPACE, 'disabled', __name__)
""" This module contains various configuration settings via waffle switches for the live app. """ from edx_toggles.toggles import LegacyWaffleFlagNamespace from openedx.core.djangoapps.waffle_utils import CourseWaffleFlag WAFFLE_NAMESPACE = LegacyWaffleFlagNamespace(name='course_live') # .. toggle_name: course_live.enable_course_live # .. toggle_implementation: CourseWaffleFlag # .. toggle_default: False # .. toggle_description: Waffle flag to enable the course live app plugin # .. toggle_use_cases: temporary, open_edx # .. toggle_creation_date: 2022-03-02 # .. toggle_target_removal_date: 2022-06-02 # .. toggle_warnings: When the flag is ON, the course live app will be visible in the course authoring mfe # .. toggle_tickets: TNL-9603 ENABLE_COURSE_LIVE = CourseWaffleFlag( waffle_namespace=WAFFLE_NAMESPACE, flag_name='enable_course_live', module_name=__name__, )
""" # lint-amnesty, pylint: disable=django-not-configured Contains configuration for schedules app """ from edx_toggles.toggles import ( LegacyWaffleFlag, LegacyWaffleFlagNamespace, LegacyWaffleSwitch, LegacyWaffleSwitchNamespace ) from openedx.core.djangoapps.waffle_utils import CourseWaffleFlag WAFFLE_FLAG_NAMESPACE = LegacyWaffleFlagNamespace(name='schedules') WAFFLE_SWITCH_NAMESPACE = LegacyWaffleSwitchNamespace(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 = LegacyWaffleFlag(WAFFLE_FLAG_NAMESPACE, 'enable_debugging', __name__)
""" Waffle flags for instructor dashboard. """ from edx_toggles.toggles import LegacyWaffleFlag, LegacyWaffleFlagNamespace from openedx.core.djangoapps.waffle_utils import CourseWaffleFlag WAFFLE_NAMESPACE = 'instructor' # Namespace for instructor waffle flags. WAFFLE_FLAG_NAMESPACE = LegacyWaffleFlagNamespace(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 = LegacyWaffleFlag( waffle_namespace=WAFFLE_FLAG_NAMESPACE, flag_name='enable_data_download_v2', module_name=__name__, ) # Waffle flag to use optimised is_small_course. # .. toggle_name: verify_student.optimised_is_small_course # .. toggle_implementation: WaffleFlag # .. toggle_default: False
def waffle_flags(): """ Returns the namespaced, cached, audited Waffle Flag class for Studio pages. """ return LegacyWaffleFlagNamespace(name=WAFFLE_NAMESPACE, log_prefix='Studio: ')
""" # lint-amnesty, pylint: disable=django-not-configured 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 LegacyWaffleFlag, LegacyWaffleFlagNamespace 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 = LegacyWaffleFlagNamespace(name='course_experience') COURSE_EXPERIENCE_WAFFLE_FLAG_NAMESPACE = LegacyWaffleFlagNamespace(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, 'display_course_sock', __name__)
""" This module contains various configuration settings via waffle switches for the course_details view. """ from edx_toggles.toggles import LegacyWaffleFlagNamespace, LegacyWaffleSwitchNamespace from openedx.core.djangoapps.waffle_utils import CourseWaffleFlag COURSE_DETAIL_WAFFLE_NAMESPACE = 'course_detail' COURSE_DETAIL_WAFFLE_FLAG_NAMESPACE = LegacyWaffleFlagNamespace(name=COURSE_DETAIL_WAFFLE_NAMESPACE) WAFFLE_SWITCHES = LegacyWaffleSwitchNamespace(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__, ) } def enable_course_detail_update_certificate_date(course_id):
""" Toggles for course home experience. """ from edx_toggles.toggles import LegacyWaffleFlagNamespace from lms.djangoapps.experiments.flags import ExperimentWaffleFlag from openedx.core.djangoapps.waffle_utils import CourseWaffleFlag WAFFLE_FLAG_NAMESPACE = LegacyWaffleFlagNamespace(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_is_active(course_key): return (COURSE_HOME_MICROFRONTEND.is_enabled(course_key) and not course_key.deprecated) def course_home_mfe_dates_tab_is_active(course_key): return (course_home_mfe_is_active(course_key) and COURSE_HOME_MICROFRONTEND_DATES_TAB.is_enabled(course_key)) def course_home_mfe_outline_tab_is_active(course_key):
from openedx.core.djangolib.markup import HTML, Text from openedx.features.enterprise_support.api import ( get_dashboard_consent_notification, get_enterprise_learner_portal_context, ) from common.djangoapps.student.api import COURSE_DASHBOARD_PLUGIN_VIEW_NAME from common.djangoapps.student.helpers import cert_info, check_verify_status_by_course, get_resume_urls_for_enrollments from common.djangoapps.student.models import ( AccountRecovery, CourseEnrollment, CourseEnrollmentAttribute, DashboardConfiguration, PendingSecondaryEmailChange, UserProfile) from common.djangoapps.util.milestones_helpers import get_pre_requisite_courses_not_completed from xmodule.modulestore.django import modulestore log = logging.getLogger("edx.student") experiments_namespace = LegacyWaffleFlagNamespace(name='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
'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 = LegacyWaffleSwitchNamespace(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 = LegacyWaffleFlagNamespace(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
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 = LegacyWaffleFlag( waffle_namespace=LegacyWaffleFlagNamespace(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:
# .. toggle_description: When enabled, a "Export to Git" menu item is added to the course studio for courses that have a # valid "giturl" attribute. Exporting a course to git causes the course to be exported in the directory indicated by # the GIT_REPO_EXPORT_DIR setting. Note that when this feature is disabled, courses can still be exported to git with # the git_export management command. # .. toggle_warnings: To enable this feature, the GIT_REPO_EXPORT_DIR setting must be properly defined and point to an # existing directory. # .. toggle_use_cases: open_edx # .. toggle_creation_date: 2014-02-13 EXPORT_GIT = SettingDictToggle("FEATURES", "ENABLE_EXPORT_GIT", default=False, module_name=__name__) # Namespace for studio dashboard waffle flags. WAFFLE_NAMESPACE = 'contentstore' WAFFLE_FLAG_NAMESPACE = LegacyWaffleFlagNamespace(name=WAFFLE_NAMESPACE, log_prefix='Contentstore: ') # .. toggle_name: split_library_on_studio_dashboard # .. toggle_implementation: WaffleFlag # .. toggle_default: False # .. toggle_description: Enables data new view for library on studio dashboard. # .. toggle_use_cases: open_edx # .. toggle_creation_date: 2020-07-8 # .. toggle_tickets: TNL-7536 SPLIT_LIBRARY_ON_DASHBOARD = LegacyWaffleFlag( waffle_namespace=LegacyWaffleFlagNamespace(name=WAFFLE_NAMESPACE), flag_name='split_library_on_studio_dashboard', module_name=__name__) # .. toggle_name: bypass_olx_failure # .. toggle_implementation: WaffleFlag
""" Toggles for Learner Profile page. """ from edx_toggles.toggles import LegacyWaffleFlag, LegacyWaffleFlagNamespace from openedx.core.djangoapps.site_configuration import helpers as configuration_helpers # Namespace for learner profile waffle flags. WAFFLE_FLAG_NAMESPACE = LegacyWaffleFlagNamespace(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 = LegacyWaffleFlag( 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())