From 24553e0e359ad7336f89f2749e828ab2614e2e9e Mon Sep 17 00:00:00 2001 From: Mouse Reeve Date: Tue, 28 Sep 2021 16:37:24 -0700 Subject: [PATCH] Updates edit/create shelf forms --- .../templates/shelf/create_shelf_form.html | 16 +----------- bookwyrm/templates/shelf/edit_shelf_form.html | 19 +------------- bookwyrm/templates/shelf/form.html | 25 +++++++++++++++++++ bookwyrm/views/shelf.py | 2 ++ 4 files changed, 29 insertions(+), 33 deletions(-) create mode 100644 bookwyrm/templates/shelf/form.html diff --git a/bookwyrm/templates/shelf/create_shelf_form.html b/bookwyrm/templates/shelf/create_shelf_form.html index b7ea27de8..e15e1cc1d 100644 --- a/bookwyrm/templates/shelf/create_shelf_form.html +++ b/bookwyrm/templates/shelf/create_shelf_form.html @@ -7,21 +7,7 @@ {% block form %}
- {% csrf_token %} - -
- - -
- -
-
- {% include 'snippets/privacy_select.html' %} -
-
- -
-
+ {% include "shelf/form.html" with editable=shelf.editable form=create_form %}
{% endblock %} diff --git a/bookwyrm/templates/shelf/edit_shelf_form.html b/bookwyrm/templates/shelf/edit_shelf_form.html index 847d5e465..5951b6da6 100644 --- a/bookwyrm/templates/shelf/edit_shelf_form.html +++ b/bookwyrm/templates/shelf/edit_shelf_form.html @@ -7,24 +7,7 @@ {% block form %}
- {% csrf_token %} - -
- {% if shelf.editable %} -
- - -
- {% else %} - - {% endif %} - -
- - {% include 'snippets/privacy_select.html' with current=shelf.privacy uuid=shelf.id no_label=True %} -
-
- + {% include "shelf/form.html" with editable=shelf.editable form=edit_form privacy=shelf.privacy %}
{% endblock %} diff --git a/bookwyrm/templates/shelf/form.html b/bookwyrm/templates/shelf/form.html new file mode 100644 index 000000000..9388a04ee --- /dev/null +++ b/bookwyrm/templates/shelf/form.html @@ -0,0 +1,25 @@ +{% load i18n %} +{% csrf_token %} + + +{% if editable %} +
+ + {{ form.name }} +
+{% else %} + +{% endif %} + +
+ + {{ form.description }} +
+
+
+ {% include 'snippets/privacy_select.html' with current=privacy %} +
+
+ +
+
diff --git a/bookwyrm/views/shelf.py b/bookwyrm/views/shelf.py index 9642363e1..cbec93d82 100644 --- a/bookwyrm/views/shelf.py +++ b/bookwyrm/views/shelf.py @@ -85,6 +85,8 @@ class Shelf(View): "shelves": shelves, "shelf": shelf, "books": page, + "edit_form": forms.ShelfForm(instance=shelf), + "create_form": forms.ShelfForm(), "page_range": paginated.get_elided_page_range( page.number, on_each_side=2, on_ends=1 ),