printedparts stage 13: pick alert recipients from shopdb users
Some checks failed
CI / backend (push) Successful in 1m42s
CI / naming (push) Successful in 2s
CI / frontend (push) Successful in 8s
CI / migrations-mysql (push) Failing after 8s

Contract 0.13.0 puts the User model on the plugin surface. The
settings page gains a checkbox picker over the user list; selected
users receive low-stock alerts at their account email, merged and
deduped with the free-text address list, inactive accounts skipped,
site alert_recipients still the fallback when both are empty.
This commit is contained in:
cproudlock
2026-07-17 08:30:04 -04:00
parent 427eb0de8c
commit a8a6baf979
10 changed files with 136 additions and 11 deletions

View File

@@ -9,7 +9,7 @@ The contract is locked in [ADR-001](../docs/adr/ADR-001-asset-as-platform-contra
The framework declares its contract version in `shopdb/__init__.py`:
```python
__contract_version__ = '0.12.0'
__contract_version__ = '0.13.0'
```
Each plugin's `manifest.json` declares the range of contract versions it supports:
@@ -479,6 +479,8 @@ What `shopdb.api` exposes:
- Import mode: `apply_import_timestamps`, `import_mode_active`,
`parse_import_datetime`
- Legacy employee directory: `employee_connection`
- `User` (0.13.0) - the account model, e.g. resolving alert recipients'
emails from selected user ids
- Mailer (0.12.0): `send_email(to, subject, html, text=None)` and
`send_alert(subject, html, text=None)` - settings-first, no-op safe when
email is unconfigured; send_alert targets the site's alert_recipients

View File

@@ -320,6 +320,21 @@ it. The page is ordinary:
3. `get_settings_cards` on the plugin pointing at `/settings/printedparts` -
the card appears in the rail's catalog while the plugin is enabled.
## Stage 13 (extension) - alert recipients picked from shopdb users
Free-text emails rot; user accounts do not. Another contract addition:
`User` joins the surface (0.13.0 - export, PLUGIN-HOOKS, version bump, the
docs-drift guard again).
1. Setting `printedparts_alert_userids` (comma-separated user ids), seeded
beside the others.
2. `_alert_recipients()`: resolve each selected id to an ACTIVE user's
account email, merge with the free-text list, dedupe order-preserving;
empty result still falls back to the site alert_recipients.
3. Settings page: checkbox picker over `usersApi.list()` (the page is
admin-only, matching the endpoint), saving joined ids.
4. Test: active user's email + free-text merge deduped, inactive user
skipped (`test_alert_recipients_merge_users_and_freetext`).
---
## Where each pattern lives (cheat sheet)

View File

@@ -1,6 +1,6 @@
# Roadmap
shopdb-flask is at `__contract_version__ = '0.12.0'` (pre-1.0; product `__version__ 0.7.0`, tags through v0.7.0). This document captures what stands between today and a stable `1.0.0` release. Maintained as scope evolves; supersedes nothing in the ADRs.
shopdb-flask is at `__contract_version__ = '0.13.0'` (pre-1.0; product `__version__ 0.7.0`, tags through v0.7.0). This document captures what stands between today and a stable `1.0.0` release. Maintained as scope evolves; supersedes nothing in the ADRs.
## Phase status