openedx.core.djangoapps.config_model_utils package#
Submodules#
openedx.core.djangoapps.config_model_utils.apps module#
Django AppConfig for ConfigurationModel utilities
openedx.core.djangoapps.config_model_utils.models module#
Useful ConfigurationModel subclasses
StackedConfigurationModel: A ConfigurationModel that can be overridden at site, org and course levels
- class openedx.core.djangoapps.config_model_utils.models.Provenance(*values)#
Bases:
EnumProvenance enum
- default = 'Default'#
- global_ = 'Global'#
- org = 'Org'#
- org_course = 'Org/Course'#
- run = 'Course Run'#
- site = 'Site'#
- class openedx.core.djangoapps.config_model_utils.models.StackedConfigurationModel(*args, **kwargs)#
Bases:
ConfigurationModelA ConfigurationModel that stacks Global, Site, Org, Course, and Course Run level configuration values.
- KEY_FIELDS = ('site', 'org', 'org_course', 'course')#
- class Meta#
Bases:
object- abstract = False#
- indexes = [<Index: fields=['site', 'org', 'course']>, <Index: fields=['site', 'org', 'org_course', 'course']>]#
- STACKABLE_FIELDS = ('enabled',)#
- classmethod all_current_course_configs()#
Return configuration for all courses
- classmethod cache_key_name(site, org, org_course, course_key)#
Return the name of the key to use to cache the current configuration
- change_date#
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- changed_by#
Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.
In the example:
class Child(Model): parent = ForeignKey(Parent, related_name='children')
Child.parentis aForwardManyToOneDescriptorinstance.
- changed_by_id#
- clean()#
Hook for doing any extra model-wide validation after clean() has been called on every field by self.clean_fields. Any ValidationError raised by this method will not be associated with a particular field; it will have a special-case association with the field defined by NON_FIELD_ERRORS.
- course#
Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.
In the example:
class Child(Model): parent = ForeignKey(Parent, related_name='children')
Child.parentis aForwardManyToOneDescriptorinstance.
- course_id#
- classmethod current(site=None, org=None, org_course=None, course_key=None)#
Return the current overridden configuration at the specified level.
Only one level may be specified at a time. Specifying multiple levels will result in a ValueError.
For example, considering the following set of requirements:
Global: Feature Disabled edx.org (Site): Feature Enabled HarvardX (org): Feature Disabled HarvardX/CS50 (org_course): Feature Enabled CS50 in 2018_Q1 (course run): Feature Disabled
Assuming these values had been properly configured, these calls would result
MyStackedConfig.current() # False MyStackedConfig.current(site=Site(domain=’edx.org’)) # True MyStackedConfig.current(site=Site(domain=’whitelabel.edx.org’)) # False – value derived from global setting MyStackedConfig.current(org=’HarvardX’) # False MyStackedConfig.current(org=’MITx’) # True – value derived from edx.org site MyStackedConfig.current(org_course=’HarvardX/CS50’) # True MyStackedConfig.current(org_course=’HarvardX/Bio101’) # False – value derived from HarvardX setting MyStackedConfig.current(course_key=CourseKey(org=’HarvardX’, course=’CS50’, run=’2018_Q1’)) # False MyStackedConfig.current(
course_key=CourseKey(org=’HarvardX’, course=’CS50’, run=’2019_Q1’)
) # True – value derived from HarvardX/CS50 setting
bio101 = CourseKey(org=’HarvardX’, course=’Bio101’, run=’2018_Q1’) MyStackedConfig.current(course_key=cs50) # False – value derived from HarvardX org
The following calls would result in errors due to overspecification:
MyStackedConfig.current(site=Site(domain=’edx.org’), org=’HarvardX’) MyStackedConfig.current(site=Site(domain=’edx.org’), course=cs50) MyStackedConfig.current(org=’HarvardX’, course=cs50)
- Parameters:
site – The Site to check current values for
org – The org to check current values for
org_course – The course in a specific org to check current values for
course_key – The course to check current values for
- Returns:
An instance of
cls.attribute_tuple()with the overridden values specified down to the level of the supplied argument (or global values if no arguments are supplied).
- enabled#
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- get_next_by_change_date(*, field=<django.db.models.fields.DateTimeField: change_date>, is_next=True, **kwargs)#
- get_previous_by_change_date(*, field=<django.db.models.fields.DateTimeField: change_date>, is_next=False, **kwargs)#
- org#
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- org_course#
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- site#
Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.
In the example:
class Child(Model): parent = ForeignKey(Parent, related_name='children')
Child.parentis aForwardManyToOneDescriptorinstance.
- site_id#
- openedx.core.djangoapps.config_model_utils.models.validate_course_in_org(value)#
openedx.core.djangoapps.config_model_utils.utils module#
utils for feature-based enrollments
- openedx.core.djangoapps.config_model_utils.utils.is_in_holdback(enrollment)#
Return true if given user is in holdback expermiment