feat(common): add site-features API backed by AppSettings - #149
Draft
geourjoa wants to merge 4 commits into
Draft
Conversation
Adds is_feature_enabled/set_feature_enabled in apps.common.services so callers read boolean flags via a small helper instead of comparing AppSettings.value strings directly (error-prone: "True"/"1"/typos). No site-features.json or existing ad-hoc feature-flag code was found in this repo to migrate, and no boolean env var currently gates behaviour in a way that would clearly benefit from becoming a runtime-toggleable flag (SEARCH_AUTO_REINDEX is unused dead config, and the one related reindex-on-save path is explicitly documented as an unconditional invariant). Ships the read/write mechanism plus a data migration seeding two clearly-labelled illustrative example flags instead of inventing a fake product feature.
apps/common/services.py and its seed migration guessed at a feature-flag mechanism in the absence of any known JSON source, and seeded two illustrative, unwired example flags. The real source (the frontend's config/site-features.json) has since been confirmed, so this generic KV-flag layer is being replaced by a dedicated site-features endpoint rather than kept alongside it.
…ettings Adds SiteFeaturesView, an AppSettings-backed replacement for the frontend's config/site-features.json file: the whole config blob (section visibility, section order, per-search-category column/facet visibility) is stored as one AppSettings row (key="site_features"), JSON-encoded, mirroring the SiteLabel/SiteLabelsView pattern. GET /api/v1/site-features/ is public and returns the raw config object at the top level, falling back to the seeded defaults if the row is missing, inactive, or fails to parse. PUT is superuser-only and validates only the top-level shape (sections + searchCategories keys), leaving deeper validation to the frontend. The seed migration populates the row with the real content of config/site-features.json as of this writing.
Merged
4 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Stacked on #148 (feat-1) — merge/rebase after that lands.
Superseded an earlier version of this PR (commit 7b0cbd6) that shipped a generic feature-flag KV helper after only searching this repo for a JSON config to migrate. The user has since confirmed the real
site-features.jsonlives in the frontend repo (archetype3-frontend/config/site-features.json) — a structured blob (section visibility/order + per-search-category column/facet config), not flat booleans. Commits6018c42/f8cdc0bremove that placeholder and replace it with the real feature:SiteFeaturesViewinapps/common/views.py, modeled directly on the existingSiteLabelsView/SiteLabelpattern:GET /api/v1/site-features/(public),PUT /api/v1/site-features/(superuser-only viaIsSuperuserOrReadOnly), backed by oneAppSettingsrow (key="site_features") holding the whole JSON blob.config/site-features.json.lib/site-features-server.tsto this endpoint instead of local file I/O.Test plan
ruff check/ruff format/mypycleanpytest apps/common— 51 passed (30 for site-features + site-labels together)makemigrations --check --dry-run— no missing migrationsNo new dependencies.