forked from mirrors/bookwyrm
find users for groups
- search for users to add to a group - display suggested users on search results screen TODO: actaully enable users to be added! TODO: groups/suggested_users probably could be replaced with some logic in snippets/suggested_users.html
This commit is contained in:
parent
8c326ec52f
commit
cbe172df3d
5 changed files with 139 additions and 20 deletions
6
bookwyrm/templates/groups/find_users.html
Normal file
6
bookwyrm/templates/groups/find_users.html
Normal file
|
@ -0,0 +1,6 @@
|
|||
{% extends 'groups/group.html' %}
|
||||
|
||||
{% block panel %}
|
||||
<h1 class="title">Add users to <a href="{{ group.local_path }}">{{ group.name }}</a></h1>
|
||||
{% include 'groups/suggested_users.html' with suggested_users=suggested_users query=query %}
|
||||
{% endblock %}
|
|
@ -7,30 +7,13 @@
|
|||
|
||||
<div class="columns mt-3">
|
||||
<section class="column is-three-quarters">
|
||||
{% if request.GET.updated %}
|
||||
<div class="notification is-primary">
|
||||
{% trans "You successfully added a user to this group!" %}
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
{% if not group.members.exists %}
|
||||
<p>{% trans "This group has no members" %}</p>
|
||||
{% else %}
|
||||
<h2 class="heading">Group Members</h2>
|
||||
<ul start="{{ members.start_index }}" class="ordered-list">
|
||||
{% for member in group.members.all %}
|
||||
<li class="block mb-5">
|
||||
<div class="column is-one-third">
|
||||
{% include 'directory/user_card.html' %}
|
||||
</div>
|
||||
</li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
{% endif %}
|
||||
{% include "groups/users.html" %}
|
||||
|
||||
<h2 class="heading">Lists</h2>
|
||||
{% if not group.lists.exists %}
|
||||
<p>{% trans "This group has no lists" %}</p>
|
||||
{% else %}
|
||||
<h2 class="heading">Lists</h2>
|
||||
<ul start="{{ lists.start_index }}" class="ordered-list">
|
||||
{% for list in group.lists.all %}
|
||||
<li class="block mb-5">
|
||||
|
|
42
bookwyrm/templates/groups/suggested_users.html
Normal file
42
bookwyrm/templates/groups/suggested_users.html
Normal file
|
@ -0,0 +1,42 @@
|
|||
{% load i18n %}
|
||||
{% load utilities %}
|
||||
{% load humanize %}
|
||||
{% if suggested_users %}
|
||||
<div class="columns is-mobile scroll-x mb-0">
|
||||
{% for user in suggested_users %}
|
||||
<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 %}
|
||||
<span title="{{ user.display_name }}" class="is-block is-6 has-text-weight-bold">{{ user.display_name|truncatechars:10 }}</span>
|
||||
<span title="@{{ user|username }}" class="is-block pb-3">@{{ user|username|truncatechars:8 }}</span>
|
||||
</a>
|
||||
{% include 'snippets/add_to_group_button.html' with user=user minimal=True %}
|
||||
{% if user.mutuals %}
|
||||
<p class="help">
|
||||
{% blocktrans trimmed with mutuals=user.mutuals|intcomma count counter=user.mutuals %}
|
||||
{{ mutuals }} follower you follow
|
||||
{% plural %}
|
||||
{{ mutuals }} followers you follow{% endblocktrans %}
|
||||
</p>
|
||||
{% elif user.shared_books %}
|
||||
<p class="help">
|
||||
{% blocktrans trimmed with shared_books=user.shared_books|intcomma count counter=user.shared_books %}
|
||||
{{ shared_books }} book on your shelves
|
||||
{% plural %}
|
||||
{{ shared_books }} books on your shelves
|
||||
{% endblocktrans %}
|
||||
</p>
|
||||
{% elif request.user in user.following.all %}
|
||||
<p class="help">
|
||||
{% trans "Follows you" %}
|
||||
</p>
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
{% endfor %}
|
||||
{% else %}
|
||||
No users found for {{ query }}
|
||||
{% endif %}
|
||||
</div>
|
||||
|
41
bookwyrm/templates/groups/users.html
Normal file
41
bookwyrm/templates/groups/users.html
Normal file
|
@ -0,0 +1,41 @@
|
|||
{% load i18n %}
|
||||
|
||||
{% if request.GET.updated %}
|
||||
<div class="notification is-primary">
|
||||
{% trans "You successfully added a user to this group!" %}
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
<h2 class="heading">Group Members</h2>
|
||||
<p class="subtitle is-6">{% trans "Members can add and remove books on your group's book lists" %}</p>
|
||||
|
||||
{% block panel %}
|
||||
<div class="block">
|
||||
<form class="field has-addons" method="get" action="{% url 'group-find-users' group.id %}">
|
||||
<div class="control">
|
||||
<input type="text" name="query" value="{{ request.GET.query }}" class="input" placeholder="{% trans 'Search to add a user' %}" aria-label="{% trans 'Search to add a user' %}">
|
||||
{% if request.GET.query and no_results %}
|
||||
<p class="help">{% blocktrans with query=request.GET.query %}No users found for "{{ query }}"{% endblocktrans %}</p>
|
||||
{% endif %}
|
||||
</div>
|
||||
<div class="control">
|
||||
<button class="button" type="submit">
|
||||
<span class="icon icon-search" title="{% trans 'Search' %}">
|
||||
<span class="is-sr-only">{% trans "Search" %}</span>
|
||||
</span>
|
||||
</button>
|
||||
</div>
|
||||
</form>
|
||||
{% include 'snippets/suggested_users.html' with suggested_users=suggested_users %}
|
||||
</div>
|
||||
{% endblock %}
|
||||
|
||||
<ul start="{{ members.start_index }}" class="ordered-list">
|
||||
{% for member in group.members.all %}
|
||||
<li class="block mb-5">
|
||||
<div class="column is-one-third">
|
||||
{% include 'directory/user_card.html' %}
|
||||
</div>
|
||||
</li>
|
||||
{% endfor %}
|
||||
</ul>
|
47
bookwyrm/templates/snippets/add_to_group_button.html
Normal file
47
bookwyrm/templates/snippets/add_to_group_button.html
Normal file
|
@ -0,0 +1,47 @@
|
|||
{% load i18n %}
|
||||
{% if request.user == user or not request.user.is_authenticated %}
|
||||
<!-- TODO: blocking is irrelevant here, but ...is it? -->
|
||||
{% elif user in request.user.blocks.all %}
|
||||
{% include 'snippets/block_button.html' with blocks=True %}
|
||||
{% else %}
|
||||
|
||||
<div class="field{% if not minimal %} has-addons{% else %} mb-0{% endif %}">
|
||||
<div class="control">
|
||||
<!-- TODO: make this "add-to-group" -->
|
||||
<form action="{% url 'follow' %}" method="POST" class="interaction follow_{{ user.id }} {% if request.user in user.followers.all or request.user in user.follower_requests.all %}is-hidden{%endif %}" data-id="follow_{{ user.id }}">
|
||||
{% csrf_token %}
|
||||
<input type="hidden" name="user" value="{{ user.username }}">
|
||||
<button class="button is-small{% if not minimal %} is-link{% endif %}" type="submit">
|
||||
{% if show_username %}
|
||||
{% blocktrans with username=user.localname %}Follow @{{ username }}{% endblocktrans %}
|
||||
{% else %}
|
||||
{% trans "Follow" %}
|
||||
{% endif %}
|
||||
</button>
|
||||
</form>
|
||||
<!-- TODO: make this "remove-from-group" -->
|
||||
<form action="{% url 'unfollow' %}" method="POST" class="interaction follow_{{ user.id }} {% if not request.user in user.followers.all and not request.user in user.follower_requests.all %}is-hidden{%endif %}" data-id="follow_{{ user.id }}">
|
||||
{% csrf_token %}
|
||||
<input type="hidden" name="user" value="{{ user.username }}">
|
||||
{% if user.manually_approves_followers and request.user not in user.followers.all %}
|
||||
<button class="button is-small is-danger is-light" type="submit">
|
||||
{% trans "Undo follow request" %}
|
||||
</button>
|
||||
{% else %}
|
||||
<button class="button is-small is-danger is-light" type="submit">
|
||||
{% if show_username %}
|
||||
{% blocktrans with username=user.localname %}Unfollow @{{ username }}{% endblocktrans %}
|
||||
{% else %}
|
||||
{% trans "Unfollow" %}
|
||||
{% endif %}
|
||||
</button>
|
||||
{% endif %}
|
||||
</form>
|
||||
</div>
|
||||
{% if not minimal %}
|
||||
<div class="control">
|
||||
{% include 'snippets/user_options.html' with user=user class="is-small" %}
|
||||
</div>
|
||||
{% endif %}
|
||||
</div>
|
||||
{% endif %}
|
Loading…
Reference in a new issue