Campus as owner of media, playlists and devices #159
Labels
No labels
Area/Backend
Area/Database
Area/Docs
Area/Frontend
Area/Infra
Area/Security
Area/Tests
Area/Tooling
Compat/Breaking
Kind/Bug
Kind/Documentation
Kind/Enhancement
Kind/Feature
Kind/Security
Kind/Testing
Lang/Python
Lang/Rust
Lang/Shell
Lang/SQL
Lang/TypeScript
Priority
Critical
Priority
High
Priority
Low
Priority
Medium
Reviewed
Confirmed
Reviewed
Duplicate
Reviewed
Invalid
Reviewed
Won't Fix
Routing
Auto
Routing
Hold
Routing
Human
Status
Abandoned
Status
Blocked
Status
Need More Info
No milestone
No project
No assignees
2 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
Grimoirix/grimoire-of-digital-signage#159
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
What
A campus (e.g. AM, HE) owns its objects: media, playlists, devices, device groups, IP rules. A user sees and changes only the campuses they are granted (one, several, or all). One server serves all campuses (
plan/operations/deployment.md, GRI-1876).Done when
Relation
Scope for #44 (permissions) and the campus settings issue. Before the one-campus production test (GRI-1960).
Product owner decision (GRI-1960, 2026-11-13):
What this means for the design:
campus_idthat is nullable:NULL= all campuses. No join table, no multi-campus.campustable, seeded or created in the panel). AM/HE/JO/NO are the first rows, not constants (GRI-1884: no hard-coding).NULL(all), so nothing disappears on upgrade.Released to @aetherforge. Next after this: #44 / #52.
Implemented the data model: a
campustable seeded with AM, HE, JO, NO (data per GRI-1884, not code), and a nullablecampus_idonmedia,playlists,devicesandip_rules(NULL= every campus, per the product owner's decision on GRI-1960). A playlist can only take media of its own campus or shared media, and the reverse holds too — a shared playlist cannot take one campus's exclusive media. A device auto-approved through a campus-scoped IP rule inherits that campus; an admin can assign one by hand viaPATCH /devices/{id}.GET /api/v1/campuseslists the seeded rows. Device groups are untouched — no such table exists yet (Phase 2, not persisted).Known gap, left for #44: caller-side scoping (listing only the campuses a user is granted, and 404-not-403 on a direct id of another campus) needs a user-campus scope that does not exist yet — Phase 4 permissions are not built (
auth/mod.rs: "being signed in is the only thingCurrentUserproves"). The product owner's own comment sequences #44 after this issue, so I built the data model #44 will need rather than silently narrowing this issue's acceptance criteria to pass.Verified locally:
cargo test --workspace --all-targets --locked,cargo clippy --workspace --all-targets --locked -- -D warnings,cargo fmt --all --check, and the branch's git-hooks gates, all green. New tests cover the campus seed list,campus_idround-trips on media/playlist/device/ip-rule, unknown-campus-id rejection, and the full playlist/media compatibility matrix (own campus, shared media, shared playlist + campus media, cross-campus media).PR: #162 (CI running — will report the verdict here).
CI on PR #162 (commit
bdaf38a8): the aggregateCI / CIgate passed — clippy, cargo deny (licenses/bans), fmt, cargo test, frontend-web, repository boundary, and the pre-push hook all green.One sub-job,
cargo deny advisories, is failing — but it's pre-existing and unrelated to this change: this PR touches noCargo.toml/Cargo.lock(verified viagit diff origin/dev...HEAD --stat), and runningcargo deny check advisorieslocally shows the same failure comes from theclientcrate's GTK/webkit transitive dependency tree, which this PR never touches. Ready for review/merge on that basis.Change request from the product owner (GRI-1969) — PR #162 is not ready to merge.
His words: "AM, HE, JO, NO … are the real campus names of the school where I work for. Let the user choose what campus names they want, without forcing them to delete campuses they do not need. That is in my eyes bloat. But you can use those for your tests."
So:
0005_campus.sql: create thecampustable empty. Remove theINSERTof AM/HE/JO/NO and the comment lines that call them the campuses. A fresh install has zero campuses. With zero campuses every object stayscampus_id = NULL(all campuses), which is correct for a single-site school.POST /api/v1/campuses{code, name}→ 201; duplicatecode→ 409.PATCH /api/v1/campuses/{id}{code?, name?}→ rename.DELETE /api/v1/campuses/{id}→ 204 when nothing references it; 409 when a media item, playlist, device or IP rule still points at it. Do notON DELETE SET NULL: that silently turns one campus's content into content for every campus.The migration comment already promised "the panel can add, rename or remove a row" — this makes it true.
POST, or an insert in the test helper). Replacethe_seeded_campuses_are_listed_by_codewith: a fresh database lists no campuses; create → list → rename → delete round-trip; duplicate code → 409; delete of a referenced campus → 409.campus.rsdoc: drop "seeded"; say campuses are created by the operator.Front end (panel page for campuses) is not in this PR; say so in the description as a follow-up.
Correction. My change request on PR #162 said the PR was not merged. That was wrong: I merged it myself at 18:25:51 UTC, four seconds before I posted the request (merge commit
33253b2). Sodevnow holds0005_campus.sqlwith the AM/HE/JO/NO seed. It is not inmain, so no release has it.The rework requested on #162 is still wanted, but now as a follow-up branch from
dev, under this issue:INSERT INTO campusfrom0005_campus.sql, and the comment line that names the four campuses. Edit 0005 in place rather than adding a 0006 that deletes rows: nothing outsidedevhas run it, and a cleanup migration would keep the school's campus names in the shipped code for ever. Any local/CI database that already ran 0005 must be recreated (sqlx checksum mismatch) — say so in the PR.POST,PATCH,DELETE /api/v1/campusesfor admins. Duplicate code → 409. Delete of a campus still referenced by media, a playlist, a device or an IP rule → 409.Done: merged into dev with #162.