First pass at views for reporting

This commit is contained in:
Mouse Reeve 2021-03-08 15:49:44 -08:00
parent bf255bd51d
commit ab57b5b906
9 changed files with 102 additions and 3 deletions

View file

@ -114,8 +114,8 @@
{% endif %} {% endif %}
{% if perms.bookwyrm.edit_instance_settings %} {% if perms.bookwyrm.edit_instance_settings %}
<li> <li>
<a href="{% url 'settings-site' %}" class="navbar-item"> <a href="{% url 'settings-reports' %}" class="navbar-item">
{% trans 'Site Configuration' %} {% trans 'Admin' %}
</a> </a>
</li> </li>
{% endif %} {% endif %}

View file

@ -18,6 +18,10 @@
{% url 'settings-invites' as url %} {% url 'settings-invites' as url %}
<a href="{{ url }}"{% if url in request.path %} class="is-active" aria-selected="true"{% endif %}>{% trans "Invites" %}</a> <a href="{{ url }}"{% if url in request.path %} class="is-active" aria-selected="true"{% endif %}>{% trans "Invites" %}</a>
</li> </li>
<li>
{% url 'settings-reports' as url %}
<a href="{{ url }}"{% if url in request.path %} class="is-active" aria-selected="true"{% endif %}>{% trans "Reports" %}</a>
</li>
<li> <li>
{% url 'settings-federation' as url %} {% url 'settings-federation' as url %}
<a href="{{ url }}"{% if url in request.path %} class="is-active" aria-selected="true"{% endif %}>{% trans "Federated Servers" %}</a> <a href="{{ url }}"{% if url in request.path %} class="is-active" aria-selected="true"{% endif %}>{% trans "Federated Servers" %}</a>

View file

