Apply review suggestions

This commit is contained in:
Joachim 2021-11-24 11:59:45 +01:00
parent 7bdfacb688
commit 40e4591a24
6 changed files with 79 additions and 58 deletions

View file

@ -9,6 +9,7 @@ from django.utils import timezone
from django.utils.translation import gettext_lazy as _
from bookwyrm import models
from bookwyrm.models.user import FeedFilterChoices
class CustomForm(ModelForm):
@ -179,15 +180,9 @@ class FeedStatusTypesForm(CustomForm):
model = models.User
fields = ["feed_status_types"]
help_texts = {f: None for f in fields}
labels = {"feed_status_types": ""}
widgets = {
"feed_status_types": widgets.CheckboxSelectMultiple(
choices=[
("review", _("Reviews")),
("comment", _("Comments")),
("quotation", _("Quotations")),
("everything", _("Everything else")),
],
choices=FeedFilterChoices,
),
}

View file

@ -1,5 +1,6 @@
# Generated by Django 3.2.5 on 2021-11-21 23:28
# Generated by Django 3.2.5 on 2021-11-24 10:15
import bookwyrm.models.user
import django.contrib.postgres.fields
from django.db import migrations, models
@ -15,8 +16,16 @@ class Migration(migrations.Migration):
model_name="user",
name="feed_status_types",
field=django.contrib.postgres.fields.ArrayField(
base_field=models.CharField(max_length=10),
default=["review", "comment", "quotation", "everything"],
base_field=models.CharField(
choices=[
("review", "Reviews"),
("comment", "Comments"),
("quotation", "Quotations"),
("everything", "Everything else"),
],
max_length=10,
),
default=bookwyrm.models.user.get_feed_filter_choices,
size=8,
),
),

View file

