From 9b6d2a9d88b8280527a284a071a6406f7f212532 Mon Sep 17 00:00:00 2001 From: Hugh Rundle Date: Fri, 24 Sep 2021 20:34:11 +1000 Subject: [PATCH] add group page --- bookwyrm/forms.py | 2 +- bookwyrm/templates/groups/create_form.html | 13 ----- bookwyrm/templates/groups/created_text.html | 6 +++ .../templates/groups/delete_group_modal.html | 21 ++++++++ bookwyrm/templates/groups/edit_form.html | 13 +++++ bookwyrm/templates/groups/form.html | 5 +- bookwyrm/templates/groups/layout.html | 32 +++++++++++++ bookwyrm/templates/user/groups.html | 2 +- bookwyrm/urls.py | 7 ++- bookwyrm/views/__init__.py | 2 +- bookwyrm/views/group.py | 48 ++++++++++++------- 11 files changed, 112 insertions(+), 39 deletions(-) delete mode 100644 bookwyrm/templates/groups/create_form.html create mode 100644 bookwyrm/templates/groups/created_text.html create mode 100644 bookwyrm/templates/groups/delete_group_modal.html create mode 100644 bookwyrm/templates/groups/edit_form.html create mode 100644 bookwyrm/templates/groups/layout.html diff --git a/bookwyrm/forms.py b/bookwyrm/forms.py index ceff1b2a..0987924e 100644 --- a/bookwyrm/forms.py +++ b/bookwyrm/forms.py @@ -298,7 +298,7 @@ class ListForm(CustomForm): class GroupForm(CustomForm): class Meta: model = models.Group - fields = ["name", "description", "privacy"] + fields = ["manager", "privacy", "name", "description"] class ReportForm(CustomForm): class Meta: diff --git a/bookwyrm/templates/groups/create_form.html b/bookwyrm/templates/groups/create_form.html deleted file mode 100644 index 103ce223..00000000 --- a/bookwyrm/templates/groups/create_form.html +++ /dev/null @@ -1,13 +0,0 @@ -{% extends 'components/inline_form.html' %} -{% load i18n %} - -{% block header %} -{% trans "Create Group" %} -{% endblock %} - -{% block form %} -
- {% include 'group/form.html' %} -
-{% endblock %} - diff --git a/bookwyrm/templates/groups/created_text.html b/bookwyrm/templates/groups/created_text.html new file mode 100644 index 00000000..e7409942 --- /dev/null +++ b/bookwyrm/templates/groups/created_text.html @@ -0,0 +1,6 @@ +{% load i18n %} +{% spaceless %} + +{% blocktrans with username=group.manager.display_name path=group.manager.local_path %}Managed by {{ username }}{% endblocktrans %} + +{% endspaceless %} diff --git a/bookwyrm/templates/groups/delete_group_modal.html b/bookwyrm/templates/groups/delete_group_modal.html new file mode 100644 index 00000000..ff6593e5 --- /dev/null +++ b/bookwyrm/templates/groups/delete_group_modal.html @@ -0,0 +1,21 @@ +{% extends 'components/modal.html' %} +{% load i18n %} + +{% block modal-title %}{% trans "Delete this group?" %}{% endblock %} + +{% block modal-body %} +{% trans "This action cannot be un-done" %} +{% endblock %} + +{% block modal-footer %} +
+ {% csrf_token %} + + + {% trans "Cancel" as button_text %} + {% include 'snippets/toggle/toggle_button.html' with text=button_text controls_text="delete_list" controls_uid=list.id %} +
+{% endblock %} + diff --git a/bookwyrm/templates/groups/edit_form.html b/bookwyrm/templates/groups/edit_form.html new file mode 100644 index 00000000..1c58dc77 --- /dev/null +++ b/bookwyrm/templates/groups/edit_form.html @@ -0,0 +1,13 @@ +{% extends 'components/inline_form.html' %} +{% load i18n %} + +{% block header %} +{% trans "Edit Group" %} +{% endblock %} + +{% block form %} +
+ {% include 'groups/form.html' %} +
+{% include "groups/delete_group_modal.html" with controls_text="delete_group" controls_uid=group.id %} +{% endblock %} diff --git a/bookwyrm/templates/groups/form.html b/bookwyrm/templates/groups/form.html index 38df17a6..f764db6f 100644 --- a/bookwyrm/templates/groups/form.html +++ b/bookwyrm/templates/groups/form.html @@ -1,9 +1,12 @@ {% load i18n %} {% csrf_token %} - +{{ group_form.non_field_errors }}
+
+ +
{{ group_form.name }} diff --git a/bookwyrm/templates/groups/layout.html b/bookwyrm/templates/groups/layout.html new file mode 100644 index 00000000..03a957d0 --- /dev/null +++ b/bookwyrm/templates/groups/layout.html @@ -0,0 +1,32 @@ +{% extends 'layout.html' %} +{% load i18n %} + +{% block title %}{{ group.name }}{% endblock %} + +{% block content %} +
+
+

{{ group.name }} {% include 'snippets/privacy-icons.html' with item=group %}

+

+ {% include 'groups/created_text.html' with group=group %} +

+
+
+ {% if request.user == group.manager %} + {% 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 %} +
+ +
+ {% include 'groups/edit_form.html' with controls_text="edit_group" %} +
+ +{% block panel %}{% endblock %} + +{% endblock %} diff --git a/bookwyrm/templates/user/groups.html b/bookwyrm/templates/user/groups.html index 3a5b9c76..39e09bc1 100644 --- a/bookwyrm/templates/user/groups.html +++ b/bookwyrm/templates/user/groups.html @@ -24,7 +24,7 @@ {% block panel %}
-