@ -0,0 +1,14 @@
{% extends 'components/card.html' %}
{% load i18n %}
{% block card-header %}
<h2 class="title is-4">
<a href="{% url settings-report report.id %}">report title</a></h2>
{% endblock %}
{% block card-content %}
about this report
{% endblock %}
{% block card-footer %}
footer
{% endblock

View file

@ -0,0 +1,27 @@
{% extends 'settings/admin_layout.html' %}
{% load i18n %}
{% block header %}{% trans "Reports" %}{% endblock %}
{% block panel %}
<div class="tabs">
<ul>
<li class="{% if filter == 'open' %}is-active{% endif %}"{% if filter == 'open' %} aria-current="page"{% endif %}>
<a href="{% url 'settings-reports' %}?status=open">{% trans "Open" %}</a>
</li>
<li class="{% if filter == 'resolved' %}is-active{% endif %}"{% if filter == 'resolved' %} aria-current="page"{% endif %}>
<a href="{% url 'settings-reports' %}?status=closed">{% trans "Resolved" %}</a>
</li>
</ul>
</div>
<ul>
{% for report in reports %}
<li class="card">
{% include 'settings/report_preview.html' with report=report %}
</li>
{% endfor %}
</ul>
{% endblock %}

View file

@ -10,6 +10,7 @@
{% block dropdown-list %} {% block dropdown-list %}
{% if status.user == request.user %} {% if status.user == request.user %}
{# things you can do to your own statuses #}
<li role="menuitem"> <li role="menuitem">
<form class="dropdown-item pt-0 pb-0" name="delete-{{status.id}}" action="/delete-status/{{ status.id }}" method="post"> <form class="dropdown-item pt-0 pb-0" name="delete-{{status.id}}" action="/delete-status/{{ status.id }}" method="post">
{% csrf_token %} {% csrf_token %}
@ -19,9 +20,13 @@
</form> </form>
</li> </li>
{% else %} {% else %}
{# things you can do to other people's statuses #}
<li role="menuitem"> <li role="menuitem">
<a href="/direct-messages/{{ status.user|username }}" class="button is-fullwidth is-small">{% trans "Send direct message" %}</a> <a href="/direct-messages/{{ status.user|username }}" class="button is-fullwidth is-small">{% trans "Send direct message" %}</a>
</li> </li>
<li role="menuitem">
<a href="{{ status.local_path }}/report" class="button is-fullwidth is-small">{% trans "Report status" %}</a>
</li>
<li role="menuitem"> <li role="menuitem">
{% include 'snippets/block_button.html' with user=status.user class="is-fullwidth" %} {% include 'snippets/block_button.html' with user=status.user class="is-fullwidth" %}
</li> </li>

View file

@ -12,6 +12,9 @@
<li role="menuitem"> <li role="menuitem">
<a href="/direct-messages/{{ user|username }}" class="button is-fullwidth is-small">{% trans "Send direct message" %}</a> <a href="/direct-messages/{{ user|username }}" class="button is-fullwidth is-small">{% trans "Send direct message" %}</a>
</li> </li>
<li role="menuitem">
<a href="{{ user.local_path }}/report" class="button is-fullwidth is-small">{% trans "Report user" %}</a>
</li>
<li role="menuitem"> <li role="menuitem">
{% include 'snippets/block_button.html' with user=user class="is-fullwidth" %} {% include 'snippets/block_button.html' with user=user class="is-fullwidth" %}
</li> </li>

View file

@ -54,6 +54,13 @@ urlpatterns = [
re_path( re_path(
r"^settings/invites/?$", views.ManageInvites.as_view(), name="settings-invites" r"^settings/invites/?$", views.ManageInvites.as_view(), name="settings-invites"
), ),
# moderation
re_path(r"^settings/reports/?$", views.Reports.as_view(), name="settings-reports"),
re_path(
r"^settings/report/(?P<report_id>\d+)/?$",
views.Report.as_view(),
name="settings-report",
),
re_path(r"^invite/(?P<code>[A-Za-z0-9]+)/?$", views.Invite.as_view()), re_path(r"^invite/(?P<code>[A-Za-z0-9]+)/?$", views.Invite.as_view()),
# landing pages # landing pages
re_path(r"^about/?$", views.About.as_view()), re_path(r"^about/?$", views.About.as_view()),

View file

@ -20,15 +20,16 @@ from .notifications import Notifications
from .outbox import Outbox from .outbox import Outbox
from .reading import edit_readthrough, create_readthrough, delete_readthrough from .reading import edit_readthrough, create_readthrough, delete_readthrough
from .reading import start_reading, finish_reading, delete_progressupdate from .reading import start_reading, finish_reading, delete_progressupdate
from .reports import Report, Reports
from .rss_feed import RssFeed from .rss_feed import RssFeed
from .password import PasswordResetRequest, PasswordReset, ChangePassword from .password import PasswordResetRequest, PasswordReset, ChangePassword
from .tag import Tag, AddTag, RemoveTag
from .search import Search from .search import Search
from .shelf import Shelf from .shelf import Shelf
from .shelf import user_shelves_page, create_shelf, delete_shelf from .shelf import user_shelves_page, create_shelf, delete_shelf
from .shelf import shelve, unshelve from .shelf import shelve, unshelve
from .site import Site from .site import Site
from .status import CreateStatus, DeleteStatus from .status import CreateStatus, DeleteStatus
from .tag import Tag, AddTag, RemoveTag
from .updates import Updates from .updates import Updates
from .user import User, EditUser, Followers, Following from .user import User, EditUser, Followers, Following
from .isbn import Isbn from .isbn import Isbn

38
bookwyrm/views/reports.py Normal file
View file

@ -0,0 +1,38 @@
""" moderation via flagged posts and users """
from django.contrib.auth.decorators import login_required, permission_required
from django.shortcuts import get_object_or_404
from django.template.response import TemplateResponse
from django.utils.decorators import method_decorator
from django.views import View
from bookwyrm import models
# pylint: disable= no-self-use
@method_decorator(login_required, name="dispatch")
@method_decorator(
permission_required("bookwyrm.moderate_user", raise_exception=True),
name="dispatch",
)
@method_decorator(
permission_required("bookwyrm.moderate_post", raise_exception=True),
name="dispatch",
)
class Reports(View):
""" list of reports """
def get(self, request, status="open"):
""" view current reports """
data = {
"status": status
} # {"reports": models.Report.objects.filter(status=status)}
return TemplateResponse(request, "settings/reports.html", data)
class Report(View):
""" view a specific report """
def get(self, request, report_id):
""" load a report """
data = {"report": get_object_or_404(models.REport, id=report_id)}
return TemplateResponse(request, "settings/report.html", data)