From 1603df0817a50dcf0ad1de5e322d668518941327 Mon Sep 17 00:00:00 2001
From: Hugh Rundle
Date: Sun, 19 Dec 2021 14:19:35 +1100
Subject: [PATCH 1/6] add "Create list" form to group template
---
bookwyrm/templates/groups/layout.html | 17 +++++++++++++----
bookwyrm/templates/lists/create_form.html | 2 +-
bookwyrm/templates/lists/form.html | 10 +++++-----
bookwyrm/views/group.py | 1 +
4 files changed, 20 insertions(+), 10 deletions(-)
diff --git a/bookwyrm/templates/groups/layout.html b/bookwyrm/templates/groups/layout.html
index f558f169..619c89ee 100644
--- a/bookwyrm/templates/groups/layout.html
+++ b/bookwyrm/templates/groups/layout.html
@@ -11,13 +11,22 @@
{% include 'groups/created_text.html' with group=group %}
+ {% if request.user == group.user %}
- {% if request.user == group.user %}
- {% trans "Edit group" as button_text %}
- {% include 'snippets/toggle/open_button.html' with text=button_text icon_with_text="pencil" controls_text="edit_group" focus="edit_group_header" %}
- {% endif %}
+ {% trans "Create List" as button_text %}
+ {% include 'snippets/toggle/open_button.html' with controls_text="create_list" icon_with_text="plus" text=button_text focus="create_list_header" %}
+
+ {% trans "Edit group" as button_text %}
+ {% include 'snippets/toggle/open_button.html' with text=button_text icon_with_text="pencil" controls_text="edit_group" focus="edit_group_header" %}
+
+ {% endif %}
+{% if request.user.is_authenticated %}
+
+ {% include 'lists/create_form.html' with controls_text="create_list" curation_group=group %}
+
+{% endif %}
{% include 'snippets/trimmed_text.html' with full=group.description %}
diff --git a/bookwyrm/templates/lists/create_form.html b/bookwyrm/templates/lists/create_form.html
index 447c0f6b..a1bda591 100644
--- a/bookwyrm/templates/lists/create_form.html
+++ b/bookwyrm/templates/lists/create_form.html
@@ -7,6 +7,6 @@
{% block form %}
{% endblock %}
diff --git a/bookwyrm/templates/lists/form.html b/bookwyrm/templates/lists/form.html
index 25dc01e6..d2248853 100644
--- a/bookwyrm/templates/lists/form.html
+++ b/bookwyrm/templates/lists/form.html
@@ -19,7 +19,7 @@
{% trans "List curation:" %}
- {% trans "Closed" %}
+ {% trans "Closed" %}
{% trans "Only you can add and remove books to this list" %}
@@ -34,17 +34,17 @@
- {% trans "Group" %}
+ {% trans "Group" %}
{% trans "Group members can add to and remove from this list" %}
-
+
{% if user.memberships.exists %}
{% trans "Select Group" %}
- {% trans "Select a group" %}
+ {% trans "Select a group" %}
{% for membership in user.memberships.all %}
- {{ membership.group.name }}
+ {{ membership.group.name }}
{% endfor %}
diff --git a/bookwyrm/views/group.py b/bookwyrm/views/group.py
index f375ac84..6f1d7596 100644
--- a/bookwyrm/views/group.py
+++ b/bookwyrm/views/group.py
@@ -35,6 +35,7 @@ class Group(View):
"group": group,
"lists": lists,
"group_form": forms.GroupForm(instance=group),
+ "list_form": forms.ListForm(),
"path": "/group",
}
return TemplateResponse(request, "groups/group.html", data)
From b1fa57d2cad30b5836146b63fba4916e512b00aa Mon Sep 17 00:00:00 2001
From: Hugh Rundle
Date: Sun, 2 Jan 2022 09:08:04 +1100
Subject: [PATCH 2/6] fix group form ids
Also adds the List form to the group FindUsers view
---
bookwyrm/templates/groups/form.html | 4 ++--
bookwyrm/views/group.py | 5 +++--
2 files changed, 5 insertions(+), 4 deletions(-)
diff --git a/bookwyrm/templates/groups/form.html b/bookwyrm/templates/groups/form.html
index 21c525ee..d51c683a 100644
--- a/bookwyrm/templates/groups/form.html
+++ b/bookwyrm/templates/groups/form.html
@@ -5,11 +5,11 @@
- {% trans "Group Name:" %}
+ {% trans "Group Name:" %}
{{ group_form.name }}
- {% trans "Group Description:" %}
+ {% trans "Group Description:" %}
{{ group_form.description }}
diff --git a/bookwyrm/views/group.py b/bookwyrm/views/group.py
index 6f1d7596..6762fc19 100644
--- a/bookwyrm/views/group.py
+++ b/bookwyrm/views/group.py
@@ -34,7 +34,7 @@ class Group(View):
data = {
"group": group,
"lists": lists,
- "group_form": forms.GroupForm(instance=group),
+ "group_form": forms.GroupForm(instance=group,auto_id='group_form_id_%s'),
"list_form": forms.ListForm(),
"path": "/group",
}
@@ -153,7 +153,8 @@ class FindUsers(View):
data = {
"suggested_users": user_results,
"group": group,
- "group_form": forms.GroupForm(instance=group),
+ "group_form": forms.GroupForm(instance=group,auto_id='group_form_id_%s'),
+ "list_form": forms.ListForm(),
"user_query": user_query,
"requestor_is_manager": request.user == group.user,
}
From 045506d6e0400ea3a03f7bc862cec453987df75a Mon Sep 17 00:00:00 2001
From: Hugh Rundle
Date: Sun, 2 Jan 2022 10:06:02 +1100
Subject: [PATCH 3/6] show group lists on group FindUsers page
---
bookwyrm/views/group.py | 9 ++++++++-
1 file changed, 8 insertions(+), 1 deletion(-)
diff --git a/bookwyrm/views/group.py b/bookwyrm/views/group.py
index 6762fc19..c90cc2ac 100644
--- a/bookwyrm/views/group.py
+++ b/bookwyrm/views/group.py
@@ -122,6 +122,11 @@ class FindUsers(View):
"""basic profile info"""
user_query = request.GET.get("user_query")
group = get_object_or_404(models.Group, id=group_id)
+ lists = (
+ models.List.privacy_filter(request.user)
+ .filter(group=group)
+ .order_by("-updated_date")
+ )
if not group:
return HttpResponseBadRequest()
@@ -143,7 +148,7 @@ class FindUsers(View):
.filter(similarity__gt=0.5, local=True)
.order_by("-similarity")[:5]
)
- data = {"no_results": not user_results}
+ no_results = not user_results
if user_results.count() < 5:
user_results = list(user_results) + suggested_users.get_suggestions(
@@ -152,7 +157,9 @@ class FindUsers(View):
data = {
"suggested_users": user_results,
+ "no_results": no_results,
"group": group,
+ "lists": lists,
"group_form": forms.GroupForm(instance=group,auto_id='group_form_id_%s'),
"list_form": forms.ListForm(),
"user_query": user_query,
From c73491b05c7dac5ec7a957df37d122dc63b5c04c Mon Sep 17 00:00:00 2001
From: Hugh Rundle
Date: Sun, 2 Jan 2022 10:06:59 +1100
Subject: [PATCH 4/6] Show add list button to group members
---
bookwyrm/templates/groups/layout.html | 14 +++++++++-----
1 file changed, 9 insertions(+), 5 deletions(-)
diff --git a/bookwyrm/templates/groups/layout.html b/bookwyrm/templates/groups/layout.html
index 619c89ee..99c69f1c 100644
--- a/bookwyrm/templates/groups/layout.html
+++ b/bookwyrm/templates/groups/layout.html
@@ -1,5 +1,6 @@
{% extends 'layout.html' %}
{% load i18n %}
+{% load bookwyrm_group_tags %}
{% block title %}{{ group.name }}{% endblock %}
@@ -11,27 +12,30 @@
{% include 'groups/created_text.html' with group=group %}
- {% if request.user == group.user %}
+ {% if group|is_member:request.user %}
{% trans "Create List" as button_text %}
{% include 'snippets/toggle/open_button.html' with controls_text="create_list" icon_with_text="plus" text=button_text focus="create_list_header" %}
+ {% endif %}
+ {% if request.user == group.user %}
{% trans "Edit group" as button_text %}
{% include 'snippets/toggle/open_button.html' with text=button_text icon_with_text="pencil" controls_text="edit_group" focus="edit_group_header" %}
{% endif %}
+
+
+ {% include 'snippets/trimmed_text.html' with full=group.description %}
+
+
{% if request.user.is_authenticated %}
{% include 'lists/create_form.html' with controls_text="create_list" curation_group=group %}
{% endif %}
-
- {% include 'snippets/trimmed_text.html' with full=group.description %}
-
-
{% include 'groups/edit_form.html' with controls_text="edit_group" %}
From 38bd1f46d62f18e80d37a66ada7c61f1fed5ca98 Mon Sep 17 00:00:00 2001
From: Hugh Rundle
Date: Sun, 2 Jan 2022 10:19:57 +1100
Subject: [PATCH 5/6] emblacken
---
bookwyrm/views/group.py | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/bookwyrm/views/group.py b/bookwyrm/views/group.py
index c90cc2ac..cbdae0d2 100644
--- a/bookwyrm/views/group.py
+++ b/bookwyrm/views/group.py
@@ -34,7 +34,7 @@ class Group(View):
data = {
"group": group,
"lists": lists,
- "group_form": forms.GroupForm(instance=group,auto_id='group_form_id_%s'),
+ "group_form": forms.GroupForm(instance=group, auto_id="group_form_id_%s"),
"list_form": forms.ListForm(),
"path": "/group",
}
@@ -160,7 +160,7 @@ class FindUsers(View):
"no_results": no_results,
"group": group,
"lists": lists,
- "group_form": forms.GroupForm(instance=group,auto_id='group_form_id_%s'),
+ "group_form": forms.GroupForm(instance=group, auto_id="group_form_id_%s"),
"list_form": forms.ListForm(),
"user_query": user_query,
"requestor_is_manager": request.user == group.user,
From ea08b302c9f1cb8ae5f9080d013b4291875d7e35 Mon Sep 17 00:00:00 2001
From: Hugh Rundle
Date: Mon, 3 Jan 2022 10:09:52 +1100
Subject: [PATCH 6/6] improve group page layout
- move 'Add list' button down to the group lists
- move member search box underneath members heading
- note about members being able to create lists is now under lists heading
---
bookwyrm/templates/groups/find_users.html | 3 -
bookwyrm/templates/groups/group.html | 67 ++++++++++---------
bookwyrm/templates/groups/layout.html | 12 ----
bookwyrm/templates/groups/members.html | 18 ++++-
.../templates/groups/suggested_users.html | 3 +
5 files changed, 53 insertions(+), 50 deletions(-)
diff --git a/bookwyrm/templates/groups/find_users.html b/bookwyrm/templates/groups/find_users.html
index 377e3a0b..1b0d5433 100644
--- a/bookwyrm/templates/groups/find_users.html
+++ b/bookwyrm/templates/groups/find_users.html
@@ -2,8 +2,5 @@
{% load i18n %}
{% block searchresults %}
-
- {% trans "Add new members!" %}
-
{% include 'groups/suggested_users.html' with suggested_users=suggested_users %}
{% endblock %}
diff --git a/bookwyrm/templates/groups/group.html b/bookwyrm/templates/groups/group.html
index f25a1f27..1a71bda8 100644
--- a/bookwyrm/templates/groups/group.html
+++ b/bookwyrm/templates/groups/group.html
@@ -1,37 +1,41 @@
{% extends 'groups/layout.html' %}
{% load i18n %}
{% load bookwyrm_tags %}
+{% load bookwyrm_group_tags %}
{% load markdown %}
{% block panel %}
-
- {% if group.user == request.user %}
-
- {% endif %}
-
{% block searchresults %}
{% endblock %}
{% include "groups/members.html" with group=group %}
-
- Lists
+
+
+
+
+
{% trans "Lists" %}
+
+ {% trans "Members of this group can create group-curated lists." %}
+
+
+ {% if request.user.is_authenticated and group|is_member:request.user %}
+
+ {% trans "Create List" as button_text %}
+ {% include 'snippets/toggle/open_button.html' with controls_text="create_list" icon_with_text="plus" text=button_text focus="create_list_header" %}
+
+ {% endif %}
+
+{% if request.user.is_authenticated and group|is_member:request.user %}
+
+ {% include 'lists/create_form.html' with controls_text="create_list" curation_group=group %}
+
+{% endif %}
+
+
{% if not lists %}
{% trans "This group has no lists" %}
{% else %}
@@ -45,19 +49,17 @@
{{ list.name }} {% include 'snippets/privacy-icons.html' with item=list %}
-
{% with list_books=list.listitem_set.all|slice:5 %}
- {% if list_books %}
-
- {% endif %}
+ {% if list_books %}
+
+ {% endif %}
{% endwith %}
-
{% if list.description %}
@@ -74,9 +76,8 @@
{% endfor %}
-
{% endif %}
- {% include "snippets/pagination.html" with page=items %}
+
{% endblock %}
diff --git a/bookwyrm/templates/groups/layout.html b/bookwyrm/templates/groups/layout.html
index 99c69f1c..a25c1085 100644
--- a/bookwyrm/templates/groups/layout.html
+++ b/bookwyrm/templates/groups/layout.html
@@ -12,12 +12,6 @@
{% include 'groups/created_text.html' with group=group %}
- {% if group|is_member:request.user %}
-
- {% trans "Create List" as button_text %}
- {% include 'snippets/toggle/open_button.html' with controls_text="create_list" icon_with_text="plus" text=button_text focus="create_list_header" %}
-
- {% endif %}
{% if request.user == group.user %}
{% trans "Edit group" as button_text %}
@@ -30,12 +24,6 @@
{% include 'snippets/trimmed_text.html' with full=group.description %}
-{% if request.user.is_authenticated %}
-
- {% include 'lists/create_form.html' with controls_text="create_list" curation_group=group %}
-
-{% endif %}
-
{% include 'groups/edit_form.html' with controls_text="edit_group" %}
diff --git a/bookwyrm/templates/groups/members.html b/bookwyrm/templates/groups/members.html
index 719674d8..8b06d178 100644
--- a/bookwyrm/templates/groups/members.html
+++ b/bookwyrm/templates/groups/members.html
@@ -5,8 +5,22 @@
{% load bookwyrm_group_tags %}
Group Members
-{% trans "Members can add and remove books on a group's book lists" %}
-
+{% if group.user == request.user %}
+
+{% endif %}
{% if group.user != request.user and group|is_member:request.user %}