From ab57b5b906641df96be76fee71186d8eb4b51896 Mon Sep 17 00:00:00 2001 From: Mouse Reeve Date: Mon, 8 Mar 2021 15:49:44 -0800 Subject: [PATCH] First pass at views for reporting --- bookwyrm/templates/layout.html | 4 +- bookwyrm/templates/settings/admin_layout.html | 4 ++ .../templates/settings/report_preview.html | 14 +++++++ bookwyrm/templates/settings/reports.html | 27 +++++++++++++ .../snippets/status/status_options.html | 5 +++ bookwyrm/templates/snippets/user_options.html | 3 ++ bookwyrm/urls.py | 7 ++++ bookwyrm/views/__init__.py | 3 +- bookwyrm/views/reports.py | 38 +++++++++++++++++++ 9 files changed, 102 insertions(+), 3 deletions(-) create mode 100644 bookwyrm/templates/settings/report_preview.html create mode 100644 bookwyrm/templates/settings/reports.html create mode 100644 bookwyrm/views/reports.py diff --git a/bookwyrm/templates/layout.html b/bookwyrm/templates/layout.html index 901a12ff..fc2ebdb7 100644 --- a/bookwyrm/templates/layout.html +++ b/bookwyrm/templates/layout.html @@ -114,8 +114,8 @@ {% endif %} {% if perms.bookwyrm.edit_instance_settings %}
  • - - {% trans 'Site Configuration' %} + + {% trans 'Admin' %}
  • {% endif %} diff --git a/bookwyrm/templates/settings/admin_layout.html b/bookwyrm/templates/settings/admin_layout.html index 16741436..312d502a 100644 --- a/bookwyrm/templates/settings/admin_layout.html +++ b/bookwyrm/templates/settings/admin_layout.html @@ -18,6 +18,10 @@ {% url 'settings-invites' as url %} {% trans "Invites" %} +
  • + {% url 'settings-reports' as url %} + {% trans "Reports" %} +
  • {% url 'settings-federation' as url %} {% trans "Federated Servers" %} diff --git a/bookwyrm/templates/settings/report_preview.html b/bookwyrm/templates/settings/report_preview.html new file mode 100644 index 00000000..67bffe27 --- /dev/null +++ b/bookwyrm/templates/settings/report_preview.html @@ -0,0 +1,14 @@ +{% extends 'components/card.html' %} +{% load i18n %} +{% block card-header %} +

    + report title

    +{% endblock %} + +{% block card-content %} +about this report +{% endblock %} + +{% block card-footer %} +footer +{% endblock diff --git a/bookwyrm/templates/settings/reports.html b/bookwyrm/templates/settings/reports.html new file mode 100644 index 00000000..efca7244 --- /dev/null +++ b/bookwyrm/templates/settings/reports.html @@ -0,0 +1,27 @@ +{% extends 'settings/admin_layout.html' %} +{% load i18n %} + +{% block header %}{% trans "Reports" %}{% endblock %} + +{% block panel %} + + + + +{% endblock %} + diff --git a/bookwyrm/templates/snippets/status/status_options.html b/bookwyrm/templates/snippets/status/status_options.html index babd8296..0f099e17 100644 --- a/bookwyrm/templates/snippets/status/status_options.html +++ b/bookwyrm/templates/snippets/status/status_options.html @@ -10,6 +10,7 @@ {% block dropdown-list %} {% if status.user == request.user %} +{# things you can do to your own statuses #}
  • {% else %} +{# things you can do to other people's statuses #}
  • {% trans "Send direct message" %}
  • +
  • + {% trans "Report status" %} +
  • {% include 'snippets/block_button.html' with user=status.user class="is-fullwidth" %}
  • diff --git a/bookwyrm/templates/snippets/user_options.html b/bookwyrm/templates/snippets/user_options.html index b3f66782..c9fdac0a 100644 --- a/bookwyrm/templates/snippets/user_options.html +++ b/bookwyrm/templates/snippets/user_options.html @@ -12,6 +12,9 @@
  • {% trans "Send direct message" %}
  • +
  • + {% trans "Report user" %} +
  • {% include 'snippets/block_button.html' with user=user class="is-fullwidth" %}
  • diff --git a/bookwyrm/urls.py b/bookwyrm/urls.py index 844f8993..c7ec7f4b 100644 --- a/bookwyrm/urls.py +++ b/bookwyrm/urls.py @@ -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\d+)/?$", + views.Report.as_view(), + name="settings-report", + ), re_path(r"^invite/(?P[A-Za-z0-9]+)/?$", views.Invite.as_view()), # landing pages re_path(r"^about/?$", views.About.as_view()), diff --git a/bookwyrm/views/__init__.py b/bookwyrm/views/__init__.py index 48da8ec1..36a64ddf 100644 --- a/bookwyrm/views/__init__.py +++ b/bookwyrm/views/__init__.py @@ -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 diff --git a/bookwyrm/views/reports.py b/bookwyrm/views/reports.py new file mode 100644 index 00000000..a90fffaf --- /dev/null +++ b/bookwyrm/views/reports.py @@ -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)