mirror of
https://github.com/bookwyrm-social/bookwyrm.git
synced 2025-01-05 14:58:43 +00:00
Merge branch 'main' into production
This commit is contained in:
commit
9d26c0e824
6 changed files with 104 additions and 4 deletions
|
@ -1,5 +1,6 @@
|
|||
{% extends 'settings/admin_layout.html' %}
|
||||
{% load i18n %}
|
||||
{% load bookwyrm_tags %}
|
||||
{% load humanize %}
|
||||
|
||||
{% block title %}{% blocktrans with report_id=report.id username=report.user.username %}Report #{{ report_id }}: {{ username }}{% endblocktrans %}{% endblock %}
|
||||
|
@ -14,9 +15,62 @@
|
|||
{% include 'moderation/report_preview.html' with report=report %}
|
||||
</div>
|
||||
|
||||
<div class="block columns">
|
||||
<div class="column is-flex is-flex-direction-column">
|
||||
<h4 class="title is-4">{% trans "User details" %}</h4>
|
||||
<div class="box is-flex-grow-1">
|
||||
{% include 'user/user_preview.html' with user=report.user %}
|
||||
{% if report.user.summary %}
|
||||
<div class="box content has-background-white-ter is-shadowless">
|
||||
{{ report.user.summary | to_markdown | safe }}
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
<p class="mt-2"><a href="{{ report.user.local_path }}">{% trans "View user profile" %}</a></p>
|
||||
</div>
|
||||
</div>
|
||||
{% if not report.user.local %}
|
||||
{% with server=report.user.federated_server %}
|
||||
<div class="column is-half is-flex is-flex-direction-column">
|
||||
<h4 class="title is-4">{% trans "Instance details" %}</h4>
|
||||
<div class="box content is-flex-grow-1">
|
||||
{% if server %}
|
||||
<h5>{{ server.server_name }}</h5>
|
||||
<dl>
|
||||
<div class="is-flex">
|
||||
<dt>{% trans "Software:" %}</dt>
|
||||
<dd>{{ server.application_type }}</dd>
|
||||
</div>
|
||||
<div class="is-flex">
|
||||
<dt>{% trans "Version:" %}</dt>
|
||||
<dd>{{ server.application_version }}</dd>
|
||||
</div>
|
||||
<div class="is-flex">
|
||||
<dt>{% trans "Status:" %}</dt>
|
||||
<dd>{{ server.status }}</dd>
|
||||
</div>
|
||||
</dl>
|
||||
{% if server.notes %}
|
||||
<h5>{% trans "Notes" %}</h5>
|
||||
<div class="box content has-background-white-ter is-shadowless">
|
||||
{{ server.notes }}
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
<p>
|
||||
<a href="{% url 'settings-federated-server' server.id %}">{% trans "View instance" %}</a>
|
||||
</p>
|
||||
{% else %}
|
||||
<em>{% trans "Not set" %}</em>
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
{% endwith %}
|
||||
{% endif %}
|
||||
</div>
|
||||
|
||||
<div class="block content">
|
||||
<h3>{% trans "Actions" %}</h3>
|
||||
<p><a href="{{ report.user.local_path }}">{% trans "View user profile" %}</a></p>
|
||||
<div class="is-flex">
|
||||
<p class="mr-1">
|
||||
<a class="button" href="{% url 'direct-messages-user' report.user.username %}">{% trans "Send direct message" %}</a>
|
||||
|
|
|
@ -15,7 +15,9 @@
|
|||
{% csrf_token %}
|
||||
<input type="hidden" name="reporter" value="{{ reporter.id }}">
|
||||
<input type="hidden" name="user" value="{{ user.id }}">
|
||||
{% if status %}
|
||||
<input type="hidden" name="statuses" value="{{ status.id }}">
|
||||
{% endif %}
|
||||
|
||||
<section class="content">
|
||||
<p>{% blocktrans with site_name=site.name %}This report will be sent to {{ site_name }}'s moderators for review.{% endblocktrans %}</p>
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
<a href="/direct-messages/{{ user|username }}" class="button is-fullwidth is-small">{% trans "Send direct message" %}</a>
|
||||
</li>
|
||||
<li role="menuitem">
|
||||
{% include 'snippets/report_button.html' with user=status.user class="is-fullwidth" %}
|
||||
{% include 'snippets/report_button.html' with user=user class="is-fullwidth" %}
|
||||
</li>
|
||||
<li role="menuitem">
|
||||
{% include 'snippets/block_button.html' with user=user class="is-fullwidth" %}
|
||||
|
|
1
bookwyrm/tests/management/__init__.py
Normal file
1
bookwyrm/tests/management/__init__.py
Normal file
|
@ -0,0 +1 @@
|
|||
from . import *
|
44
bookwyrm/tests/management/test_populate_streams.py
Normal file
44
bookwyrm/tests/management/test_populate_streams.py
Normal file
|
@ -0,0 +1,44 @@
|
|||
""" test populating user streams """
|
||||
from unittest.mock import patch
|
||||
from django.test import TestCase
|
||||
|
||||
from bookwyrm import models
|
||||
from bookwyrm.management.commands.populate_streams import populate_streams
|
||||
|
||||
|
||||
@patch("bookwyrm.models.activitypub_mixin.broadcast_task.delay")
|
||||
class Activitystreams(TestCase):
|
||||
""" using redis to build activity streams """
|
||||
|
||||
def setUp(self):
|
||||
""" we need some stuff """
|
||||
self.local_user = models.User.objects.create_user(
|
||||
"mouse", "mouse@mouse.mouse", "password", local=True, localname="mouse"
|
||||
)
|
||||
self.another_user = models.User.objects.create_user(
|
||||
"nutria", "nutria@nutria.nutria", "password", local=True, localname="nutria"
|
||||
)
|
||||
with patch("bookwyrm.models.user.set_remote_server.delay"):
|
||||
self.remote_user = models.User.objects.create_user(
|
||||
"rat",
|
||||
"rat@rat.com",
|
||||
"ratword",
|
||||
local=False,
|
||||
remote_id="https://example.com/users/rat",
|
||||
inbox="https://example.com/users/rat/inbox",
|
||||
outbox="https://example.com/users/rat/outbox",
|
||||
)
|
||||
self.book = models.Edition.objects.create(title="test book")
|
||||
|
||||
def test_populate_streams(self, _):
|
||||
""" make sure the function on the redis manager gets called """
|
||||
with patch("bookwyrm.activitystreams.ActivityStream.add_status"):
|
||||
models.Comment.objects.create(
|
||||
user=self.local_user, content="hi", book=self.book
|
||||
)
|
||||
|
||||
with patch(
|
||||
"bookwyrm.activitystreams.ActivityStream.populate_store"
|
||||
) as redis_mock:
|
||||
populate_streams()
|
||||
self.assertEqual(redis_mock.call_count, 6) # 2 users x 3 streams
|
|
@ -98,8 +98,7 @@ def make_report(request):
|
|||
""" a user reports something """
|
||||
form = forms.ReportForm(request.POST)
|
||||
if not form.is_valid():
|
||||
print(form.errors)
|
||||
return redirect(request.headers.get("Referer", "/"))
|
||||
raise ValueError(form.errors)
|
||||
|
||||
form.save()
|
||||
return redirect(request.headers.get("Referer", "/"))
|
||||
|
|
Loading…
Reference in a new issue