mirror of
https://github.com/bookwyrm-social/bookwyrm.git
synced 2024-11-29 04:51:11 +00:00
Remove suggested users on block
This commit is contained in:
parent
9250b8b85d
commit
644e5926db
3 changed files with 18 additions and 7 deletions
|
@ -132,6 +132,16 @@ def update_suggestions_on_follow(sender, instance, created, *args, **kwargs):
|
||||||
suggested_users.rerank_obj(instance.user_object)
|
suggested_users.rerank_obj(instance.user_object)
|
||||||
|
|
||||||
|
|
||||||
|
@receiver(signals.post_save, sender=models.UserBlocks)
|
||||||
|
# pylint: disable=unused-argument
|
||||||
|
def update_suggestions_on_block(sender, instance, *args, **kwargs):
|
||||||
|
"""remove blocked users from recs"""
|
||||||
|
if instance.user_subject.local:
|
||||||
|
suggested_users.remove_suggestion(instance.user_subject, instance.user_object)
|
||||||
|
if instance.user_object.local:
|
||||||
|
suggested_users.remove_suggestion(instance.user_object, instance.user_subject)
|
||||||
|
|
||||||
|
|
||||||
@receiver(signals.post_delete, sender=models.UserFollows)
|
@receiver(signals.post_delete, sender=models.UserFollows)
|
||||||
# pylint: disable=unused-argument
|
# pylint: disable=unused-argument
|
||||||
def update_suggestions_on_unfollow(sender, instance, **kwargs):
|
def update_suggestions_on_unfollow(sender, instance, **kwargs):
|
||||||
|
@ -163,7 +173,7 @@ def add_new_user(sender, instance, created, **kwargs):
|
||||||
# a new user is found, create suggestions for them
|
# a new user is found, create suggestions for them
|
||||||
suggested_users.rerank_user_suggestions(instance)
|
suggested_users.rerank_user_suggestions(instance)
|
||||||
|
|
||||||
# TODO: this happens on every save, not just when discoverability changes
|
# this happens on every save, not just when discoverability changes, annoyingly
|
||||||
if instance.discoverable:
|
if instance.discoverable:
|
||||||
suggested_users.rerank_obj(instance, update_only=False)
|
suggested_users.rerank_obj(instance, update_only=False)
|
||||||
elif not created:
|
elif not created:
|
||||||
|
|
|
@ -9,7 +9,7 @@
|
||||||
<form class="field has-addons" method="get" action="{% url 'get-started-users' %}">
|
<form class="field has-addons" method="get" action="{% url 'get-started-users' %}">
|
||||||
<div class="control">
|
<div class="control">
|
||||||
<input type="text" name="query" value="{{ request.GET.query }}" class="input" placeholder="{% trans 'Search for a user' %}" aria-label="{% trans 'Search for a user' %}">
|
<input type="text" name="query" value="{{ request.GET.query }}" class="input" placeholder="{% trans 'Search for a user' %}" aria-label="{% trans 'Search for a user' %}">
|
||||||
{% if request.GET.query and not user_results %}
|
{% if request.GET.query and no_results %}
|
||||||
<p class="help">{% blocktrans with query=request.GET.query %}No users found for "{{ query }}"{% endblocktrans %}</p>
|
<p class="help">{% blocktrans with query=request.GET.query %}No users found for "{{ query }}"{% endblocktrans %}</p>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -13,6 +13,7 @@ from django.views import View
|
||||||
|
|
||||||
from bookwyrm import forms, models
|
from bookwyrm import forms, models
|
||||||
from bookwyrm.connectors import connector_manager
|
from bookwyrm.connectors import connector_manager
|
||||||
|
from bookwyrm.suggested_users import suggested_users
|
||||||
from .user import save_user_form
|
from .user import save_user_form
|
||||||
|
|
||||||
|
|
||||||
|
@ -117,12 +118,12 @@ class GetStartedUsers(View):
|
||||||
)
|
)
|
||||||
.order_by("-similarity")[:5]
|
.order_by("-similarity")[:5]
|
||||||
)
|
)
|
||||||
|
data = {"no_results": not user_results}
|
||||||
|
|
||||||
if user_results.count() < 5:
|
if user_results.count() < 5:
|
||||||
suggested_users = [] # TODO: get_suggested_users(request.user)
|
user_results = list(user_results) + suggested_users.get_suggestions(
|
||||||
user_results = list(user_results) + list(suggested_users)
|
request.user
|
||||||
|
)
|
||||||
|
|
||||||
data = {
|
data["suggested_users"] = user_results
|
||||||
"suggested_users": user_results,
|
|
||||||
}
|
|
||||||
return TemplateResponse(request, "get_started/users.html", data)
|
return TemplateResponse(request, "get_started/users.html", data)
|
||||||
|
|
Loading…
Reference in a new issue