Skip to content

feat: add feature toggle system for disabling modules and UI#28

Merged
JacobCoffee merged 7 commits intomainfrom
feat/feature-toggles
Feb 14, 2026
Merged

feat: add feature toggle system for disabling modules and UI#28
JacobCoffee merged 7 commits intomainfrom
feat/feature-toggles

Conversation

@JacobCoffee
Copy link
Owner

@JacobCoffee JacobCoffee commented Feb 14, 2026

Summary

  • Add FeaturesConfig dataclass for module/UI toggles via DJANGO_PROGRAM["features"] settings
  • Add DB-backed FeatureFlags model (per-conference, OneToOneField) for live runtime toggling via Django admin
  • Priority: DB overrides > settings defaults. None in DB = use settings default, explicit True/False = override
  • Add features.py with is_feature_enabled(feature, conference=None), require_feature(), and FeatureRequiredMixin
  • Add context processor for template-level feature checks (registered in example app)
  • Master switch all_ui_enabled overrides both public and manage UI (from settings or DB)
  • All features enabled by default - opt-in to disable
  • 63 tests covering all toggle logic, DB overrides, backward compatibility

How to test in the UI

  1. Start the dev server:

    uv run python examples/manage.py migrate
    uv run python examples/manage.py runserver
  2. Create a superuser if needed:

    uv run python examples/manage.py createsuperuser
  3. Go to Django Admin at /admin/

  4. Navigate to Conference > Feature flags and click "Add"

  5. Select a conference and toggle features:

    • Leave fields blank (None) to use settings defaults
    • Set to True or False to override for that specific conference
    • Changes take effect immediately — no restart needed
  6. Test the master switch:

    • Set all_ui_enabled to False in the admin
    • Both public and manage UI should return 404 for that conference
  7. Test individual toggles:

    • Set registration_enabled to False
    • Registration-related views should 404 (when FeatureRequiredMixin is applied in follow-up)
  8. Settings.py still works as global defaults:

    DJANGO_PROGRAM = {
        "features": {
            "registration_enabled": False,  # global default
        },
    }

    A conference can then re-enable it via the admin by setting its DB flag to True.

Test plan

  • All features enabled by default with no config or DB rows
  • DB FeatureFlags with explicit False disables feature for that conference
  • DB FeatureFlags with None falls back to settings default
  • all_ui_enabled=False in DB disables both public_ui and manage_ui
  • Settings-level defaults work when no DB row exists
  • Context processor exposes resolved flags to templates
  • Django admin UI shows feature flags with clean fieldset layout
  • Changes in admin take effect without restart

🤖 Generated with Claude Code

Copilot AI review requested due to automatic review settings February 14, 2026 01:09
@chatgpt-codex-connector
Copy link

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

JacobCoffee and others added 2 commits February 13, 2026 19:32
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings February 14, 2026 01:37
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 6 out of 6 changed files in this pull request and generated 4 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

JacobCoffee and others added 2 commits February 13, 2026 19:42
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings February 14, 2026 02:36
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 9 out of 9 changed files in this pull request and generated 2 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

…to-creation

- FeatureRequiredMixin now supports tuple of features (all must be enabled)
- Applied mixin to all public views: pretalx (public_ui), sponsors
  (sponsors+public_ui), registration (registration+public_ui), programs
  (programs/travel_grants+public_ui)
- FeatureFlags inline on ConferenceAdmin (like Sections), standalone admin kept
- Auto-create FeatureFlags via post_save signal when Conference is created
- Admin widget labels show "Default (enabled)" instead of "Unknown"
- Narrowed blanket Exception catch to ObjectDoesNotExist in _get_db_flag

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@JacobCoffee JacobCoffee enabled auto-merge (squash) February 14, 2026 03:50
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings February 14, 2026 04:04
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 15 out of 15 changed files in this pull request and generated no new comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@JacobCoffee JacobCoffee merged commit cb83b81 into main Feb 14, 2026
16 checks passed
@JacobCoffee JacobCoffee deleted the feat/feature-toggles branch February 14, 2026 04:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant