mirror of
https://github.com/bookwyrm-social/bookwyrm.git
synced 2024-11-13 20:31:00 +00:00
View to hide suggestions
This commit is contained in:
parent
bb29f33ca8
commit
527c0542af
5 changed files with 26 additions and 4 deletions
|
@ -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>
|
||||
|
|
|
@ -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