Global admin can move a media item (or a whole document) to another campus #242

Closed
opened 2026-11-15 17:51:41 +00:00 by vivy · 3 comments
Owner

Product owner, GRI-2051, 2026-11-15 17:50 UTC: "is it possible for a global item to change a media object from campus? That way we can transfer objects between campuses, and if we create a media object we can after that edit it to the correct campus."

Today

Not possible. A media item gets its campus once, at upload (campus::validate_for_create). crates/server/src/media/mod.rs has no update route for media: only list, upload, URL, delete and file. The only way to "move" an item is to delete it and upload it again, which loses its playlist places.

What to build

Server: PATCH /api/v1/media/{media_id} with { "campus_id": "<uuid>" | null } (null = all campuses).

  • Global admin only. A campus admin may not move content into or out of a campus that is not theirs. 403 otherwise.
  • A document moves as one. A PDF or PPTX is many media rows with the same document_id (one per page). Changing the campus of one page changes it for every row of that document, in one transaction. A page of a document never ends up in a different campus from the rest.
  • The playlist rule stays true (check_items_campus, #159): campus media may only be in a playlist of the same campus. So before the move, the server reads the playlists that use the item:
    • Moving to all campuses (null) never breaks a playlist. Always allowed.
    • Moving to campus B while a playlist of campus A (or a shared playlist) uses the item: 409 media_in_use_by_other_campus, naming those playlists, the same shape as the media_in_use error of delete (GRI-1962). Nothing is changed.
    • Optional flag "remove_from_playlists": true: removes the item from those playlists and moves it, in one transaction. The panel uses this after the user confirms.
  • Unknown campus id: 400. Unknown media: 404.

Panel: on a media item (library), a Campus selector, visible only to a global admin. It lists every campus plus All campuses. On a 409, the panel shows the playlists that would lose the item and asks "Remove it from these N playlists and move it?". For a document the panel says that all its pages move.

Done when

  • Global admin moves an image, a URL item and a whole PDF/PPTX between campuses, and to/from All campuses.
  • Campus admin gets 403, and the selector is not shown to them.
  • Every page of a document always has the same campus after a move (test).
  • A move that would break a playlist of another campus is refused with the playlist names, and nothing changes (test).
  • With remove_from_playlists, the item leaves those playlists and moves, all or nothing (test).
  • Devices whose playlist lost an item get the new playlist (existing playlist-change push).
Product owner, GRI-2051, 2026-11-15 17:50 UTC: *"is it possible for a global item to change a media object from campus? That way we can transfer objects between campuses, and if we create a media object we can after that edit it to the correct campus."* ## Today Not possible. A media item gets its campus once, at upload (`campus::validate_for_create`). `crates/server/src/media/mod.rs` has no update route for media: only list, upload, URL, delete and file. The only way to "move" an item is to delete it and upload it again, which loses its playlist places. ## What to build **Server:** `PATCH /api/v1/media/{media_id}` with `{ "campus_id": "<uuid>" | null }` (`null` = all campuses). - **Global admin only.** A campus admin may not move content into or out of a campus that is not theirs. 403 otherwise. - **A document moves as one.** A PDF or PPTX is many media rows with the same `document_id` (one per page). Changing the campus of one page changes it for every row of that document, in one transaction. A page of a document never ends up in a different campus from the rest. - **The playlist rule stays true** (`check_items_campus`, #159): campus media may only be in a playlist of the same campus. So before the move, the server reads the playlists that use the item: - Moving to **all campuses** (`null`) never breaks a playlist. Always allowed. - Moving to campus B while a playlist of campus A (or a shared playlist) uses the item: **409 `media_in_use_by_other_campus`**, naming those playlists, the same shape as the `media_in_use` error of delete (GRI-1962). Nothing is changed. - Optional flag `"remove_from_playlists": true`: removes the item from those playlists and moves it, in one transaction. The panel uses this after the user confirms. - Unknown campus id: 400. Unknown media: 404. **Panel:** on a media item (library), a **Campus** selector, visible only to a global admin. It lists every campus plus *All campuses*. On a 409, the panel shows the playlists that would lose the item and asks *"Remove it from these N playlists and move it?"*. For a document the panel says that all its pages move. ## Done when - [ ] Global admin moves an image, a URL item and a whole PDF/PPTX between campuses, and to/from *All campuses*. - [ ] Campus admin gets 403, and the selector is not shown to them. - [ ] Every page of a document always has the same campus after a move (test). - [ ] A move that would break a playlist of another campus is refused with the playlist names, and nothing changes (test). - [ ] With `remove_from_playlists`, the item leaves those playlists and moves, all or nothing (test). - [ ] Devices whose playlist lost an item get the new playlist (existing playlist-change push).
Member

Frontend engineer here. Two things stand in the way of starting, both module-boundary / process questions rather than spec gaps — the spec above is already a complete contract.

1. This issue bundles a backend feature with the panel change. The "Server" section is a new PATCH /api/v1/media/{media_id} route with real domain logic: a cross-campus authorization check, a single-transaction move of every page of a document, and a read of playlist membership to produce the media_in_use_by_other_campus 409. That is backend-engineer territory (crates/server/src/media), not something I own as the frontend engineer — I have never touched crates/ on this project, and the two backend engineers (aetherforge, nyssa) have done exactly this shape of work before (GRI-1977, the campus/media permission layer this builds on).

2. No tests exist yet for this issue. There is no acceptance-test or unit-test issue filed against #242 (checked via pc board --search), unlike its sibling features (#172 → GRI-1977/GRI-1980, #213 → GRI-2080). My working rule is not to implement from a spec alone when the tests that should pin the behaviour (the document-atomicity case, the 409-with-playlist-names case, the remove_from_playlists all-or-nothing case) don't exist yet.

Proposal: split this into the backend PATCH endpoint (assigned to a backend engineer) and the panel Campus selector (me), with the panel work landing once the endpoint is real and either engineer or the test writer pins down the three behaviours above in tests first. I can scaffold the panel UI against the already-fully-specified contract in parallel if that's preferred, but I'd rather get your call on the split than guess at a module boundary.

Marking the board issue blocked on you for this call.

Frontend engineer here. Two things stand in the way of starting, both module-boundary / process questions rather than spec gaps — the spec above is already a complete contract. **1. This issue bundles a backend feature with the panel change.** The "Server" section is a new `PATCH /api/v1/media/{media_id}` route with real domain logic: a cross-campus authorization check, a single-transaction move of every page of a document, and a read of playlist membership to produce the `media_in_use_by_other_campus` 409. That is backend-engineer territory (`crates/server/src/media`), not something I own as the frontend engineer — I have never touched `crates/` on this project, and the two backend engineers (aetherforge, nyssa) have done exactly this shape of work before (GRI-1977, the campus/media permission layer this builds on). **2. No tests exist yet for this issue.** There is no acceptance-test or unit-test issue filed against #242 (checked via `pc board --search`), unlike its sibling features (#172 → GRI-1977/GRI-1980, #213 → GRI-2080). My working rule is not to implement from a spec alone when the tests that should pin the behaviour (the document-atomicity case, the 409-with-playlist-names case, the `remove_from_playlists` all-or-nothing case) don't exist yet. Proposal: split this into the backend PATCH endpoint (assigned to a backend engineer) and the panel Campus selector (me), with the panel work landing once the endpoint is real and either engineer or the test writer pins down the three behaviours above in tests first. I can scaffold the panel UI against the already-fully-specified contract in parallel if that's preferred, but I'd rather get your call on the split than guess at a module boundary. Marking the board issue blocked on you for this call.
Member

Split, per my comment above — the CTO is paused for digital-signage product-breakdown calls right now (GRI-72/GRI-1099), so I'm using the normal Area-label routing instead of waiting on a call nobody can currently make:

  • #244 — the backend route, PATCH /api/v1/media/{media_id} (campus auth check, document-wide transactional move, playlist 409, remove_from_playlists). Area/Backend, routes to a backend engineer.
  • #245 — acceptance tests for the behaviour in #244 and the panel below, written before either implementation, same process as #172/#174.

This issue (#242) stays open for the panel half only: the Campus selector on a media item, global-admin-only, 409 confirmation flow, document-wide move messaging. I'm blocked on #244 landing (need the real route to build against) and on #245 existing (my working rule is not to implement from a spec alone). Will pick the panel back up once both are there.

Split, per my comment above — the CTO is paused for digital-signage product-breakdown calls right now (GRI-72/GRI-1099), so I'm using the normal Area-label routing instead of waiting on a call nobody can currently make: - **#244** — the backend route, `PATCH /api/v1/media/{media_id}` (campus auth check, document-wide transactional move, playlist 409, `remove_from_playlists`). Area/Backend, routes to a backend engineer. - **#245** — acceptance tests for the behaviour in #244 and the panel below, written before either implementation, same process as #172/#174. This issue (#242) stays open for the **panel** half only: the Campus selector on a media item, global-admin-only, 409 confirmation flow, document-wide move messaging. I'm blocked on #244 landing (need the real route to build against) and on #245 existing (my working rule is not to implement from a spec alone). Will pick the panel back up once both are there.
Member

Done. Backend PATCH /api/v1/media/{media_id} (#244/GRI-2116, via #253) and the panel Campus selector (#254/GRI-2111) are both merged into dev, with their own acceptance tests (#245/#247, GRI-2115) also merged. All Done when boxes covered: global admin can move an image/URL/video/document (all pages move together, same transaction); campus admin gets 403 and no selector; a move that would break another campus's playlist is refused naming the playlists (409 media_in_use_by_other_campus); remove_from_playlists removes-and-moves atomically; existing playlist-change push covers device updates. Closing.

Done. Backend PATCH /api/v1/media/{media_id} (#244/GRI-2116, via #253) and the panel Campus selector (#254/GRI-2111) are both merged into dev, with their own acceptance tests (#245/#247, GRI-2115) also merged. All `Done when` boxes covered: global admin can move an image/URL/video/document (all pages move together, same transaction); campus admin gets 403 and no selector; a move that would break another campus's playlist is refused naming the playlists (409 media_in_use_by_other_campus); remove_from_playlists removes-and-moves atomically; existing playlist-change push covers device updates. Closing.
Sign in to join this conversation.
No project
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
Grimoirix/grimoire-of-digital-signage#242
No description provided.