feat: implement media asset reactivation and enhance lifecycle management
Deploy Development / deploy (push) Successful in 34s
Test Suite / pytest-backend (push) Successful in 24s
Test Suite / lint-backend (push) Successful in 0s
Test Suite / build-frontend (push) Successful in 6s
Test Suite / playwright-tests (push) Successful in 31s
Deploy Development / deploy (push) Successful in 34s
Test Suite / pytest-backend (push) Successful in 24s
Test Suite / lint-backend (push) Successful in 0s
Test Suite / build-frontend (push) Successful in 6s
Test Suite / playwright-tests (push) Successful in 31s
- Added a new action to the media asset lifecycle for reactivating assets from the trash, allowing users to restore previously deleted media. - Updated the backend API to handle reactivation requests and ensure proper state transitions for media assets. - Enhanced frontend error handling to prompt users for reactivation when attempting to upload media that matches an existing asset in the trash. - Incremented version to 0.8.45, reflecting the latest changes in media lifecycle management and user experience improvements.
This commit is contained in:
1 parent
e2964a077d
commit
da368222e0
8 files changed
+198
-44
No files matched your search
@@ -271,3 +271,44 @@ def test_delete_exercise_media_embed_row_no_orphan(client: TestClient) -> None:
|
||||
|
||||
assert r.status_code == 200
|
||||
assert r.json() == {"ok": True, "orphan_media_asset_id": None}
|
||||
|
||||
|
||||
def test_media_asset_lifecycle_reactivate_mocked(client: TestClient) -> None:
|
||||
app.dependency_overrides[require_auth] = lambda: {"profile_id": 1, "role": "trainer"}
|
||||
app.dependency_overrides[get_tenant_context] = lambda: TenantContext(
|
||||
profile_id=1,
|
||||
global_role="trainer",
|
||||
effective_club_id=None,
|
||||
club_ids=frozenset(),
|
||||
memberships=[],
|
||||
)
|
||||
|
||||
mock_cur = MagicMock()
|
||||
mock_cur.fetchone.side_effect = [
|
||||
{
|
||||
"id": 5,
|
||||
"visibility": "private",
|
||||
"club_id": None,
|
||||
"uploaded_by_profile_id": 1,
|
||||
"lifecycle_state": "trash_soft",
|
||||
"storage_key": "exercises/a.mp4",
|
||||
"storage_backend": "local",
|
||||
"trash_soft_at": None,
|
||||
"trash_hidden_at": None,
|
||||
"purge_after_at": None,
|
||||
},
|
||||
{"id": 5, "lifecycle_state": "active"},
|
||||
]
|
||||
mock_cm = _mock_db(mock_cur)
|
||||
|
||||
with patch("routers.media_assets.get_db", return_value=mock_cm), patch(
|
||||
"routers.media_assets.get_cursor", return_value=mock_cur
|
||||
):
|
||||
r = client.post(
|
||||
"/api/media-assets/5/lifecycle",
|
||||
headers={"X-Auth-Token": "t", "Content-Type": "application/json"},
|
||||
json={"action": "reactivate"},
|
||||
)
|
||||
|
||||
assert r.status_code == 200
|
||||
assert r.json()["lifecycle_state"] == "active"
|
||||
Reference in new issue
Block a user