From 86a60d58e5284df5d7ab5bc20ba8ebd673936467 Mon Sep 17 00:00:00 2001 From: Hugh Rundle Date: Fri, 24 Sep 2021 21:24:06 +1000 Subject: [PATCH] add user cards to group pages --- bookwyrm/templates/groups/group.html | 27 +++++++++++++++++++++------ bookwyrm/views/group.py | 15 ++------------- 2 files changed, 23 insertions(+), 19 deletions(-) diff --git a/bookwyrm/templates/groups/group.html b/bookwyrm/templates/groups/group.html index a8d65f7f..01a10a39 100644 --- a/bookwyrm/templates/groups/group.html +++ b/bookwyrm/templates/groups/group.html @@ -13,19 +13,34 @@ {% endif %} - {% if not members.object_list.exists %} + {% if not group.members.exists %}

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

{% else %} -
    - {% for member in members %} +

    Group Members

    + + {% endif %} + {% if not group.lists.exists %} +

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

    + {% else %} +

    Lists

    +
+ {% endif %} {% include "snippets/pagination.html" with page=items %} diff --git a/bookwyrm/views/group.py b/bookwyrm/views/group.py index ba5c251a..59d3e8d1 100644 --- a/bookwyrm/views/group.py +++ b/bookwyrm/views/group.py @@ -41,17 +41,6 @@ class Group(View): } return TemplateResponse(request, "groups/group.html", data) - # @method_decorator(login_required, name="dispatch") - # # pylint: disable=unused-argument - # def post(self, request): - # """create a book_list""" - # form = forms.ListForm(request.POST) - # if not form.is_valid(): - # return redirect("lists") - # book_list = form.save() - - # return redirect(book_list.local_path) - @method_decorator(login_required, name="dispatch") class UserGroups(View): """a user's groups page""" @@ -59,9 +48,7 @@ class UserGroups(View): def get(self, request, username): """display a group""" user = get_user_from_username(request.user, username) - # groups = models.GroupMember.objects.filter(user=user) groups = models.Group.objects.filter(members=user) - # groups = privacy_filter(request.user, groups) paginated = Paginator(groups, 12) data = { @@ -83,4 +70,6 @@ def create_group(request): return redirect(request.headers.get("Referer", "/")) group = form.save() + # TODO: add user as group member + models.GroupMember.objects.create(group=group, user=request.user) return redirect(group.local_path) \ No newline at end of file