Fix admin delete in the UI

main
Thomas Sileo 2022-09-07 19:45:34 +02:00
parent 1bfea16eed
commit eba868e8e5
2 changed files with 2 additions and 2 deletions

View File

@ -740,7 +740,7 @@ async def admin_object(
db_session: AsyncSession = Depends(get_db_session), db_session: AsyncSession = Depends(get_db_session),
) -> templates.TemplateResponse: ) -> templates.TemplateResponse:
requested_object = await boxes.get_anybox_object_by_ap_id(db_session, ap_id) requested_object = await boxes.get_anybox_object_by_ap_id(db_session, ap_id)
if not requested_object: if not requested_object or requested_object.is_deleted:
raise HTTPException(status_code=404) raise HTTPException(status_code=404)
replies_tree = await boxes.get_replies_tree( replies_tree = await boxes.get_replies_tree(

View File

@ -99,7 +99,7 @@
{% macro admin_delete_button(ap_object) %} {% macro admin_delete_button(ap_object) %}
<form action="{{ request.url_for("admin_actions_delete") }}" class="object-delete-form" method="POST"> <form action="{{ request.url_for("admin_actions_delete") }}" class="object-delete-form" method="POST">
{{ embed_csrf_token() }} {{ embed_csrf_token() }}
<input type="hidden" name="redirect_url" value="{% if request.url.path.endswith("/" + ap_object.public_id) %}{{ request.base_url}}{% else %}{{ request.url }}{% endif %}"> <input type="hidden" name="redirect_url" value="{% if request.url.path.endswith("/" + ap_object.public_id) or (request.url.path == "/admin/object" and request.query_params.ap_id.endswith("/" + ap_object.public_id)) %}{{ request.base_url}}{% else %}{{ request.url }}{% endif %}">
<input type="hidden" name="ap_object_id" value="{{ ap_object.ap_id }}"> <input type="hidden" name="ap_object_id" value="{{ ap_object.ap_id }}">
<input type="submit" value="delete"> <input type="submit" value="delete">
</form> </form>