Models like Archive/Video/Doc can be deleted, even if they are tagged. User is shown a warning and must confirm deletion of tagged files.

This commit is contained in:
Roland 2026-05-03 17:28:06 -06:00 • committed by lrnselfreliance
parent 513ae52a6e
commit 09a967535b
23 changed files with 689 additions and 109 deletions

View file

@ -36,15 +36,21 @@ async def get_doc(request: Request, file_group_id: int):
@docs_bp.delete('/<file_group_ids:int>', name='doc_delete_one')
@docs_bp.delete('/<file_group_ids:[0-9,]+>', name='doc_delete_many')
@openapi.description('Delete Docs by FileGroup IDs')
@openapi.description('Delete Docs by FileGroup IDs. Pass ?force=true to delete even tagged FileGroups.')
@openapi.response(HTTPStatus.NOT_FOUND, JSONErrorResponse)
@wrol_mode_check
async def delete_docs(_: Request, file_group_ids: str):
async def delete_docs(request: Request, file_group_ids: str):
try:
file_group_ids = [int(i) for i in str(file_group_ids).split(',')]
except ValueError:
raise ValidationError('Could not parse file group ids')
_delete_docs(*file_group_ids)
force = request.args.get('force', '').lower() == 'true'
tagged = _delete_docs(*file_group_ids, force=force)
if tagged:
return json_response(
{'code': 'FILE_GROUP_IS_TAGGED', 'file_groups': tagged},
HTTPStatus.CONFLICT,
)
return response.empty()