mirror of
https://github.com/bookwyrm-social/bookwyrm.git
synced 2024-11-13 12:21:01 +00:00
Merge pull request #1383 from bookwyrm-social/hide-suggestions
Option to hide suggestions
This commit is contained in:
commit
aabacc2124
9 changed files with 61 additions and 14 deletions
|
@ -134,6 +134,7 @@ class EditUserForm(CustomForm):
|
|||
"email",
|
||||
"summary",
|
||||
"show_goal",
|
||||
"show_suggested_users",
|
||||
"manually_approves_followers",
|
||||
"default_post_privacy",
|
||||
"discoverable",
|
||||
|
|
18
bookwyrm/migrations/0089_user_show_suggested_users.py
Normal file
18
bookwyrm/migrations/0089_user_show_suggested_users.py
Normal file
|
@ -0,0 +1,18 @@
|
|||
# Generated by Django 3.2.4 on 2021-09-08 16:28
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
("bookwyrm", "0088_auto_20210905_2233"),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AddField(
|
||||
model_name="user",
|
||||
name="show_suggested_users",
|
||||
field=models.BooleanField(default=True),
|
||||
),
|
||||
]
|
|
@ -122,8 +122,12 @@ class User(OrderedCollectionPageMixin, AbstractUser):
|
|||
updated_date = models.DateTimeField(auto_now=True)
|
||||
last_active_date = models.DateTimeField(default=timezone.now)
|
||||
manually_approves_followers = fields.BooleanField(default=False)
|
||||
|
||||
# options to turn features on and off
|
||||
show_goal = models.BooleanField(default=True)
|
||||
show_suggested_users = models.BooleanField(default=True)
|
||||
discoverable = fields.BooleanField(default=False)
|
||||
|
||||
preferred_timezone = models.CharField(
|
||||
choices=[(str(tz), str(tz)) for tz in pytz.all_timezones],
|
||||
default=str(pytz.utc),
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
{% blocktrans with tab_key=tab.key %}load <span data-poll="stream/{{ tab_key }}">0</span> unread status(es){% endblocktrans %}
|
||||
</a>
|
||||
|
||||
{% if request.user.show_goal and not goal and tab.key == streams.first.key %}
|
||||
{% if request.user.show_goal and not goal and tab.key == 'home' %}
|
||||
{% now 'Y' as year %}
|
||||
<section class="block">
|
||||
{% include 'snippets/goal_card.html' with year=year %}
|
||||
|
@ -37,7 +37,7 @@
|
|||
<div class="block content">
|
||||
<p>{% trans "There aren't any activities right now! Try following a user to get started" %}</p>
|
||||
|
||||
{% if suggested_users %}
|
||||
{% if request.user.show_suggested_users and suggested_users %}
|
||||
{# suggested users for when things are very lonely #}
|
||||
{% include 'feed/suggested_users.html' with suggested_users=suggested_users %}
|
||||
{% endif %}
|
||||
|
@ -46,7 +46,7 @@
|
|||
|
||||
{% for activity in activities %}
|
||||
|
||||
{% if not activities.number > 1 and forloop.counter0 == 2 and suggested_users %}
|
||||
{% if request.user.show_suggested_users and not activities.number > 1 and forloop.counter0 == 2 and suggested_users %}
|
||||
{# suggested users on the first page, two statuses down #}
|
||||
{% include 'feed/suggested_users.html' with suggested_users=suggested_users %}
|
||||
{% endif %}
|
||||
|
|
|
@ -1,6 +1,15 @@
|
|||
{% load i18n %}
|
||||
<section class="block">
|
||||
<h2 class="title is-5">{% trans "Who to follow" %}</h2>
|
||||
<header class="columns">
|
||||
<div class="column">
|
||||
<h2 class="title is-5">{% trans "Who to follow" %}</h2>
|
||||
</div>
|
||||
<form class="column is-narrow" action="{% url 'hide-suggestions' %}" method="POST">
|
||||
{% csrf_token %}
|
||||
{% trans "Don't show suggested users" as button_text %}
|
||||
<button type="submit" class="delete" title="{{ button_text }}">{{ button_text }}</button>
|
||||
</form>
|
||||
</header>
|
||||
{% include 'snippets/suggested_users.html' with suggested_users=suggested_users %}
|
||||
<a class="help" href="{% url 'directory' %}">{% trans "View directory" %} <span class="icon icon-arrow-right"></span></a>
|
||||
</section>
|
||||
|
|
|
@ -43,9 +43,19 @@
|
|||
</div>
|
||||
<div class="block">
|
||||
<label class="checkbox label" for="id_show_goal">
|
||||
{% trans "Show set reading goal prompt in feed:" %}
|
||||
{% trans "Show reading goal prompt in feed:" %}
|
||||
{{ form.show_goal }}
|
||||
</label>
|
||||
<label class="checkbox label" for="id_show_goal">
|
||||
{% trans "Show suggested users:" %}
|
||||
{{ form.show_suggested_users }}
|
||||
</label>
|
||||
<label class="checkbox label" for="id_discoverable">
|
||||
{% trans "Show this account in suggested users:" %}
|
||||
{{ form.discoverable }}
|
||||
</label>
|
||||
{% url 'directory' as path %}
|
||||
<p class="help">{% blocktrans %}Your account will show up in the <a href="{{ path }}">directory</a>, and may be recommended to other BookWyrm users.{% endblocktrans %}</p>
|
||||
</div>
|
||||
<div class="block">
|
||||
<label class="checkbox label" for="id_manually_approves_followers">
|
||||
|
@ -61,14 +71,6 @@
|
|||
{{ form.default_post_privacy }}
|
||||
</div>
|
||||
</div>
|
||||
<div class="block">
|
||||
<label class="checkbox label" for="id_discoverable">
|
||||
{% trans "Show this account in suggested users:" %}
|
||||
{{ form.discoverable }}
|
||||
</label>
|
||||
{% url 'directory' as path %}
|
||||
<p class="help">{% blocktrans %}Your account will show up in the <a href="{{ path }}">directory</a>, and may be recommended to other BookWyrm users.{% endblocktrans %}</p>
|
||||
</div>
|
||||
<div class="block">
|
||||
<label class="label" for="id_preferred_timezone">{% trans "Preferred Timezone: " %}</label>
|
||||
<div class="select">
|
||||
|
|
|
@ -215,6 +215,7 @@ urlpatterns = [
|
|||
views.Following.as_view(),
|
||||
name="user-following",
|
||||
),
|
||||
re_path(r"^hide-suggestions/?$", views.hide_suggestions, name="hide-suggestions"),
|
||||
# lists
|
||||
re_path(r"%s/lists/?$" % USER_PATH, views.UserLists.as_view(), name="user-lists"),
|
||||
re_path(r"^list/?$", views.Lists.as_view(), name="lists"),
|
||||
|
|
|
@ -43,6 +43,6 @@ from .shelf import shelve, unshelve
|
|||
from .site import Site
|
||||
from .status import CreateStatus, DeleteStatus, DeleteAndRedraft
|
||||
from .updates import get_notification_count, get_unread_status_count
|
||||
from .user import User, Followers, Following
|
||||
from .user import User, Followers, Following, hide_suggestions
|
||||
from .user_admin import UserAdmin, UserAdminList
|
||||
from .wellknown import *
|
||||
|
|
|
@ -1,8 +1,11 @@
|
|||
""" non-interactive pages """
|
||||
from django.contrib.auth.decorators import login_required
|
||||
from django.core.paginator import Paginator
|
||||
from django.shortcuts import redirect
|
||||
from django.template.response import TemplateResponse
|
||||
from django.utils import timezone
|
||||
from django.views import View
|
||||
from django.views.decorators.http import require_POST
|
||||
|
||||
from bookwyrm import models
|
||||
from bookwyrm.activitypub import ActivitypubResponse
|
||||
|
@ -118,3 +121,12 @@ class Following(View):
|
|||
"follow_list": paginated.get_page(request.GET.get("page")),
|
||||
}
|
||||
return TemplateResponse(request, "user/relationships/following.html", data)
|
||||
|
||||
|
||||
@require_POST
|
||||
@login_required
|
||||
def hide_suggestions(request):
|
||||
"""not everyone wants user suggestions"""
|
||||
request.user.show_suggested_users = False
|
||||
request.user.save(broadcast=False, update_fields=["show_suggested_users"])
|
||||
return redirect(request.headers.get("Referer", "/"))
|
||||
|
|
Loading…
Reference in a new issue