diff --git a/bookwyrm/forms.py b/bookwyrm/forms.py index e08f3a3a..0d27fffe 100644 --- a/bookwyrm/forms.py +++ b/bookwyrm/forms.py @@ -453,7 +453,7 @@ class GroupForm(CustomForm): class ReportForm(CustomForm): class Meta: model = models.Report - fields = ["user", "reporter", "statuses", "note"] + fields = ["user", "reporter", "statuses", "links", "note"] class EmailBlocklistForm(CustomForm): diff --git a/bookwyrm/migrations/0127_auto_20220110_2211.py b/bookwyrm/migrations/0127_auto_20220110_2211.py new file mode 100644 index 00000000..e18be29e --- /dev/null +++ b/bookwyrm/migrations/0127_auto_20220110_2211.py @@ -0,0 +1,22 @@ +# Generated by Django 3.2.10 on 2022-01-10 22:11 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ("bookwyrm", "0126_filelink_link_linkdomain"), + ] + + operations = [ + migrations.RemoveConstraint( + model_name="report", + name="self_report", + ), + migrations.AddField( + model_name="report", + name="links", + field=models.ManyToManyField(blank=True, to="bookwyrm.Link"), + ), + ] diff --git a/bookwyrm/models/link.py b/bookwyrm/models/link.py index 3e21642f..be7c104f 100644 --- a/bookwyrm/models/link.py +++ b/bookwyrm/models/link.py @@ -16,10 +16,7 @@ class Link(ActivitypubMixin, BookWyrmModel): url = fields.URLField(max_length=255, activitypub_field="href") added_by = fields.ForeignKey( - "User", - on_delete=models.SET_NULL, - null=True, - activitypub_field="attributedTo" + "User", on_delete=models.SET_NULL, null=True, activitypub_field="attributedTo" ) domain = models.ForeignKey( "LinkDomain", diff --git a/bookwyrm/models/report.py b/bookwyrm/models/report.py index 636817cb..4910a4e0 100644 --- a/bookwyrm/models/report.py +++ b/bookwyrm/models/report.py @@ -13,14 +13,12 @@ class Report(BookWyrmModel): note = models.TextField(null=True, blank=True) user = models.ForeignKey("User", on_delete=models.PROTECT) statuses = models.ManyToManyField("Status", blank=True) + links = models.ManyToManyField("Link", blank=True) resolved = models.BooleanField(default=False) class Meta: - """don't let users report themselves""" + """set order by default""" - constraints = [ - models.CheckConstraint(check=~Q(reporter=F("user")), name="self_report") - ] ordering = ("-created_date",) diff --git a/bookwyrm/static/css/bookwyrm.css b/bookwyrm/static/css/bookwyrm.css index 4d960734..92ddd294 100644 --- a/bookwyrm/static/css/bookwyrm.css +++ b/bookwyrm/static/css/bookwyrm.css @@ -720,6 +720,10 @@ ol.ordered-list li::before { } } +.overflow-wrap-anywhere { + overflow-wrap: anywhere; +} + /* Threads ******************************************************************************/ diff --git a/bookwyrm/templates/book/link_verification_modal.html b/bookwyrm/templates/book/link_verification_modal.html index ed7dca8e..eab8987b 100644 --- a/bookwyrm/templates/book/link_verification_modal.html +++ b/bookwyrm/templates/book/link_verification_modal.html @@ -9,7 +9,8 @@ {% block modal-body %} {% blocktrans trimmed with link_url=link.url %} -This link is taking you to {{ link_url }}. Is that where you'd like to go? +This link is taking you to: {{ link_url }}.
+Is that where you'd like to go? {% endblocktrans %} {% endblock %} @@ -19,4 +20,10 @@ This link is taking you to {{ link_url }}. Is that where you'd like {% trans "Continue" %} +{% if request.user.is_authenticated %} +
+ {% trans "Report spam" %} +
+{% endif %} + {% endblock %} diff --git a/bookwyrm/templates/report.html b/bookwyrm/templates/report.html new file mode 100644 index 00000000..686401eb --- /dev/null +++ b/bookwyrm/templates/report.html @@ -0,0 +1,10 @@ +{% extends "layout.html" %} +{% load i18n %} + +{% block title %} +{% trans "Report" %} +{% endblock %} + +{% block content %} +{% include "snippets/report_modal.html" with user=user active=True static=True %} +{% endblock %} diff --git a/bookwyrm/templates/settings/link_domains/link_domains.html b/bookwyrm/templates/settings/link_domains/link_domains.html index 83190029..3f2d6097 100644 --- a/bookwyrm/templates/settings/link_domains/link_domains.html +++ b/bookwyrm/templates/settings/link_domains/link_domains.html @@ -1,5 +1,4 @@ {% extends 'settings/layout.html' %} -{% load humanize %} {% load i18n %} {% load utilities %} @@ -32,7 +31,7 @@ {% for domain in domains %} {% join "domain" domain.id as domain_modal %} -
+