@ -9,6 +9,7 @@ from django.core.validators import MinValueValidator
from django.dispatch import receiver
from django.db import models, transaction
from django.utils import timezone
from django.utils.translation import gettext_lazy as _
from model_utils import FieldTracker
import pytz
@ -27,6 +28,18 @@ from .federated_server import FederatedServer
from . import fields, Review
FeedFilterChoices = [
("review", _("Reviews")),
("comment", _("Comments")),
("quotation", _("Quotations")),
("everything", _("Everything else")),
]
def get_feed_filter_choices():
return [f[0] for f in FeedFilterChoices]
def site_link():
"""helper for generating links to the site"""
protocol = "https" if USE_HTTPS else "http"
@ -130,9 +143,9 @@ class User(OrderedCollectionPageMixin, AbstractUser):
# feed options
feed_status_types = ArrayField(
models.CharField(max_length=10, blank=False),
models.CharField(max_length=10, blank=False, choices=FeedFilterChoices),
size=8,
default=list(["review", "comment", "quotation", "everything"]),
default=get_feed_filter_choices,
)
preferred_timezone = models.CharField(

View file

@ -42,7 +42,7 @@
</div>
</div>
</div>
<div class="level-right">
<div class="level-right control">
<button class="button is-small is-primary is-outlined" type="submit">
{{ _("Save settings") }}
</button>
@ -69,7 +69,8 @@
{# activity feed #}
{% if not activities %}
<div class="block content">
<p>{% trans "There aren't any activities right now! Try following a user to get started" %}{% if user.feed_status_types|length < 4 %}{% trans ", or enable more status types" %}{% endif %}</p>
<p>{% trans "There aren't any activities right now! Try following a user to get started" %}</p>
<p>{% if user.feed_status_types|length < 4 %}{% trans "Alternatively, you can try enabling more status types" %}{% endif %}</p>
{% if request.user.show_suggested_users and suggested_users %}
{# suggested users for when things are very lonely #}

View file

@ -7,10 +7,10 @@ from django.shortcuts import get_object_or_404
from django.template.response import TemplateResponse
from django.utils import timezone
from django.utils.decorators import method_decorator
from django.utils.translation import gettext_lazy as _
from django.views import View
from bookwyrm import activitystreams, forms, models
from bookwyrm.models.user import FeedFilterChoices
from bookwyrm.activitypub import ActivitypubResponse
from bookwyrm.settings import PAGE_LENGTH, STREAMS
from bookwyrm.suggested_users import suggested_users
@ -58,12 +58,7 @@ class Feed(View):
"tab": tab,
"streams": STREAMS,
"goal_form": forms.GoalForm(),
"feed_status_types_options": [
("review", _("Reviews")),
("comment", _("Comments")),
("quotation", _("Quotations")),
("everything", _("Everything else")),
],
"feed_status_types_options": FeedFilterChoices,
"settings_saved": settings_saved,
"path": f"/{tab['key']}",
},
@ -260,12 +255,21 @@ def filter_stream_by_status_type(activities, allowed_types=None):
allowed_types = []
if "review" not in allowed_types:
activities = activities.filter(Q(review__isnull=True))
activities = activities.filter(
Q(review__isnull=True) | Q(boost__boosted_status__review__isnull=True)
)
if "comment" not in allowed_types:
activities = activities.filter(Q(comment__isnull=True))
activities = activities.filter(
Q(comment__isnull=True) | Q(boost__boosted_status__comment__isnull=True)
)
if "quotation" not in allowed_types:
activities = activities.filter(Q(quotation__isnull=True))
activities = activities.filter(
Q(quotation__isnull=True) | Q(boost__boosted_status__quotation__isnull=True)
)
if "everything" not in allowed_types:
activities = activities.filter(Q(generatednote__isnull=True))
activities = activities.filter(
Q(generatednote__isnull=True)
| Q(boost__boosted_status__generatednote__isnull=True)
)
return activities

View file

@ -8,7 +8,7 @@ msgid ""
msgstr ""
"Project-Id-Version: 0.0.1\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2021-11-22 18:23+0000\n"
"POT-Creation-Date: 2021-11-24 10:57+0000\n"
"PO-Revision-Date: 2021-02-28 17:19-0800\n"
"Last-Translator: Mouse Reeve <mousereeve@riseup.net>\n"
"Language-Team: English <LL@li.org>\n"
@ -18,75 +18,58 @@ msgstr ""
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=2; plural=(n != 1);\n"
#: bookwyrm/forms.py:186 bookwyrm/templates/book/book.html:218
#: bookwyrm/views/feed.py:62
msgid "Reviews"
msgstr ""
#: bookwyrm/forms.py:187 bookwyrm/views/feed.py:63
msgid "Comments"
msgstr ""
#: bookwyrm/forms.py:188 bookwyrm/views/feed.py:64
msgid "Quotations"
msgstr ""
#: bookwyrm/forms.py:189 bookwyrm/views/feed.py:65
msgid "Everything else"
msgstr ""
#: bookwyrm/forms.py:266
#: bookwyrm/forms.py:262
msgid "A user with this email already exists."
msgstr ""
#: bookwyrm/forms.py:280
#: bookwyrm/forms.py:276
msgid "One Day"
msgstr ""
#: bookwyrm/forms.py:281
#: bookwyrm/forms.py:277
msgid "One Week"
msgstr ""
#: bookwyrm/forms.py:282
#: bookwyrm/forms.py:278
msgid "One Month"
msgstr ""
#: bookwyrm/forms.py:283
#: bookwyrm/forms.py:279
msgid "Does Not Expire"
msgstr ""
#: bookwyrm/forms.py:287
#: bookwyrm/forms.py:283
#, python-brace-format
msgid "{i} uses"
msgstr ""
#: bookwyrm/forms.py:288
#: bookwyrm/forms.py:284
msgid "Unlimited"
msgstr ""
#: bookwyrm/forms.py:356
#: bookwyrm/forms.py:352
msgid "List Order"
msgstr ""
#: bookwyrm/forms.py:357
#: bookwyrm/forms.py:353
msgid "Book Title"
msgstr ""
#: bookwyrm/forms.py:358 bookwyrm/templates/shelf/shelf.html:149
#: bookwyrm/forms.py:354 bookwyrm/templates/shelf/shelf.html:149
#: bookwyrm/templates/shelf/shelf.html:181
#: bookwyrm/templates/snippets/create_status/review.html:33
msgid "Rating"
msgstr ""
#: bookwyrm/forms.py:360 bookwyrm/templates/lists/list.html:110
#: bookwyrm/forms.py:356 bookwyrm/templates/lists/list.html:110
msgid "Sort By"
msgstr ""
#: bookwyrm/forms.py:364
#: bookwyrm/forms.py:360
msgid "Ascending"
msgstr ""
#: bookwyrm/forms.py:365
#: bookwyrm/forms.py:361
msgid "Descending"
msgstr ""
@ -170,6 +153,22 @@ msgstr ""
msgid "A user with that username already exists."
msgstr ""
#: bookwyrm/models/user.py:32 bookwyrm/templates/book/book.html:218
msgid "Reviews"
msgstr ""
#: bookwyrm/models/user.py:33
msgid "Comments"
msgstr ""
#: bookwyrm/models/user.py:34
msgid "Quotations"
msgstr ""
#: bookwyrm/models/user.py:35
msgid "Everything else"
msgstr ""
#: bookwyrm/settings.py:118
msgid "Home Timeline"
msgstr ""
@ -1108,8 +1107,8 @@ msgstr ""
msgid "There aren't any activities right now! Try following a user to get started"
msgstr ""
#: bookwyrm/templates/feed/feed.html:72
msgid ", or enable more status types"
#: bookwyrm/templates/feed/feed.html:73
msgid "Alternatively, you can try enabling more status types"
msgstr ""
#: bookwyrm/templates/feed/goal_card.html:6