SQ-821: Announcements to users via CLI and webpage#65
Conversation
There was a problem hiding this comment.
Pull request overview
Adds a first-class “announcements” feature spanning DB/model + admin UI authoring, API retrieval, and user-facing display via both the CLI (post-login) and the website home page. Also standardizes the FastAPI health check under the versioned core router.
Changes:
- Introduces an
AnnouncementDBmodel + Alembic migration, plus admin panel view support for creating/editing announcements. - Adds “core” API routes for
/healthand unauthenticated/announcements, with a CRUD helper for fetching active (non-expired) announcements by target. - Displays announcements on the website home page and in the CLI after successful login.
Reviewed changes
Copilot reviewed 16 out of 16 changed files in this pull request and generated 10 comments.
Show a summary per file
| File | Description |
|---|---|
| packages/divbase-lib/src/divbase_lib/api_schemas/announcements.py | Adds Pydantic response schema for announcements shared across API/CLI. |
| packages/divbase-cli/src/divbase_cli/user_auth.py | Improves request error handling and adds an unauthenticated request helper for public endpoints. |
| packages/divbase-cli/src/divbase_cli/services/announcements.py | New CLI service to fetch announcements and print them using Rich styling. |
| packages/divbase-cli/src/divbase_cli/cli_commands/auth_cli.py | Fetches/displays announcements after login (without failing login on announcement errors). |
| packages/divbase-api/src/divbase_api/templates/index.html | Renders announcements on the home page when present. |
| packages/divbase-api/src/divbase_api/templates/components/announcements.html | Adds a Bootstrap alert component for rendering announcements. |
| packages/divbase-api/src/divbase_api/routes/core.py | New unauthenticated “core” router exposing health + CLI announcements. |
| packages/divbase-api/src/divbase_api/models/announcements.py | New SQLAlchemy model and enums for announcement targeting/leveling + expiry timestamp. |
| packages/divbase-api/src/divbase_api/models/init.py | Exposes announcement model/types from the models package. |
| packages/divbase-api/src/divbase_api/migrations/versions/2026-02-09_add_annoucements_db.py | Adds the announcement table and related enums via Alembic migration. |
| packages/divbase-api/src/divbase_api/frontend_routes/core.py | Fetches active WEB announcements and passes them into template context for /. |
| packages/divbase-api/src/divbase_api/divbase_api.py | Registers the new core router and removes the old /api/health endpoint. |
| packages/divbase-api/src/divbase_api/crud/announcements.py | Adds CRUD helper to return active (non-expired) announcements filtered by target. |
| packages/divbase-api/src/divbase_api/admin_panel.py | Adds Announcement admin view and switches several string-backed enums to EnumField. |
| docs/development/database-migrations.md | Adds guidance to run migration tests. |
| docker/divbase_compose.yaml | Updates FastAPI healthcheck path to the new versioned endpoint. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
plus handle potential edge cases of no e.g. no message, or new color type gracefully
|
@brinkdp, this is now ready for review. I think once approved/we're happy with the I will deploy to the dev cluster, don't want to do it before then in case we want to make changes to the db models and would then need to make another migration etc... |
brinkdp
left a comment
There was a problem hiding this comment.
Thanks! It feels both simple and powerful to add an announcement this way. Nice implementation! The front end announcements work well. I did not wait or manipulate the timestamp for the time expiry, but deleting the entry manually at least removed my test announcement so it looks solid.
For the CLI, I did at first not realise that the announcements only show upon login. Since users can stay logged in for a week with the refresh token, there is a risk that they might miss CLI announcements. Maybe it could be good to think about additional triggers to the display the announcements in the CLI for logged-in users other than just the login command?
Maybe high level alerts should show up for every divbase-cli command? Or maybe there could be a separate CLI command to check if there are any announcements? What do you think?
Other than that I think this looks good. I think the model looks complete and the migration was applied without issues on my computer. This should be ready for a dev deployment!
|
Glad to see trying it out went nicely!
I see your point, but I think output from every command would be too much/annoying and we'd have to be careful to put the announcement into standard error to avoid interfering with standard out for programmatic usage. The announcements cli subcommand sounds good although I'm not sure how much it would be used. I've added it to a Jira task where I'll be doing other cli updates. Will update the dev instance tomorrow :) |
That is a very good point! Agree, an announcements subcommand might not be the most used, but it at least gives the user an option to check for announcements without having to login again. Great, hope that the deployment and migration will go smoothly! |
This PR gives us admins the ability to make announcements to users via both the command line and frontend.
Summary:
Other things:
To test it out