@@ -58,37 +57,7 @@
- - - - - - - - {% for link in domain.links.all|slice:10 %} - - - - - - - - {% endfor %} -
{% trans "URL" %}{% trans "Added by" %}{% trans "Filetype" %}{% trans "Book" %}
- {{ link.url }} - - @{{ link.added_by|username }} - - {% if link.filelink.filetype %} - {{ link.filelink.filetype }} - {% endif %} - - {% if link.filelink.filetype %} - {% with book=link.filelink.book %} - {% include "snippets/book_titleby.html" with book=book %} - {% endwith %} - {% endif %} -
+ {% include "settings/link_domains/link_table.html" with links=domain.links.all|slice:10 %}

diff --git a/bookwyrm/templates/settings/link_domains/link_table.html b/bookwyrm/templates/settings/link_domains/link_table.html new file mode 100644 index 00000000..680132fd --- /dev/null +++ b/bookwyrm/templates/settings/link_domains/link_table.html @@ -0,0 +1,36 @@ +{% load i18n %} +{% load utilities %} + + + + + + + + {% block additional_headers %}{% endblock %} + + {% for link in links%} + + + + + + + {% block additional_data %}{% endblock %} + + {% endfor %} +
{% trans "URL" %}{% trans "Added by" %}{% trans "Filetype" %}{% trans "Book" %}
+ {{ link.url }} + + @{{ link.added_by|username }} + + {% if link.filelink.filetype %} + {{ link.filelink.filetype }} + {% endif %} + + {% if link.filelink.filetype %} + {% with book=link.filelink.book %} + {% include "snippets/book_titleby.html" with book=book %} + {% endwith %} + {% endif %} +
diff --git a/bookwyrm/templates/settings/reports/report.html b/bookwyrm/templates/settings/reports/report.html index 37593f3c..84fafb14 100644 --- a/bookwyrm/templates/settings/reports/report.html +++ b/bookwyrm/templates/settings/reports/report.html @@ -2,10 +2,12 @@ {% load i18n %} {% load humanize %} -{% block title %}{% blocktrans with report_id=report.id username=report.user.username %}Report #{{ report_id }}: {{ username }}{% endblocktrans %}{% endblock %} +{% block title %} +{% include "settings/reports/report_header.html" with report=report %} +{% endblock %} {% block header %} -{% blocktrans with report_id=report.id username=report.user.username %}Report #{{ report_id }}: {{ username }}{% endblocktrans %} +{% include "settings/reports/report_header.html" with report=report %}
{% trans "Back to reports" %} {% endblock %} @@ -15,6 +17,36 @@ {% include 'settings/reports/report_preview.html' with report=report %}
+{% if report.statuses.exists %} +
+

{% trans "Reported statuses" %}

+ +
+{% endif %} + +{% if report.links.exists %} +
+

{% trans "Reported links" %}

+
+
+
+ {% include "settings/reports/report_links_table.html" with links=report.links.all %} +
+
+
+
+{% endif %} + {% include 'settings/users/user_info.html' with user=report.user %} {% include 'settings/users/user_moderation_actions.html' with user=report.user %} @@ -41,23 +73,4 @@
- -
-

{% trans "Reported statuses" %}

- {% if not report.statuses.exists %} - {% trans "No statuses reported" %} - {% else %} - - {% endif %} -
{% endblock %} diff --git a/bookwyrm/templates/settings/reports/report_header.html b/bookwyrm/templates/settings/reports/report_header.html new file mode 100644 index 00000000..d76db104 --- /dev/null +++ b/bookwyrm/templates/settings/reports/report_header.html @@ -0,0 +1,22 @@ +{% load i18n %} +{% load utilities %} + +{% if report.statuses.exists %} + +{% blocktrans trimmed with report_id=report.id username=report.user|username %} +Report #{{ report_id }}: Status posted by @{{ username }} +{% endblocktrans %} + +{% elif report.links.exists %} + +{% blocktrans trimmed with report_id=report.id username=report.user|username %} +Report #{{ report_id }}: Link added by @{{ username }} +{% endblocktrans %} + +{% else %} + +{% blocktrans trimmed with report_id=report.id username=report.user|username %} +Report #{{ report_id }}: User @{{ username }} +{% endblocktrans %} + +{% endif %} diff --git a/bookwyrm/templates/settings/reports/report_links_table.html b/bookwyrm/templates/settings/reports/report_links_table.html new file mode 100644 index 00000000..b0ebf73a --- /dev/null +++ b/bookwyrm/templates/settings/reports/report_links_table.html @@ -0,0 +1,20 @@ +{% extends "settings/link_domains/link_table.html" %} +{% load i18n %} + +{% block additional_headers %} +{% trans "Domain" %} +{% trans "Actions" %} +{% endblock %} + +{% block additional_data %} + + + {{ link.domain.domain }} + + + +
+ +
+ +{% endblock %} diff --git a/bookwyrm/templates/settings/reports/report_preview.html b/bookwyrm/templates/settings/reports/report_preview.html index 363783d5..31bde0a1 100644 --- a/bookwyrm/templates/settings/reports/report_preview.html +++ b/bookwyrm/templates/settings/reports/report_preview.html @@ -1,9 +1,13 @@ {% extends 'components/card.html' %} {% load i18n %} {% load humanize %} +{% load utilities %} + {% block card-header %}

