Merge pull request #849 from mouse-reeve/ui-small-fixes

UI small fixes
This commit is contained in:
Mouse Reeve 2021-04-02 07:37:31 -07:00 committed by GitHub
commit 6211e66a5e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
14 changed files with 53 additions and 41 deletions

View file

@ -71,6 +71,7 @@ class Status(OrderedCollectionPageMixin, BookWyrmModel):
if self.deleted:
notification_model.objects.filter(related_status=self).delete()
return
if (
self.reply_parent

View file

@ -3,7 +3,7 @@
{% load humanize %}
<div class="columns is-mobile scroll-x mb-0">
{% for user in suggested_users %}
<div class="column is-flex">
<div class="column is-flex is-flex-grow-0">
<div class="box has-text-centered is-shadowless has-background-white-bis m-0">
<a href="{{ user.local_path }}" class="has-text-black">
{% include 'snippets/avatar.html' with user=user large=True %}

View file

@ -87,11 +87,6 @@
{% trans "Direct Messages" %}
</a>
</li>
<li>
<a href="{{ request.user.local_path }}" class="navbar-item">
{% trans 'Profile' %}
</a>
</li>
<li>
<a href="{% url 'directory' %}" class="navbar-item">
{% trans 'Directory' %}

View file

@ -79,6 +79,8 @@
{# accepted #}
{% if req.invite.invitees.exists %}
<a href="{{ req.invite.invitees.first.local_path }}">@{{ req.invite.invitees.first.localname }}</a>
{% else %}
&nbsp;
{% endif %}
{% else %}
<form name="ignore-request" method="post" action="{% url 'settings-invite-requests-ignore' %}">

View file

@ -0,0 +1,7 @@
{% load humanize %}
{% load i18n %}
{% if total_pages %}
{% blocktrans with page=page|intcomma total_pages=total_pages|intcomma %}page {{ page }} of {{ total_pages }}{% endblocktrans %}
{% else %}
{% blocktrans with page=page|intcomma %}page {{ page }}{% endblocktrans %}
{% endif %}

View file

@ -9,8 +9,18 @@
</dl>
<ul>
{% if readthrough.finish_date or readthrough.progress %}
<li>{% if readthrough.finish_date %} {{ readthrough.finish_date | localtime | naturalday }}: {% trans "finished" %} {% else %}{% if readthrough.progress_mode == 'PG' %}on page {{ readthrough.progress }}{% if book.pages %} of {{ book.pages }}{% endif %}
{% else %}{{ readthrough.progress }}%{% endif %}{% endif %}
<li>
{% if readthrough.finish_date %}
{{ readthrough.finish_date | localtime | naturalday }}: {% trans "finished" %}
{% else %}
{% if readthrough.progress_mode == 'PG' %}
{% include 'snippets/page_text.html' with page=readthrough.progress total_pages=book.pages %}
{% else %}
{{ readthrough.progress }}%
{% endif %}
{% endif %}
{% if readthrough.progress %}
{% trans "Show all updates" as button_text %}
{% include 'snippets/toggle/toggle_button.html' with text=button_text controls_text="updates" controls_uid=readthrough.id class="is-small" %}
@ -21,7 +31,7 @@
{% csrf_token %}
{{ progress_update.created_date | naturalday }}:
{% if progress_update.mode == 'PG' %}
page {{ progress_update.progress }} of {{ book.pages }}
{% include 'snippets/page_text.html' with page=progress_update.progress total_pages=book.pages %}
{% else %}
{{ progress_update.progress }}%
{% endif %}

View file

@ -7,17 +7,15 @@
{% block dropdown-list %}
{% for shelf in request.user.shelf_set.all %}
{% if shelf.identifier != current.identifier %}
<li role="menuitem">
<form class="dropdown-item pt-0 pb-0" name="shelve" action="/shelve/" method="post">
{% csrf_token %}
<input type="hidden" name="book" value="{{ book.id }}">
<input type="hidden" name="change-shelf-from" value="{{ current.identifier }}">
<input type="hidden" name="shelf" value="{{ shelf.identifier }}">
<button class="button is-fullwidth is-small" type="submit">{{ shelf.name }}</button>
<button class="button is-fullwidth is-small shelf-option" type="submit" {% if shelf.identifier == current.identifier %}disabled{% endif %}><span>{{ shelf.name }}</span></button>
</form>
</li>
{% endif %}
{% endfor %}
<li class="navbar-divider" role="presentation"></li>
<li>

View file

@ -38,6 +38,6 @@
{% if status.progress %}
<p class="help">
({% if status.progress_mode == 'PG' %}page {{ status.progress }}{%else %}{{ status.progress }}%{% endif %})
({% if status.progress_mode == 'PG' %}{% include 'snippets/page_text.html' with page=status.progress total_pages=status.book.pages %}{% else %}{{ status.progress }}%{% endif %})
</p>
{% endif %}

View file

@ -111,12 +111,14 @@
{% endif %}
{% if shelf.user == request.user %}
<td>
{% with right=True %}
{% if not shelf.id %}
{% active_shelf book as current %}
{% include 'snippets/shelf_selector.html' with current=current.shelf class="is-small" %}
{% else %}
{% include 'snippets/shelf_selector.html' with current=shelf class="is-small" %}
{% endif %}
{% endwith %}
</td>
{% endif %}
</tr>

View file

@ -247,7 +247,7 @@ class ViewsHelpers(TestCase):
)
self.assertFalse(views.helpers.object_visible_to_user(self.local_user, obj))
def test_get_suggested_users(self, _):
def test_get_annotated_users(self, _):
""" list of people you might know """
user_1 = models.User.objects.create_user(
"nutria@local.com",
@ -279,7 +279,7 @@ class ViewsHelpers(TestCase):
user=user_1, book=self.book, shelf=user_1.shelf_set.first()
)
result = views.helpers.get_suggested_users(self.local_user)
result = views.helpers.get_annotated_users(self.local_user)
self.assertEqual(result.count(), 3)
self.assertTrue(user_1 in result)
self.assertFalse(user_2 in result)
@ -294,7 +294,7 @@ class ViewsHelpers(TestCase):
self.assertEqual(remote_user_annotated.mutuals, 0)
self.assertEqual(remote_user_annotated.shared_books, 0)
def test_get_suggested_users_counts(self, _):
def test_get_annotated_users_counts(self, _):
""" correct counting for multiple shared attributed """
user_1 = models.User.objects.create_user(
"nutria@local.com",
@ -330,7 +330,7 @@ class ViewsHelpers(TestCase):
user=user_1, book=book, shelf=user_1.shelf_set.first()
)
result = views.helpers.get_suggested_users(
result = views.helpers.get_annotated_users(
self.local_user,
~Q(id=self.local_user.id),
~Q(followers=self.local_user),

View file

@ -6,7 +6,7 @@ from django.template.response import TemplateResponse
from django.views import View
from django.utils.decorators import method_decorator
from .helpers import get_suggested_users
from .helpers import get_annotated_users
# pylint: disable=no-self-use
@method_decorator(login_required, name="dispatch")
@ -29,7 +29,7 @@ class Directory(View):
if scope == "local":
filters["local"] = True
users = get_suggested_users(request.user, **filters)
users = get_annotated_users(request.user, **filters)
sort = request.GET.get("sort")
if sort == "recent":
users = users.order_by("-last_active_date")

View file

@ -34,16 +34,7 @@ class Feed(View):
paginated = Paginator(activities, PAGE_LENGTH)
suggested_users = (
get_suggested_users(
request.user,
~Q(id=request.user.id),
~Q(followers=request.user),
bookwyrm_user=True,
)
.order_by("-mutuals", "-last_active_date")
.all()[:5]
)
suggested_users = get_suggested_users(request.user)
data = {
**feed_page_data(request.user),

View file

@ -120,17 +120,8 @@ class GetStartedUsers(View):
)
if user_results.count() < 5:
suggested_users = (
get_suggested_users(
request.user,
~Q(id=request.user.id),
~Q(followers=request.user),
~Q(id__in=user_results),
bookwyrm_user=True,
)
.order_by("shared_books", "-mutuals", "-last_active_date")
.all()[: 5 - user_results.count()]
)
suggested_users = get_suggested_users(request.user)
data = {
"suggested_users": list(user_results) + list(suggested_users),
}

View file

@ -192,7 +192,22 @@ def get_discover_books():
)
def get_suggested_users(user, *args, **kwargs):
def get_suggested_users(user):
""" bookwyrm users you don't already know """
return (
get_annotated_users(
user,
~Q(id=user.id),
~Q(followers=user),
~Q(follower_requests=user),
bookwyrm_user=True,
)
.order_by("-mutuals", "-last_active_date")
.all()[:5]
)
def get_annotated_users(user, *args, **kwargs):
""" Users, annotated with things they have in common """
return (
models.User.objects.filter(discoverable=True, is_active=True, *args, **kwargs)