From cbe172df3d587cb82d772f1a1639095b47c0df79 Mon Sep 17 00:00:00 2001 From: Hugh Rundle Date: Sat, 25 Sep 2021 11:11:58 +1000 Subject: [PATCH] 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 --- bookwyrm/templates/groups/find_users.html | 6 +++ bookwyrm/templates/groups/group.html | 23 ++------- .../templates/groups/suggested_users.html | 42 +++++++++++++++++ bookwyrm/templates/groups/users.html | 41 ++++++++++++++++ .../snippets/add_to_group_button.html | 47 +++++++++++++++++++ 5 files changed, 139 insertions(+), 20 deletions(-) create mode 100644 bookwyrm/templates/groups/find_users.html create mode 100644 bookwyrm/templates/groups/suggested_users.html create mode 100644 bookwyrm/templates/groups/users.html create mode 100644 bookwyrm/templates/snippets/add_to_group_button.html diff --git a/bookwyrm/templates/groups/find_users.html b/bookwyrm/templates/groups/find_users.html new file mode 100644 index 000000000..9154a5275 --- /dev/null +++ b/bookwyrm/templates/groups/find_users.html @@ -0,0 +1,6 @@ +{% extends 'groups/group.html' %} + +{% block panel %} +

Add users to {{ group.name }}

+ {% include 'groups/suggested_users.html' with suggested_users=suggested_users query=query %} +{% endblock %} \ No newline at end of file diff --git a/bookwyrm/templates/groups/group.html b/bookwyrm/templates/groups/group.html index c14694154..a73d78250 100644 --- a/bookwyrm/templates/groups/group.html +++ b/bookwyrm/templates/groups/group.html @@ -7,30 +7,13 @@
- {% if request.GET.updated %} -
- {% trans "You successfully added a user to this group!" %} -
- {% endif %} - {% if not group.members.exists %} -

{% trans "This group has no members" %}

- {% else %} -

Group Members

-
    - {% for member in group.members.all %} -
  • -
    - {% include 'directory/user_card.html' %} -
    -
  • - {% endfor %} -
- {% endif %} + {% include "groups/users.html" %} + +

Lists

{% if not group.lists.exists %}

{% trans "This group has no lists" %}

{% else %} -

Lists

    {% for list in group.lists.all %}
  • diff --git a/bookwyrm/templates/groups/suggested_users.html b/bookwyrm/templates/groups/suggested_users.html new file mode 100644 index 000000000..472841e54 --- /dev/null +++ b/bookwyrm/templates/groups/suggested_users.html @@ -0,0 +1,42 @@ +{% load i18n %} +{% load utilities %} +{% load humanize %} +{% if suggested_users %} +
    + {% for user in suggested_users %} +
    +
    + + {% include 'snippets/avatar.html' with user=user large=True %} + {{ user.display_name|truncatechars:10 }} + @{{ user|username|truncatechars:8 }} + + {% include 'snippets/add_to_group_button.html' with user=user minimal=True %} + {% if user.mutuals %} +

    + {% blocktrans trimmed with mutuals=user.mutuals|intcomma count counter=user.mutuals %} + {{ mutuals }} follower you follow + {% plural %} + {{ mutuals }} followers you follow{% endblocktrans %} +

    + {% elif user.shared_books %} +

    + {% 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 %} +

    + {% elif request.user in user.following.all %} +

    + {% trans "Follows you" %} +

    + {% endif %} +
    +
    + {% endfor %} + {% else %} + No users found for {{ query }} +{% endif %} +
    + diff --git a/bookwyrm/templates/groups/users.html b/bookwyrm/templates/groups/users.html new file mode 100644 index 000000000..c7470b328 --- /dev/null +++ b/bookwyrm/templates/groups/users.html @@ -0,0 +1,41 @@ +{% load i18n %} + +{% if request.GET.updated %} +
    + {% trans "You successfully added a user to this group!" %} +
    +{% endif %} + +

    Group Members

    +

    {% trans "Members can add and remove books on your group's book lists" %}

    + +{% block panel %} +
    +
    +
    + + {% if request.GET.query and no_results %} +

    {% blocktrans with query=request.GET.query %}No users found for "{{ query }}"{% endblocktrans %}

    + {% endif %} +
    +
    + +
    +
    + {% include 'snippets/suggested_users.html' with suggested_users=suggested_users %} +
    +{% endblock %} + +
      +{% for member in group.members.all %} +
    • +
      + {% include 'directory/user_card.html' %} +
      +
    • +{% endfor %} +
    \ No newline at end of file diff --git a/bookwyrm/templates/snippets/add_to_group_button.html b/bookwyrm/templates/snippets/add_to_group_button.html new file mode 100644 index 000000000..51c3179be --- /dev/null +++ b/bookwyrm/templates/snippets/add_to_group_button.html @@ -0,0 +1,47 @@ +{% load i18n %} +{% if request.user == user or not request.user.is_authenticated %} + +{% elif user in request.user.blocks.all %} +{% include 'snippets/block_button.html' with blocks=True %} +{% else %} + +
    +
    + + + + +
    + {% if not minimal %} +
    + {% include 'snippets/user_options.html' with user=user class="is-small" %} +
    + {% endif %} +
    +{% endif %}