django_program.features¶
Feature toggle utilities for django-program.
Provides functions to check whether specific features are enabled in the current configuration, and a mixin for views that require specific features.
Features can be configured at two levels:
Settings defaults –
DJANGO_PROGRAM["features"]in Django settings. These require a server restart to change.Per-conference DB overrides – The
FeatureFlagsmodel stores nullable booleans. When a value is notNoneit takes precedence over the settings default.
Functions
|
Check if a feature is enabled, with optional per-conference DB override. |
|
Raise |
Classes
View mixin that returns 404 when a required feature is disabled. |
- django_program.features.is_feature_enabled(feature, conference=None)[source]¶
Check if a feature is enabled, with optional per-conference DB override.
Resolution order:
If a conference is provided and has a
FeatureFlagsrow with an explicit value for the feature, that value wins.Otherwise the default from
DJANGO_PROGRAM["features"]is used.The
all_ui_enabledmaster switch is checked first for UI features (public_ui,manage_ui).
- Parameters:
- Return type:
- Returns:
Trueif the feature is enabled,Falseotherwise.- Raises:
ValueError – If the feature name is not recognized.
- django_program.features.require_feature(feature, conference=None)[source]¶
Raise
Http404if a feature is disabled.
- class django_program.features.FeatureRequiredMixin[source]¶
Bases:
objectView mixin that returns 404 when a required feature is disabled.
Set
required_featureon the view class to the feature name or a tuple of feature names (all must be enabled). When used alongsideConferenceMixin(placed before this mixin in the MRO), the already-resolvedself.conferenceis picked up automatically for per-conference DB overrides.Example:
class TicketListView(ConferenceMixin, FeatureRequiredMixin, ListView): required_feature = ("registration", "public_ui")