Skip to content

SQ-821: Announcements to users via CLI and webpage#65

Merged
RMCrean merged 14 commits into
mainfrom
frontend-cli-annoucements
Feb 11, 2026
Merged

SQ-821: Announcements to users via CLI and webpage#65
RMCrean merged 14 commits into
mainfrom
frontend-cli-annoucements

Conversation

@RMCrean

@RMCrean RMCrean commented Feb 10, 2026

Copy link
Copy Markdown
Member

This PR gives us admins the ability to make announcements to users via both the command line and frontend.

Summary:

  • We have a new db model (models/announcements.py).
  • We can create/update/remove announcements using the admin panel.
  • We have 1 crud function to get active announcements for display on the home page of the website and for users when they login.
  • The new db model can specify if the announcement should only be shown on the website or cli or both and whether it should automatically "expire" after a given time period. After this expiry time the entry is not deleted from the db, the crud get operation just ignores the entry.

Other things:

  1. New migration to be run on dev cluster when this branch is deployed
  2. Health check endpoint has changed for fastapi, updated in docker compose, but needs to be updated in k8s manifests when deployed.
  3. I fixed the admin panel problem of enums being treated as strings.
  4. We talked about a soft-delete option but I suppose the automatic expire functionality covers this (we can keep older entries if we need and just have them set to be expired in order to effectively soft delete them).

To test it out

  • Go the admin panel and create a new announcement db entry
  • Go to the home page of the website or login with the cli to see the announcement.
  • Optionally add another to see multiple announcement.
Screenshot from 2026-02-10 09-46-02

@RMCrean RMCrean changed the base branch from main to use-typer-recommended-cli-config-loc February 10, 2026 08:51
@RMCrean RMCrean requested a review from Copilot February 10, 2026 08:54

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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 AnnouncementDB model + Alembic migration, plus admin panel view support for creating/editing announcements.
  • Adds “core” API routes for /health and 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.

Comment thread packages/divbase-cli/src/divbase_cli/user_auth.py
Comment thread packages/divbase-cli/src/divbase_cli/services/announcements.py Outdated
Comment thread packages/divbase-api/src/divbase_api/routes/core.py Outdated
Comment thread packages/divbase-cli/src/divbase_cli/user_auth.py
Comment thread packages/divbase-cli/src/divbase_cli/services/announcements.py
Comment thread packages/divbase-api/src/divbase_api/templates/components/announcements.html Outdated
Comment thread packages/divbase-cli/src/divbase_cli/services/announcements.py Outdated
Comment thread packages/divbase-cli/src/divbase_cli/cli_commands/auth_cli.py Outdated
Base automatically changed from use-typer-recommended-cli-config-loc to main February 10, 2026 14:21
@RMCrean RMCrean marked this pull request as ready for review February 11, 2026 07:22
@RMCrean RMCrean requested a review from a team as a code owner February 11, 2026 07:22
@RMCrean

RMCrean commented Feb 11, 2026

Copy link
Copy Markdown
Member Author

@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 brinkdp left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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!

Comment thread packages/divbase-api/src/divbase_api/routes/core.py
Comment thread packages/divbase-cli/src/divbase_cli/cli_commands/auth_cli.py
Comment thread packages/divbase-api/src/divbase_api/models/announcements.py
Comment thread packages/divbase-api/src/divbase_api/crud/announcements.py
@RMCrean

RMCrean commented Feb 11, 2026

Copy link
Copy Markdown
Member Author

Glad to see trying it out went nicely!

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?

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 :)

@RMCrean RMCrean merged commit 6f0ba7b into main Feb 11, 2026
@RMCrean RMCrean deleted the frontend-cli-annoucements branch February 11, 2026 16:10
@brinkdp

brinkdp commented Feb 11, 2026

Copy link
Copy Markdown
Contributor

we'd have to be careful to put the announcement into standard error to avoid interfering with standard out for programmatic usage.

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!

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.

3 participants