Record statuses deleted in reports

This commit is contained in:
Mouse Reeve 2023-05-30 11:35:47 -07:00
parent affaf3d0ba
commit c6d23ba26a
3 changed files with 11 additions and 6 deletions

View file

@ -18,7 +18,7 @@
<div class="card-footer-item">
{# moderation options #}
<form name="delete-{{ status.id }}" action="/delete-status/{{ status.id }}" method="post">
<form name="delete-{{ status.id }}" action="/delete-status/{{ status.id }}/{{ report.id }}" method="post">
{% csrf_token %}
<button class="button is-danger is-light" type="submit">
{% trans "Delete status" %}

View file

@ -141,7 +141,7 @@ urlpatterns = [
name="settings-users",
),
re_path(
r"^settings/users/(?P<user>\d+)/(?P<report_id>\d+)??$",
r"^settings/users/(?P<user>\d+)/(?P<report_id>\d+)?$",
views.UserAdmin.as_view(),
name="settings-user",
),
@ -633,7 +633,7 @@ urlpatterns = [
name="create-status",
),
re_path(
r"^delete-status/(?P<status_id>\d+)/?$",
r"^delete-status/(?P<status_id>\d+)/?(?P<report_id>\d+)?$",
views.DeleteStatus.as_view(),
name="delete-status",
),

View file

@ -8,7 +8,7 @@ from django.core.validators import URLValidator
from django.core.exceptions import ValidationError
from django.db.models import Q
from django.http import HttpResponse, HttpResponseBadRequest, Http404
from django.shortcuts import get_object_or_404, redirect
from django.shortcuts import get_object_or_404
from django.template.response import TemplateResponse
from django.utils import timezone
from django.utils.decorators import method_decorator
@ -17,6 +17,7 @@ from django.views.decorators.http import require_POST
from markdown import markdown
from bookwyrm import forms, models
from bookwyrm.models.report import DELETE_ITEM
from bookwyrm.utils import regex, sanitizer
from .helpers import handle_remote_webfinger, is_api_request
from .helpers import load_date_in_user_tz_as_utc, redirect_to_referer
@ -167,7 +168,7 @@ def format_hashtags(content, hashtags):
class DeleteStatus(View):
"""tombstone that bad boy"""
def post(self, request, status_id):
def post(self, request, status_id, report_id=None):
"""delete and tombstone a status"""
status = get_object_or_404(models.Status, id=status_id)
@ -176,7 +177,11 @@ class DeleteStatus(View):
# perform deletion
status.delete()
return redirect("/")
# record deletion if it's related to a report
if report_id:
models.Report.record_action(report_id, DELETE_ITEM, request.user)
return redirect_to_referer(request, "/")
@login_required