Publish frozen exercise releases and report whether they stay offerable.
Deploy Development / deploy (push) Successful in 1m12s
Test Suite / pytest-backend (push) Failing after 30s
Test Suite / lint-backend (push) Successful in 0s
Test Suite / build-frontend (push) Successful in 16s
Test Suite / k6 /health Baseline (push) Successful in 35s
Test Suite / playwright-tests (push) Failing after 7m42s
Deploy Development / deploy (push) Successful in 1m12s
Test Suite / pytest-backend (push) Failing after 30s
Test Suite / lint-backend (push) Successful in 0s
Test Suite / build-frontend (push) Successful in 16s
Test Suite / k6 /health Baseline (push) Successful in 35s
Test Suite / playwright-tests (push) Failing after 7m42s
Recipients can ask whether a released exercise is still offerable. Archiving or removing the source stops new offers; the frozen copy stays fetchable until withdrawal. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
1 parent
b537750671
commit
fe3633ba8b
21 files changed
+3862
-12
No files matched your search
@@ -29,6 +29,7 @@ from club_tenancy import (
|
||||
club_admin_shares_club_with_creator,
|
||||
has_club_role,
|
||||
is_platform_admin,
|
||||
is_superadmin,
|
||||
library_content_visible_to_profile,
|
||||
)
|
||||
from tenant_context import TenantContext, get_tenant_context, get_tenant_context_flexible, library_content_visibility_sql
|
||||
@@ -39,6 +40,8 @@ from ai_prompt_context import ExerciseFormAiFocusRow, ExerciseFormAiPromptContex
|
||||
from ai_prompt_job import run_exercise_form_ai_suggestion
|
||||
from account_lifecycle import assert_min_account_state
|
||||
from capabilities import probe_capability
|
||||
from distribution_contract import OFFICIAL_WRITE_DENIED, official_write_allowed
|
||||
from distribution_service import blocks_exercise_delete, blocks_media_delete, blocks_variant_delete
|
||||
from club_features import (
|
||||
consume_club_feature_with_usage,
|
||||
merge_feature_usage_into_response,
|
||||
@@ -563,11 +566,13 @@ def _assert_can_edit_exercise(cur, exercise_id: int, tenant: TenantContext) -> N
|
||||
owner = rd.get("created_by")
|
||||
if owner is not None:
|
||||
owner = int(owner)
|
||||
ex_vis = (rd.get("visibility") or "private").strip().lower()
|
||||
if not official_write_allowed(ex_vis, role):
|
||||
raise HTTPException(status_code=403, detail=OFFICIAL_WRITE_DENIED)
|
||||
if owner == profile_id:
|
||||
return
|
||||
if is_platform_admin(role):
|
||||
return
|
||||
ex_vis = (rd.get("visibility") or "private").strip().lower()
|
||||
ex_cid_raw = rd.get("club_id")
|
||||
ex_cid = int(ex_cid_raw) if ex_cid_raw is not None else None
|
||||
if ex_vis == "club" and ex_cid is not None and can_plan_in_club(cur, profile_id, ex_cid, role):
|
||||
@@ -1458,9 +1463,13 @@ def _exercise_delete_usage_message(counts: dict) -> str:
|
||||
def _assert_can_delete_exercise(cur, tenant: TenantContext, row: dict) -> None:
|
||||
pid = tenant.profile_id
|
||||
role = tenant.global_role
|
||||
vis = str(row.get("visibility") or "private").strip().lower()
|
||||
if vis == "official":
|
||||
if not is_superadmin(role):
|
||||
raise HTTPException(status_code=403, detail=OFFICIAL_WRITE_DENIED)
|
||||
return
|
||||
if is_platform_admin(role):
|
||||
return
|
||||
vis = str(row.get("visibility") or "private").strip().lower()
|
||||
cid = row.get("club_id")
|
||||
creator = row.get("created_by")
|
||||
try:
|
||||
@@ -1468,11 +1477,6 @@ def _assert_can_delete_exercise(cur, tenant: TenantContext, row: dict) -> None:
|
||||
except (TypeError, ValueError):
|
||||
creator_int = None
|
||||
|
||||
if vis == "official":
|
||||
raise HTTPException(
|
||||
status_code=403,
|
||||
detail="Globale Übungen dürfen nur von Plattform-Admins gelöscht werden.",
|
||||
)
|
||||
if vis == "club":
|
||||
try:
|
||||
ex_club = int(cid) if cid is not None else None
|
||||
@@ -1598,6 +1602,9 @@ def bulk_patch_exercises_metadata(
|
||||
owner = int(owner)
|
||||
|
||||
ex_vis = (rowd.get("visibility") or "private").strip().lower()
|
||||
if not official_write_allowed(ex_vis, role):
|
||||
failed.append({"id": ex_id, "detail": OFFICIAL_WRITE_DENIED})
|
||||
continue
|
||||
ex_cid_raw = rowd.get("club_id")
|
||||
ex_cid = int(ex_cid_raw) if ex_cid_raw is not None else None
|
||||
|
||||
@@ -2833,6 +2840,11 @@ def delete_exercise(
|
||||
usage_msg = _exercise_delete_usage_message(counts)
|
||||
if usage_msg:
|
||||
raise HTTPException(status_code=409, detail=usage_msg)
|
||||
if blocks_exercise_delete(cur, exercise_id):
|
||||
raise HTTPException(
|
||||
status_code=409,
|
||||
detail="Die Übung hat eine externe Freigabe und kann nicht gelöscht werden.",
|
||||
)
|
||||
|
||||
cur.execute("DELETE FROM exercises WHERE id = %s", (exercise_id,))
|
||||
conn.commit()
|
||||
@@ -3040,6 +3052,11 @@ def delete_exercise_variant(
|
||||
cur = get_cursor(conn)
|
||||
_assert_can_edit_exercise(cur, exercise_id, tenant)
|
||||
assert_exercise_not_combination(cur, exercise_id)
|
||||
if blocks_variant_delete(cur, variant_id):
|
||||
raise HTTPException(
|
||||
status_code=409,
|
||||
detail="Die Variante ist Teil einer externen Freigabe und kann nicht gelöscht werden.",
|
||||
)
|
||||
_fetch_variant_row(cur, exercise_id, variant_id)
|
||||
|
||||
cur.execute(
|
||||
@@ -3840,6 +3857,11 @@ def delete_exercise_media(
|
||||
row = cur.fetchone()
|
||||
if not row:
|
||||
raise HTTPException(status_code=404, detail="Medium nicht gefunden")
|
||||
if blocks_media_delete(cur, media_id):
|
||||
raise HTTPException(
|
||||
status_code=409,
|
||||
detail="Das Medium ist Teil einer externen Freigabe und kann nicht gelöst werden.",
|
||||
)
|
||||
rec = r2d(row)
|
||||
media_asset_id = rec.get("media_asset_id")
|
||||
if media_asset_id:
|
||||
|
||||
Reference in new issue
Block a user