mirror of
https://github.com/bookwyrm-social/bookwyrm.git
synced 2024-12-16 13:16:33 +00:00
First pass at views for reporting
This commit is contained in:
parent
bf255bd51d
commit
ab57b5b906
9 changed files with 102 additions and 3 deletions
|
@ -114,8 +114,8 @@
|
|||
{% endif %}
|
||||
{% if perms.bookwyrm.edit_instance_settings %}
|
||||
<li>
|
||||
<a href="{% url 'settings-site' %}" class="navbar-item">
|
||||
{% trans 'Site Configuration' %}
|
||||
<a href="{% url 'settings-reports' %}" class="navbar-item">
|
||||
{% trans 'Admin' %}
|
||||
</a>
|
||||
</li>
|
||||
{% endif %}
|
||||
|
|
|
@ -18,6 +18,10 @@
|
|||
{% url 'settings-invites' as url %}
|
||||
<a href="{{ url }}"{% if url in request.path %} class="is-active" aria-selected="true"{% endif %}>{% trans "Invites" %}</a>
|
||||
</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>
|
||||
{% url 'settings-federation' as url %}
|
||||
<a href="{{ url }}"{% if url in request.path %} class="is-active" aria-selected="true"{% endif %}>{% trans "Federated Servers" %}</a>
|
||||
|
|
14
bookwyrm/templates/settings/report_preview.html
Normal file
14
bookwyrm/templates/settings/report_preview.html
Normal 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
|
27
bookwyrm/templates/settings/reports.html
Normal file
27
bookwyrm/templates/settings/reports.html
Normal 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 %}
|
||||
|
|
@ -10,6 +10,7 @@
|
|||
|
||||
{% block dropdown-list %}
|
||||
{% if status.user == request.user %}
|
||||
{# things you can do to your own statuses #}
|
||||
<li role="menuitem">
|
||||
<form class="dropdown-item pt-0 pb-0" name="delete-{{status.id}}" action="/delete-status/{{ status.id }}" method="post">
|
||||
{% csrf_token %}
|
||||
|
@ -19,9 +20,13 @@
|
|||
</form>
|
||||
</li>
|
||||
{% else %}
|
||||
{# things you can do to other people's statuses #}
|
||||
<li role="menuitem">
|
||||
<a href="/direct-messages/{{ status.user|username }}" class="button is-fullwidth is-small">{% trans "Send direct message" %}</a>
|
||||
</li>
|
||||
<li role="menuitem">
|
||||
<a href="{{ status.local_path }}/report" class="button is-fullwidth is-small">{% trans "Report status" %}</a>
|
||||
</li>
|
||||
<li role="menuitem">
|
||||
{% include 'snippets/block_button.html' with user=status.user class="is-fullwidth" %}
|
||||
</li>
|
||||
|
|
|
@ -12,6 +12,9 @@
|
|||
<li role="menuitem">
|
||||
<a href="/direct-messages/{{ user|username }}" class="button is-fullwidth is-small">{% trans "Send direct message" %}</a>
|
||||
</li>
|
||||
<li role="menuitem">
|
||||
<a href="{{ user.local_path }}/report" class="button is-fullwidth is-small">{% trans "Report user" %}</a>
|
||||
</li>
|
||||
<li role="menuitem">
|
||||
{% include 'snippets/block_button.html' with user=user class="is-fullwidth" %}
|
||||
</li>
|
||||
|
|
|
@ -54,6 +54,13 @@ urlpatterns = [
|
|||
re_path(
|
||||
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()),
|
||||
# landing pages
|
||||
re_path(r"^about/?$", views.About.as_view()),
|
||||
|
|
|
@ -20,15 +20,16 @@ from .notifications import Notifications
|
|||
from .outbox import Outbox
|
||||
from .reading import edit_readthrough, create_readthrough, delete_readthrough
|
||||
from .reading import start_reading, finish_reading, delete_progressupdate
|
||||
from .reports import Report, Reports
|
||||
from .rss_feed import RssFeed
|
||||
from .password import PasswordResetRequest, PasswordReset, ChangePassword
|
||||
from .tag import Tag, AddTag, RemoveTag
|
||||
from .search import Search
|
||||
from .shelf import Shelf
|
||||
from .shelf import user_shelves_page, create_shelf, delete_shelf
|
||||
from .shelf import shelve, unshelve
|
||||
from .site import Site
|
||||
from .status import CreateStatus, DeleteStatus
|
||||
from .tag import Tag, AddTag, RemoveTag
|
||||
from .updates import Updates
|
||||
from .user import User, EditUser, Followers, Following
|
||||
from .isbn import Isbn
|
||||
|
|
38
bookwyrm/views/reports.py
Normal file
38
bookwyrm/views/reports.py
Normal 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)
|
Loading…
Reference in a new issue