Repository navigation
Add site settings with per-key validation and a public API (W2-04) #49 - #64
Merged
Merged
Conversation
Collaborator
|
there are merge conflicts, and also for the PR title you just need to copy the issue title @BrianRyu04 |
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.
Single values like the tagline, contact email, Instagram handle, responder form link, SMS number, and launch date need to be editable by coordinators without a deploy (TDD 4.5.3). Each key has its own Pydantic type so a typo in the editor can't break the site. This PR adds the table, the key registry, and the public read endpoint. The admin editor comes later.
Changes:
SiteSettingmodel (keyprimary key, JSONBvalue, nullableupdated_by,updated_at) and its migration, so settings can be stored and edited.services/site_settings.pywith aSETTINGSregistry. Each entry has a Pydantic type (checked withTypeAdapter), a default, apublicflag, and a description for the future editor. Adding a key later (likeretention_days) is one new entry.get_setting, which returns the stored value if it's valid and otherwise the default. Unknown keys raiseKeyError.set_setting, which validates and upserts, and raises a validation error for bad values. It flushes instead of committing, matching the other services, so callers own the transaction.GET /api/settingsreturningSiteSettingsDTO(TDD 4.7.1) with public keys only.line_launch_atis not public because the status endpoint will serve it.seed_dev()so the registration actually runs.pydantic[email]for email validation.test_site_settings.pyfor defaults, stored values winning over defaults, rejecting a bad email and a non-URL, and non-public keys never appearing inGET /api/settings.Notes for reviewers:
fe7f9cc864a9andalembic headsshows a single head. I regenerated it once after removing an empty revision from a failed first attempt.Closes #49