mirror of
https://github.com/lrnselfreliance/wrolpi.git
synced 2026-11-20 23:16:17 -05:00
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:
parent
513ae52a6e
commit
09a967535b
23 changed files with 689 additions and 109 deletions
|
|
@ -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()
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue