GRI-2116: PATCH /api/v1/media/{media_id} campus move #253

Merged
vivy merged 7 commits from feature/GRI-2116-media-campus-move into dev 2026-11-15 23:59:17 +00:00
Member

Implements PATCH /api/v1/media/{media_id} for moving a media item (or whole document) between campuses, per forge #244.

  • Global-admin only; 403 for a campus admin moving into/out of a campus that isn't theirs.
  • A document (all pages sharing document_id) moves as one, in a single transaction.
  • Moving to all campuses (campus_id: null) is always allowed.
  • Moving to a specific campus while a playlist of another campus (or shared) uses the item: 409 media_in_use_by_other_campus, naming those playlists. Nothing changes.
  • remove_from_playlists: true removes the item from those playlists and moves it, in one transaction; devices whose playlist lost the item get the push.
  • Unknown campus: 400. Unknown media: 404.

Branched from test/GRI-2115-campus-move-media-acceptance (forge #247, not yet merged) to run the 13 acceptance tests locally; also drops #[ignore] on the device-push acceptance test now that the route exists. The chief of staff is merging #247 and this PR together.

Verified: ./scripts/local-gates.sh --rust-only (incl. ignored DB-backed acceptance tests) — every gate passed, commit fb1d1a3.

Implements `PATCH /api/v1/media/{media_id}` for moving a media item (or whole document) between campuses, per forge #244. - Global-admin only; 403 for a campus admin moving into/out of a campus that isn't theirs. - A document (all pages sharing `document_id`) moves as one, in a single transaction. - Moving to all campuses (`campus_id: null`) is always allowed. - Moving to a specific campus while a playlist of another campus (or shared) uses the item: 409 `media_in_use_by_other_campus`, naming those playlists. Nothing changes. - `remove_from_playlists: true` removes the item from those playlists and moves it, in one transaction; devices whose playlist lost the item get the push. - Unknown campus: 400. Unknown media: 404. Branched from `test/GRI-2115-campus-move-media-acceptance` (forge #247, not yet merged) to run the 13 acceptance tests locally; also drops `#[ignore]` on the device-push acceptance test now that the route exists. The chief of staff is merging #247 and this PR together. Verified: `./scripts/local-gates.sh --rust-only` (incl. ignored DB-backed acceptance tests) — every gate passed, commit `fb1d1a3`.
GRI-2115: acceptance tests for campus move for media (#242, backend #244)
Some checks failed
CI / the pre-push hook (pull_request) Successful in 8s
CI / cargo fmt (pull_request) Successful in 8s
CI / install.sh client upgrade (pull_request) Successful in 12s
CI / cargo deny (pull_request) Successful in 19s
CI / cargo deny advisories (pull_request) Successful in 15s
CI / repository boundary (pull_request) Successful in 5s
CI / cargo clippy (pull_request) Successful in 1m30s
CI / frontend-web (pull_request) Successful in 1m12s
CI / cargo test (pull_request) Failing after 3m38s
CI / CI (pull_request) Failing after 2s
CI / Notify gate failed (pull_request) Successful in 2s
557ae95ab9
It ran unignored against a real DB in CI (unlike the other 13 tests in
this PR, which carry the standard ignore), so it failed the cargo test
gate on a route that genuinely does not exist yet. The other acceptance
tests in this PR already follow GRI-1977/GRI-1992's pattern: ship
ignored, drop the ignore once the backend engineer implements the route.
Merge origin/dev into test/GRI-2115-campus-move-media-acceptance
Some checks failed
CI / the pre-push hook (pull_request) Successful in 4s
CI / install.sh client upgrade (pull_request) Successful in 10s
CI / cargo fmt (pull_request) Successful in 4s
CI / cargo deny (pull_request) Successful in 22s
CI / cargo deny advisories (pull_request) Successful in 26s
CI / cargo clippy (pull_request) Successful in 1m30s
CI / repository boundary (pull_request) Successful in 3s
CI / cargo test (pull_request) Failing after 1m29s
CI / frontend-web (pull_request) Successful in 1m1s
CI / CI (pull_request) Failing after 1s
CI / Notify gate failed (pull_request) Successful in 2s
b8c58cc319
GRI-2115: merge dev
All checks were successful
CI / the pre-push hook (pull_request) Successful in 4s
CI / install.sh client upgrade (pull_request) Successful in 13s
CI / cargo fmt (pull_request) Successful in 6s
CI / cargo deny (pull_request) Successful in 22s
CI / cargo deny advisories (pull_request) Successful in 27s
CI / cargo clippy (pull_request) Successful in 2m6s
CI / repository boundary (pull_request) Successful in 6s
CI / frontend-web (pull_request) Successful in 1m9s
CI / cargo test (pull_request) Successful in 3m38s
CI / CI (pull_request) Successful in 2s
CI / Notify gate failed (pull_request) Has been skipped
3ea0446062
GRI-2116: PATCH /api/v1/media/{id} to move a media item's campus
All checks were successful
CI / the pre-push hook (pull_request) Successful in 5s
CI / cargo fmt (pull_request) Successful in 5s
CI / install.sh client upgrade (pull_request) Successful in 8s
CI / cargo deny (pull_request) Successful in 22s
CI / cargo deny advisories (pull_request) Successful in 22s
CI / repository boundary (pull_request) Successful in 6s
CI / frontend-web (pull_request) Successful in 1m14s
CI / cargo clippy (pull_request) Successful in 1m44s
CI / cargo test (pull_request) Successful in 3m24s
CI / Notify gate failed (pull_request) Has been skipped
CI / CI (pull_request) Successful in 2s
fb1d1a3093
Global admin only; moves a whole document as one unit; refuses with
409 media_in_use_by_other_campus unless remove_from_playlists is set,
mirroring delete_media's 409 media_in_use shape (GRI-1962).

Drops the GRI-2115 ignore on the device-push acceptance test now that
the route exists.
vivy requested changes 2026-11-15 21:24:27 +00:00
Dismissed
vivy left a comment

The implementation looks right, but the tests do not run. 13 tests in media_campus_move_acceptance_integration.rs still carry #[ignore = "requires SIGNAGE_TEST_DATABASE_URL"]. CI sets SIGNAGE_TEST_DATABASE_URL and runs cargo test without --include-ignored, so these 13 are never executed, and the green CI proves nothing about this endpoint. Each test already returns early when there is no URL, like every other DB test here, so the #[ignore] lines are not needed. Please remove all 13 and let CI run them.

Also, please fix: MoveMediaRequest.campus_id is Option without a required marker, so PATCH with an empty body {} moves the media to every campus. Make the field required (e.g. a double Option or a custom deserializer) so that a missing field is 400, and only an explicit null means every campus. Add a test for {}.

This PR contains all of #247's commits, so #247 will be closed when this merges.

The implementation looks right, but the tests do not run. 13 tests in media_campus_move_acceptance_integration.rs still carry #[ignore = "requires SIGNAGE_TEST_DATABASE_URL"]. CI sets SIGNAGE_TEST_DATABASE_URL and runs cargo test without --include-ignored, so these 13 are never executed, and the green CI proves nothing about this endpoint. Each test already returns early when there is no URL, like every other DB test here, so the #[ignore] lines are not needed. Please remove all 13 and let CI run them. Also, please fix: MoveMediaRequest.campus_id is Option<Uuid> without a required marker, so PATCH with an empty body {} moves the media to every campus. Make the field required (e.g. a double Option or a custom deserializer) so that a missing field is 400, and only an explicit null means every campus. Add a test for {}. This PR contains all of #247's commits, so #247 will be closed when this merges.
GRI-2116: require campus_id on PATCH /media/{id}, run the acceptance tests
All checks were successful
CI / the pre-push hook (pull_request) Successful in 6s
CI / cargo fmt (pull_request) Successful in 6s
CI / install.sh client upgrade (pull_request) Successful in 14s
CI / cargo deny (pull_request) Successful in 25s
CI / cargo deny advisories (pull_request) Successful in 25s
CI / cargo clippy (pull_request) Successful in 2m17s
CI / repository boundary (pull_request) Successful in 8s
CI / frontend-web (pull_request) Successful in 1m34s
CI / cargo test (pull_request) Successful in 5m41s
CI / CI (pull_request) Successful in 3s
CI / Notify gate failed (pull_request) Has been skipped
1cc50b180a
Drop the #[ignore] guard from the 13 acceptance tests so CI runs them
(they already return early without SIGNAGE_TEST_DATABASE_URL set).

campus_id was Option<Uuid>, so an omitted field and an explicit null
both deserialized to None, silently defaulting PATCH {} to 'move to
every campus'. Switch to Option<Option<Uuid>> so only an explicit
null means every campus and a missing field is 400 campus_id_required,
with a test covering the omitted-field case.
vivy approved these changes 2026-11-15 22:39:35 +00:00
Dismissed
vivy left a comment

Re-reviewed 1cc50b18. Both points are fixed:

  • campus_id is now required. Option<Option<Uuid>> with the explicit-option deserializer is the right way to tell an omitted field from null, and the new test checks that {} gives 400 and does not move the media.
  • The 13 acceptance tests are no longer #[ignore]. The cargo test job sets SIGNAGE_TEST_DATABASE_URL, so CI now runs them against Postgres. CI is green.

Approved. It merges after the PRs ahead of it in the queue, and #254 merges after it.

Re-reviewed 1cc50b18. Both points are fixed: - `campus_id` is now required. `Option<Option<Uuid>>` with the explicit-option deserializer is the right way to tell an omitted field from `null`, and the new test checks that `{}` gives 400 and does not move the media. - The 13 acceptance tests are no longer `#[ignore]`. The `cargo test` job sets `SIGNAGE_TEST_DATABASE_URL`, so CI now runs them against Postgres. CI is green. Approved. It merges after the PRs ahead of it in the queue, and #254 merges after it.
Merge branch 'dev' into feature/GRI-2116-media-campus-move
All checks were successful
CI / the pre-push hook (pull_request) Successful in 4s
CI / install.sh client upgrade (pull_request) Successful in 10s
CI / cargo fmt (pull_request) Successful in 6s
CI / cargo deny (pull_request) Successful in 19s
CI / cargo clippy (pull_request) Successful in 1m22s
CI / cargo deny advisories (pull_request) Successful in 20s
CI / repository boundary (pull_request) Successful in 5s
CI / frontend-web (pull_request) Successful in 1m5s
CI / cargo test (pull_request) Successful in 2m45s
CI / Notify gate failed (pull_request) Has been skipped
CI / CI (pull_request) Successful in 2s
79edb8aea7
vivy dismissed vivy's review 2026-11-15 23:42:41 +00:00
Reason:

New commits pushed, approval review dismissed automatically according to repository settings

vivy merged commit 409540ccb4 into dev 2026-11-15 23:59:17 +00:00
vivy deleted branch feature/GRI-2116-media-campus-move 2026-11-15 23:59:18 +00:00
Sign in to join this conversation.
No reviewers
No milestone
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!253
No description provided.