- {% blocktrans with report_id=report.id username=report.user.username %}Report #{{ report_id }}: {{ username }}{% endblocktrans %} + + {% include "settings/reports/report_header.html" with report=report %} +

{% endblock %} @@ -17,7 +21,7 @@ {% block card-footer %} {% else %} -

{% trans "Actions" %}

+

{% trans "User Actions" %}

-
- {% if user.is_active %} -

- {% trans "Send direct message" %} -

- {% endif %} +
+
+ {% if user.is_active %} +

+ {% trans "Send direct message" %} +

+ {% endif %} - {% if user.is_active or user.deactivation_reason == "pending" %} -
- {% csrf_token %} - -
- {% else %} -
- {% csrf_token %} - -
+ {% if user.is_active or user.deactivation_reason == "pending" %} +
+ {% csrf_token %} + +
+ {% else %} +
+ {% csrf_token %} + +
+ {% endif %} + + {% if user.local %} +
+ {% trans "Permanently delete user" as button_text %} + {% include "snippets/toggle/open_button.html" with controls_text="delete_user" text=button_text class="is-danger is-light" %} +
+ {% endif %} +
+ + {% if user.local %} +
+ {% include "settings/users/delete_user_form.html" with controls_text="delete_user" class="mt-2 mb-2" %} +
{% endif %} {% if user.local %}
- {% trans "Permanently delete user" as button_text %} - {% include "snippets/toggle/open_button.html" with controls_text="delete_user" text=button_text class="is-danger is-light" %} +
+ {% csrf_token %} + + {% if group_form.non_field_errors %} + {{ group_form.non_field_errors }} + {% endif %} + {% with group=user.groups.first %} +
+ +
+ + {% include 'snippets/form_errors.html' with errors_list=group_form.groups.errors id="desc_user_group" %} + {% endwith %} + +
- {% endif %} -
- - {% if user.local %} -
- {% include "settings/users/delete_user_form.html" with controls_text="delete_user" class="mt-2 mb-2" %} -
- {% endif %} - - {% if user.local %} -
-
- {% csrf_token %} - - {% if group_form.non_field_errors %} - {{ group_form.non_field_errors }} - {% endif %} - {% with group=user.groups.first %} -
- -
- - {% include 'snippets/form_errors.html' with errors_list=group_form.groups.errors id="desc_user_group" %} - {% endwith %} - -
{% endif %} diff --git a/bookwyrm/templates/snippets/report_button.html b/bookwyrm/templates/snippets/report_button.html index 6b4a3f25..9d94d2af 100644 --- a/bookwyrm/templates/snippets/report_button.html +++ b/bookwyrm/templates/snippets/report_button.html @@ -12,6 +12,6 @@ > {% trans "Report" %} -{% include 'snippets/report_modal.html' with user=user reporter=request.user id=modal_id %} +{% include 'snippets/report_modal.html' with user=user id=modal_id status=status.id %} {% endwith %} diff --git a/bookwyrm/templates/snippets/report_modal.html b/bookwyrm/templates/snippets/report_modal.html index afd39644..7d2e52b6 100644 --- a/bookwyrm/templates/snippets/report_modal.html +++ b/bookwyrm/templates/snippets/report_modal.html @@ -1,9 +1,16 @@ {% extends 'components/modal.html' %} {% load i18n %} +{% load utilities %} {% load humanize %} {% block modal-title %} -{% blocktrans with username=user.username %}Report @{{ username }}{% endblocktrans %} +{% if status %} +{% blocktrans with username=user|username %}Report @{{ username }}'s status{% endblocktrans %} +{% elif link %} +{% blocktrans with domain=link.domain.domain %}Report {{ domain }} link{% endblocktrans %} +{% else %} +{% blocktrans with username=user|username %}Report @{{ username }}{% endblocktrans %} +{% endif %} {% endblock %} {% block modal-form-open %} @@ -13,14 +20,22 @@ {% block modal-body %} {% csrf_token %} - + {% if status %} - + +{% endif %} +{% if link %} + {% endif %}
-

{% blocktrans with site_name=site.name %}This report will be sent to {{ site_name }}'s moderators for review.{% endblocktrans %}

+

+ {% blocktrans with site_name=site.name %}This report will be sent to {{ site_name }}'s moderators for review.{% endblocktrans %} + {% if link %} + {% trans "Links from this domain will be removed until your report has been reviewed." %} + {% endif %} +