feat: implement official exercise media management and copyright validation
Deploy Development / deploy (push) Successful in 35s
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 22s
Deploy Development / deploy (push) Successful in 35s
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 22s
- Enhanced exercise update functionality to support the promotion of attached media assets to 'official' status, requiring active visibility and copyright validation. - Updated backend API to handle new fields for promoting media and setting default copyright notices during exercise updates. - Improved frontend error handling to prompt users for confirmation when promoting media assets, including checks for copyright compliance. - Incremented version to 0.8.47, reflecting the latest changes in media management and governance.
This commit is contained in:
1 parent
88fb60e244
commit
95f5b0b2d7
7 files changed
+391
-10
No files matched your search
@@ -632,7 +632,54 @@ function ExerciseFormPage() {
|
||||
setSaving(true)
|
||||
try {
|
||||
if (isEdit) {
|
||||
await api.updateExercise(exerciseId, payload)
|
||||
const saveOnce = (extras = {}) =>
|
||||
api.updateExercise(exerciseId, buildExerciseApiPayload(payloadBase, extras))
|
||||
try {
|
||||
await saveOnce()
|
||||
} catch (firstErr) {
|
||||
if (
|
||||
firstErr.status === 422 &&
|
||||
firstErr.code === 'OFFICIAL_MEDIA_LIFECYCLE' &&
|
||||
firstErr.payload?.media_assets
|
||||
) {
|
||||
alert(
|
||||
'Speichern nicht möglich: mindestens ein verknüpftes Medium ist nicht aktiv (Papierkorb). ' +
|
||||
'Bitte Medium wiederherstellen oder aus der Übung entfernen.',
|
||||
)
|
||||
throw firstErr
|
||||
}
|
||||
if (firstErr.status === 422 && firstErr.code === 'OFFICIAL_MEDIA_CONFIRM_REQUIRED') {
|
||||
const promo = (firstErr.payload.assets_need_visibility_promotion || []).length
|
||||
const miss = (firstErr.payload.assets_missing_copyright || []).length
|
||||
let msg =
|
||||
'Die Übung ist oder wird offiziell. '
|
||||
if (promo > 0) {
|
||||
msg += `${promo} verknüpfte Datei(en) werden dabei plattformweit („offiziell“) freigegeben. `
|
||||
}
|
||||
if (miss > 0) {
|
||||
msg += `${miss} Datei(en) haben noch keinen ausreichenden Copyright-Vermerk (mind. 3 Zeichen). `
|
||||
}
|
||||
msg += 'Fortfahren?'
|
||||
if (!window.confirm(msg)) throw firstErr
|
||||
let defaultCopyright = ''
|
||||
if (miss > 0) {
|
||||
defaultCopyright = window.prompt(
|
||||
'Copyright-Vermerk für betroffene Dateien ohne Eintrag (mind. 3 Zeichen):',
|
||||
'© ',
|
||||
)
|
||||
if (!defaultCopyright || String(defaultCopyright).trim().length < 3) {
|
||||
alert('Mindestens 3 Zeichen für den Copyright-Vermerk.')
|
||||
throw firstErr
|
||||
}
|
||||
}
|
||||
await saveOnce({
|
||||
promote_attached_media_for_official: true,
|
||||
...(miss > 0 ? { default_official_media_copyright: String(defaultCopyright).trim() } : {}),
|
||||
})
|
||||
} else {
|
||||
throw firstErr
|
||||
}
|
||||
}
|
||||
const ex = await api.getExercise(exerciseId)
|
||||
setMediaList(ex.media || [])
|
||||
setVariants((ex.variants || []).map(apiVariantToRow))
|
||||
|
||||
Reference in new issue
Block a user