From e5746d611783c2410c6e33dadd157798a9e322ad Mon Sep 17 00:00:00 2001 From: Mouse Reeve Date: Sat, 30 Jan 2021 11:43:40 -0800 Subject: [PATCH 01/10] Menu list for shelf button options --- bookwyrm/static/css/format.css | 7 +++++++ .../templates/snippets/shelve_button.html | 17 +--------------- .../snippets/shelve_button_dropdown.html | 20 +------------------ .../snippets/toggle/toggle_button.html | 3 ++- bookwyrm/templatetags/bookwyrm_tags.py | 13 ++++++++++++ 5 files changed, 24 insertions(+), 36 deletions(-) diff --git a/bookwyrm/static/css/format.css b/bookwyrm/static/css/format.css index f10549ed..50ce101e 100644 --- a/bookwyrm/static/css/format.css +++ b/bookwyrm/static/css/format.css @@ -13,6 +13,13 @@ overflow: hidden; } +/* --- SHELVING --- */ +.shelf-option:disabled > *::after { + font-family: "icomoon"; + content: "\e918"; + margin-left: 0.5em; +} + /* --- TOGGLES --- */ .toggle-button[aria-pressed=true], .toggle-button[aria-pressed=true]:hover { background-color: hsl(171, 100%, 41%); diff --git a/bookwyrm/templates/snippets/shelve_button.html b/bookwyrm/templates/snippets/shelve_button.html index f69ab525..946368c2 100644 --- a/bookwyrm/templates/snippets/shelve_button.html +++ b/bookwyrm/templates/snippets/shelve_button.html @@ -10,22 +10,7 @@ {% else %}
- {% if active_shelf.shelf.identifier == 'read' %} - - {% elif active_shelf.shelf.identifier == 'reading' %} - {% include 'snippets/toggle/toggle_button.html' with class="is-small" text="I'm done!" controls_text="finish-reading" controls_uid=uuid focus="modal-title-finish-reading" %} - {% elif active_shelf.shelf.identifier == 'to-read' %} - {% include 'snippets/toggle/toggle_button.html' with class="is-small" text="Start reading" controls_text="start-reading" controls_uid=uuid focus="modal-title-start-reading" %} - {% else %} -
- {% csrf_token %} - - - -
- {% endif %} + {% include 'snippets/shelve_button_options.html' with class="shelf-option is-small" shelves=request.user.shelf_set.all active_shelf=active_shelf %}
{% include 'snippets/shelve_button_dropdown.html' with class="is-small" button_uuid=uuid%} {% endif %} diff --git a/bookwyrm/templates/snippets/shelve_button_dropdown.html b/bookwyrm/templates/snippets/shelve_button_dropdown.html index 50140e3f..d70765a3 100644 --- a/bookwyrm/templates/snippets/shelve_button_dropdown.html +++ b/bookwyrm/templates/snippets/shelve_button_dropdown.html @@ -6,23 +6,5 @@ {% endblock %} {% block dropdown-list %} -{% for shelf in request.user.shelf_set.all %} -
  • - {% if active_shelf.shelf.identifier != 'reading' and shelf.identifier == 'reading' %} - - {% else %} - - {% endif %} -
  • -{% endfor %} +{% include 'snippets/shelve_button_options.html' with active_shelf=active_shelf shelves=request.user.shelf_set.all dropdown=True class="shelf-option is-fullwidth is-small" %} {% endblock %} - diff --git a/bookwyrm/templates/snippets/toggle/toggle_button.html b/bookwyrm/templates/snippets/toggle/toggle_button.html index d6fd0a36..fe1823f1 100644 --- a/bookwyrm/templates/snippets/toggle/toggle_button.html +++ b/bookwyrm/templates/snippets/toggle/toggle_button.html @@ -6,6 +6,7 @@ {% if checkbox %}data-controls-checkbox="{{ checkbox }}{% if controls_uid %}-{{ controls_uid }}{% endif %}"{% endif %} {% if label %}aria-label="{{ label }}"{% endif %} aria-pressed="{% if pressed %}true{% else %}false{% endif %}" + {% if disabled %}disabled{% endif %} > {% if icon %} @@ -13,6 +14,6 @@ {{ text }} {% else %} - {{ text }} + {{ text }} {% endif %} diff --git a/bookwyrm/templatetags/bookwyrm_tags.py b/bookwyrm/templatetags/bookwyrm_tags.py index 08bbcafe..c1a2d14e 100644 --- a/bookwyrm/templatetags/bookwyrm_tags.py +++ b/bookwyrm/templatetags/bookwyrm_tags.py @@ -159,6 +159,14 @@ def get_status_preview_name(obj): return '%s from %s' % (name, obj.book.title) return name +@register.filter(name='next_shelf') +def get_next_shelf(current_shelf): + if current_shelf == 'to-read': + return 'reading' + if current_shelf == 'reading': + return 'read' + return 'to-read' + @register.simple_tag(takes_context=False) def related_status(notification): ''' for notifications ''' @@ -199,3 +207,8 @@ def active_read_through(book, user): book=book, finish_date__isnull=True ).order_by('-start_date').first() + + +@register.simple_tag(takes_context=False) +def comparison_bool(str1, str2): + return str1 == str2 From 37710144fa9919cdbb30224090d543afdba61eba Mon Sep 17 00:00:00 2001 From: Mouse Reeve Date: Sat, 30 Jan 2021 11:52:31 -0800 Subject: [PATCH 02/10] Adds options tempalte --- .../snippets/shelve_button_options.html | 23 +++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 bookwyrm/templates/snippets/shelve_button_options.html diff --git a/bookwyrm/templates/snippets/shelve_button_options.html b/bookwyrm/templates/snippets/shelve_button_options.html new file mode 100644 index 00000000..84133400 --- /dev/null +++ b/bookwyrm/templates/snippets/shelve_button_options.html @@ -0,0 +1,23 @@ +{% load bookwyrm_tags %} +{% for shelf in shelves %} +{% comparison_bool shelf.identifier active_shelf.shelf.identifier as is_current %} +{% if dropdown %}
  • {% endif %} + +{% if dropdown %}
  • {% endif %} +{% endfor %} From e5fd14b2067b54a095bd374cdccbbb215ca8b52e Mon Sep 17 00:00:00 2001 From: Mouse Reeve Date: Sat, 30 Jan 2021 13:11:43 -0800 Subject: [PATCH 03/10] Confirmation modal for to-read shelve action --- bookwyrm/templates/components/modal.html | 4 ++- .../templates/snippets/shelve_button.html | 4 ++- .../snippets/shelve_button_options.html | 4 ++- .../snippets/want_to_read_modal.html | 30 +++++++++++++++++++ bookwyrm/templatetags/bookwyrm_tags.py | 4 +++ 5 files changed, 43 insertions(+), 3 deletions(-) create mode 100644 bookwyrm/templates/snippets/want_to_read_modal.html diff --git a/bookwyrm/templates/components/modal.html b/bookwyrm/templates/components/modal.html index 72402914..554f9ccd 100644 --- a/bookwyrm/templates/components/modal.html +++ b/bookwyrm/templates/components/modal.html @@ -8,15 +8,17 @@ {% include 'snippets/toggle/toggle_button.html' with label="close" class="delete" nonbutton=True %} {% block modal-form-open %}{% endblock %} + {% if not no_body %} + {% endif %}
    {% block modal-footer %}{% endblock %}
    {% block modal-form-close %}{% endblock %} - + {% include 'snippets/toggle/toggle_button.html' with label="close" class="modal-close is-large" nonbutton=True %} diff --git a/bookwyrm/templates/snippets/shelve_button.html b/bookwyrm/templates/snippets/shelve_button.html index 946368c2..769da50f 100644 --- a/bookwyrm/templates/snippets/shelve_button.html +++ b/bookwyrm/templates/snippets/shelve_button.html @@ -10,12 +10,14 @@ {% else %}
    - {% include 'snippets/shelve_button_options.html' with class="shelf-option is-small" shelves=request.user.shelf_set.all active_shelf=active_shelf %} + {% include 'snippets/shelve_button_options.html' with class="shelf-option is-small" shelves=request.user.shelf_set.all active_shelf=active_shelf button_uuid=uuid %}
    {% include 'snippets/shelve_button_dropdown.html' with class="is-small" button_uuid=uuid%} {% endif %} +{% include 'snippets/want_to_read_modal.html' with book=active_shelf.book controls_text="want-to-read" controls_uid=uuid no_body=True %} + {% include 'snippets/start_reading_modal.html' with book=active_shelf.book controls_text="start-reading" controls_uid=uuid %} {% latest_read_through book request.user as readthrough %} diff --git a/bookwyrm/templates/snippets/shelve_button_options.html b/bookwyrm/templates/snippets/shelve_button_options.html index 84133400..af47ee23 100644 --- a/bookwyrm/templates/snippets/shelve_button_options.html +++ b/bookwyrm/templates/snippets/shelve_button_options.html @@ -5,10 +5,12 @@ + +{% endblock %} +{% block modal-form-close %}{% endblock %} diff --git a/bookwyrm/templatetags/bookwyrm_tags.py b/bookwyrm/templatetags/bookwyrm_tags.py index c1a2d14e..0a699129 100644 --- a/bookwyrm/templatetags/bookwyrm_tags.py +++ b/bookwyrm/templatetags/bookwyrm_tags.py @@ -161,10 +161,13 @@ def get_status_preview_name(obj): @register.filter(name='next_shelf') def get_next_shelf(current_shelf): + ''' shelf you'd use to update reading progress ''' if current_shelf == 'to-read': return 'reading' if current_shelf == 'reading': return 'read' + if current_shelf == 'read': + return 'read' return 'to-read' @register.simple_tag(takes_context=False) @@ -211,4 +214,5 @@ def active_read_through(book, user): @register.simple_tag(takes_context=False) def comparison_bool(str1, str2): + ''' idk why I need to write a tag for this, it reutrns a bool ''' return str1 == str2 From 9b326f732158333f9dcb713e2b759ddc2babe7d7 Mon Sep 17 00:00:00 2001 From: Mouse Reeve Date: Sat, 30 Jan 2021 15:18:38 -0800 Subject: [PATCH 04/10] Give user control over "want to read" posts --- bookwyrm/templates/snippets/want_to_read_modal.html | 3 ++- bookwyrm/views/shelf.py | 8 ++++++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/bookwyrm/templates/snippets/want_to_read_modal.html b/bookwyrm/templates/snippets/want_to_read_modal.html index 37a4c39a..9b7e2bde 100644 --- a/bookwyrm/templates/snippets/want_to_read_modal.html +++ b/bookwyrm/templates/snippets/want_to_read_modal.html @@ -8,6 +8,7 @@ Want to Read "{{ book.title }}"
    {% csrf_token %} + {% endblock %} {% block modal-footer %} @@ -20,7 +21,7 @@ Want to Read "{{ book.title }}" {% include 'snippets/privacy_select.html' %}
    - {% include 'snippets/toggle/toggle_button.html' with text="Cancel" controls_text="want-to-read" controls_uid=uuid %} diff --git a/bookwyrm/views/shelf.py b/bookwyrm/views/shelf.py index ae8a494b..25275d67 100644 --- a/bookwyrm/views/shelf.py +++ b/bookwyrm/views/shelf.py @@ -125,6 +125,8 @@ def shelve(request): identifier=request.POST.get('shelf'), user=request.user ).first() + #if not desired_shelf: + # return HttpResponseNotFound() if request.POST.get('reshelve', True): try: @@ -141,12 +143,14 @@ def shelve(request): broadcast(request.user, shelfbook.to_add_activity(request.user)) # post about "want to read" shelves - if desired_shelf.identifier == 'to-read': + if desired_shelf.identifier == 'to-read' and \ + request.POST.get('post-status'): + privacy = request.POST.get('privacy') or desired_shelf.privacy handle_reading_status( request.user, desired_shelf, book, - privacy=desired_shelf.privacy + privacy=privacy ) return redirect('/') From 7afab352b1585ceaa55258ebf5c8cb5f41dcf5a1 Mon Sep 17 00:00:00 2001 From: Mouse Reeve Date: Sat, 30 Jan 2021 11:46:15 -0800 Subject: [PATCH 05/10] Fixes incorrect tempalte path in threaded status page --- bookwyrm/templates/feed/thread.html | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/bookwyrm/templates/feed/thread.html b/bookwyrm/templates/feed/thread.html index 589702ce..aa67d5bb 100644 --- a/bookwyrm/templates/feed/thread.html +++ b/bookwyrm/templates/feed/thread.html @@ -4,7 +4,7 @@ {% with depth=depth|add:1 %} {% if depth <= max_depth and status.reply_parent and direction <= 0 %} {% with direction=-1 %} - {% include 'snippets/thread.html' with status=status|parent is_root=False %} + {% include 'feed/thread.html' with status=status|parent is_root=False %} {% endwith %} {% endif %} @@ -13,7 +13,7 @@ {% if depth <= max_depth and direction >= 0 %} {% for reply in status|replies %} {% with direction=1 %} - {% include 'snippets/thread.html' with status=reply is_root=False %} + {% include 'feed/thread.html' with status=reply is_root=False %} {% endwith %} {% endfor %} {% endif %} From 0c723eb550ea4c97f261ed9272e6b8852aa39bc5 Mon Sep 17 00:00:00 2001 From: Mouse Reeve Date: Sat, 30 Jan 2021 12:03:50 -0800 Subject: [PATCH 06/10] Fixes shelf page template path bug --- bookwyrm/templates/{ => user}/shelf.html | 28 +++++++++++------------- bookwyrm/tests/views/test_shelf.py | 2 +- bookwyrm/views/shelf.py | 2 +- 3 files changed, 15 insertions(+), 17 deletions(-) rename bookwyrm/templates/{ => user}/shelf.html (89%) diff --git a/bookwyrm/templates/shelf.html b/bookwyrm/templates/user/shelf.html similarity index 89% rename from bookwyrm/templates/shelf.html rename to bookwyrm/templates/user/shelf.html index da599c7d..c0083e17 100644 --- a/bookwyrm/templates/shelf.html +++ b/bookwyrm/templates/user/shelf.html @@ -1,21 +1,19 @@ -{% extends 'layout.html' %} +{% extends 'user/user_layout.html' %} {% load bookwyrm_tags %} -{% block content %} -
    -
    -

    - {% if is_self %}Your - {% else %} - {% include 'snippets/username.html' with user=user possessive=True %} - {% endif %} - shelves -

    -
    -
    - -{% include 'snippets/user_header.html' with user=user %} +{% block header %} +
    +

    + {% if is_self %}Your + {% else %} + {% include 'snippets/username.html' with user=user possessive=True %} + {% endif %} + shelves +

    +
    +{% endblock %} +{% block panel %}
    diff --git a/bookwyrm/tests/views/test_shelf.py b/bookwyrm/tests/views/test_shelf.py index 35e07953..95150fe9 100644 --- a/bookwyrm/tests/views/test_shelf.py +++ b/bookwyrm/tests/views/test_shelf.py @@ -41,7 +41,7 @@ class ShelfViews(TestCase): is_api.return_value = False result = view(request, self.local_user.username, shelf.identifier) self.assertIsInstance(result, TemplateResponse) - self.assertEqual(result.template_name, 'shelf.html') + self.assertEqual(result.template_name, 'user/shelf.html') self.assertEqual(result.status_code, 200) with patch('bookwyrm.views.shelf.is_api_request') as is_api: diff --git a/bookwyrm/views/shelf.py b/bookwyrm/views/shelf.py index 25275d67..05049109 100644 --- a/bookwyrm/views/shelf.py +++ b/bookwyrm/views/shelf.py @@ -62,7 +62,7 @@ class Shelf(View): 'books': [b.book for b in books], } - return TemplateResponse(request, 'shelf.html', data) + return TemplateResponse(request, 'user/shelf.html', data) @method_decorator(login_required, name='dispatch') # pylint: disable=unused-argument From 74d37c84be5c48fa0a146dcfc54c803091dcc722 Mon Sep 17 00:00:00 2001 From: Mouse Reeve Date: Sat, 30 Jan 2021 15:46:20 -0800 Subject: [PATCH 07/10] Don't show the main button in the dropdown --- bookwyrm/templates/snippets/shelve_button_options.html | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/bookwyrm/templates/snippets/shelve_button_options.html b/bookwyrm/templates/snippets/shelve_button_options.html index af47ee23..2d7d9609 100644 --- a/bookwyrm/templates/snippets/shelve_button_options.html +++ b/bookwyrm/templates/snippets/shelve_button_options.html @@ -3,15 +3,15 @@ {% comparison_bool shelf.identifier active_shelf.shelf.identifier as is_current %} {% if dropdown %}
  • {% endif %} {% else %}
    - {% include 'snippets/shelve_button_options.html' with class="shelf-option is-small" shelves=request.user.shelf_set.all active_shelf=active_shelf button_uuid=uuid %} + {% include 'snippets/shelve_button/shelve_button_options.html' with class="shelf-option is-small" shelves=request.user.shelf_set.all active_shelf=active_shelf button_uuid=uuid %}
    - {% include 'snippets/shelve_button_dropdown.html' with class="is-small" button_uuid=uuid%} + {% include 'snippets/shelve_button/shelve_button_dropdown.html' with class="is-small" button_uuid=uuid%} {% endif %}
  • -{% include 'snippets/want_to_read_modal.html' with book=active_shelf.book controls_text="want-to-read" controls_uid=uuid no_body=True %} +{% include 'snippets/shelve_button/want_to_read_modal.html' with book=active_shelf.book controls_text="want-to-read" controls_uid=uuid no_body=True %} -{% include 'snippets/start_reading_modal.html' with book=active_shelf.book controls_text="start-reading" controls_uid=uuid %} +{% include 'snippets/shelve_button/start_reading_modal.html' with book=active_shelf.book controls_text="start-reading" controls_uid=uuid %} {% latest_read_through book request.user as readthrough %} -{% include 'snippets/finish_reading_modal.html' with book=active_shelf.book controls_text="finish-reading" controls_uid=uuid readthrough=readthrough %} +{% include 'snippets/shelve_button/finish_reading_modal.html' with book=active_shelf.book controls_text="finish-reading" controls_uid=uuid readthrough=readthrough %} {% endwith %} {% endif %} diff --git a/bookwyrm/templates/snippets/shelve_button/shelve_button_dropdown.html b/bookwyrm/templates/snippets/shelve_button/shelve_button_dropdown.html index d70765a3..47cf3505 100644 --- a/bookwyrm/templates/snippets/shelve_button/shelve_button_dropdown.html +++ b/bookwyrm/templates/snippets/shelve_button/shelve_button_dropdown.html @@ -6,5 +6,5 @@ {% endblock %} {% block dropdown-list %} -{% include 'snippets/shelve_button_options.html' with active_shelf=active_shelf shelves=request.user.shelf_set.all dropdown=True class="shelf-option is-fullwidth is-small" %} +{% include 'snippets/shelve_button/shelve_button_options.html' with active_shelf=active_shelf shelves=request.user.shelf_set.all dropdown=True class="shelf-option is-fullwidth is-small" %} {% endblock %} diff --git a/bookwyrm/templates/snippets/start_reading_modal.html b/bookwyrm/templates/snippets/shelve_button/start_reading_modal.html similarity index 100% rename from bookwyrm/templates/snippets/start_reading_modal.html rename to bookwyrm/templates/snippets/shelve_button/start_reading_modal.html diff --git a/bookwyrm/templates/snippets/want_to_read_modal.html b/bookwyrm/templates/snippets/shelve_button/want_to_read_modal.html similarity index 100% rename from bookwyrm/templates/snippets/want_to_read_modal.html rename to bookwyrm/templates/snippets/shelve_button/want_to_read_modal.html