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/book.html b/bookwyrm/templates/book.html index 51811d17..1d8b5d35 100644 --- a/bookwyrm/templates/book.html +++ b/bookwyrm/templates/book.html @@ -35,7 +35,7 @@
{% include 'snippets/book_cover.html' with book=book size=large %} {% include 'snippets/rate_action.html' with user=request.user book=book %} - {% include 'snippets/shelve_button.html' %} + {% include 'snippets/shelve_button/shelve_button.html' %} {% if request.user.is_authenticated and not book.cover %}
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/feed/feed_layout.html b/bookwyrm/templates/feed/feed_layout.html index f0c7b057..00ac4ab8 100644 --- a/bookwyrm/templates/feed/feed_layout.html +++ b/bookwyrm/templates/feed/feed_layout.html @@ -48,7 +48,7 @@
- {% include 'snippets/shelve_button.html' with book=book %} + {% include 'snippets/shelve_button/shelve_button.html' with book=book %} {% active_shelf book as active_shelf %} {% if active_shelf.shelf.identifier == 'reading' and book.latest_readthrough %} {% include 'snippets/progress_update.html' with readthrough=book.latest_readthrough %} diff --git a/bookwyrm/templates/snippets/book_preview.html b/bookwyrm/templates/snippets/book_preview.html index 6f8ff53a..0c75f9b1 100644 --- a/bookwyrm/templates/snippets/book_preview.html +++ b/bookwyrm/templates/snippets/book_preview.html @@ -3,7 +3,7 @@
{% include 'snippets/book_cover.html' with book=book %} - {% include 'snippets/shelve_button.html' with book=book %} + {% include 'snippets/shelve_button/shelve_button.html' with book=book %}
diff --git a/bookwyrm/templates/snippets/book_tiles.html b/bookwyrm/templates/snippets/book_tiles.html index 85f685a8..1867a8a8 100644 --- a/bookwyrm/templates/snippets/book_tiles.html +++ b/bookwyrm/templates/snippets/book_tiles.html @@ -5,7 +5,7 @@ {% include 'snippets/book_cover.html' with book=book %} - {% include 'snippets/shelve_button.html' with book=book switch_mode=True %} + {% include 'snippets/shelve_button/shelve_button.html' with book=book switch_mode=True %}
{% endfor %} diff --git a/bookwyrm/templates/snippets/shelve_button.html b/bookwyrm/templates/snippets/shelve_button.html deleted file mode 100644 index f69ab525..00000000 --- a/bookwyrm/templates/snippets/shelve_button.html +++ /dev/null @@ -1,40 +0,0 @@ -{% load bookwyrm_tags %} -{% if request.user.is_authenticated %} - -{% with book.id|uuid as uuid %} -{% active_shelf book as active_shelf %} -
- {% if switch_mode and active_shelf.book != book %} -
- {% include 'snippets/switch_edition_button.html' with edition=book size='is-small' %} -
- {% 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_dropdown.html' with class="is-small" button_uuid=uuid%} - {% endif %} -
- -{% 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 %} -{% include 'snippets/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/finish_reading_modal.html b/bookwyrm/templates/snippets/shelve_button/finish_reading_modal.html similarity index 100% rename from bookwyrm/templates/snippets/finish_reading_modal.html rename to bookwyrm/templates/snippets/shelve_button/finish_reading_modal.html diff --git a/bookwyrm/templates/snippets/shelve_button/shelve_button.html b/bookwyrm/templates/snippets/shelve_button/shelve_button.html new file mode 100644 index 00000000..5f6ed8d2 --- /dev/null +++ b/bookwyrm/templates/snippets/shelve_button/shelve_button.html @@ -0,0 +1,27 @@ +{% load bookwyrm_tags %} +{% if request.user.is_authenticated %} + +{% with book.id|uuid as uuid %} +{% active_shelf book as active_shelf %} +
+ {% if switch_mode and active_shelf.book != book %} +
+ {% include 'snippets/switch_edition_button.html' with edition=book size='is-small' %} +
+ {% else %} +
+ {% 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/shelve_button_dropdown.html' with class="is-small" button_uuid=uuid%} + {% endif %} +
+ +{% 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/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/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 new file mode 100644 index 00000000..47cf3505 --- /dev/null +++ b/bookwyrm/templates/snippets/shelve_button/shelve_button_dropdown.html @@ -0,0 +1,10 @@ +{% extends 'components/dropdown.html' %} +{% block dropdown-trigger %} + + More shelves + +{% endblock %} + +{% block dropdown-list %} +{% 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/shelve_button/shelve_button_options.html b/bookwyrm/templates/snippets/shelve_button/shelve_button_options.html new file mode 100644 index 00000000..2d7d9609 --- /dev/null +++ b/bookwyrm/templates/snippets/shelve_button/shelve_button_options.html @@ -0,0 +1,25 @@ +{% 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 %} 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/shelve_button/want_to_read_modal.html b/bookwyrm/templates/snippets/shelve_button/want_to_read_modal.html new file mode 100644 index 00000000..9b7e2bde --- /dev/null +++ b/bookwyrm/templates/snippets/shelve_button/want_to_read_modal.html @@ -0,0 +1,31 @@ +{% extends 'components/modal.html' %} + +{% block modal-title %} +Want to Read "{{ book.title }}" +{% endblock %} + +{% block modal-form-open %} +
    + {% csrf_token %} + + +{% endblock %} + +{% block modal-footer %} +
    +
    + + {% include 'snippets/privacy_select.html' %} +
    +
    + + {% include 'snippets/toggle/toggle_button.html' with text="Cancel" controls_text="want-to-read" controls_uid=uuid %} +
    +
    +{% endblock %} +{% block modal-form-close %}
    {% endblock %} diff --git a/bookwyrm/templates/snippets/shelve_button_dropdown.html b/bookwyrm/templates/snippets/shelve_button_dropdown.html deleted file mode 100644 index 50140e3f..00000000 --- a/bookwyrm/templates/snippets/shelve_button_dropdown.html +++ /dev/null @@ -1,28 +0,0 @@ -{% extends 'components/dropdown.html' %} -{% block dropdown-trigger %} - - More shelves - -{% 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 %} -{% 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 6dea32e9..d251d8e4 100644 --- a/bookwyrm/templatetags/bookwyrm_tags.py +++ b/bookwyrm/templatetags/bookwyrm_tags.py @@ -171,6 +171,17 @@ 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): + ''' 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) def related_status(notification): ''' for notifications ''' @@ -211,3 +222,9 @@ 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): + ''' idk why I need to write a tag for this, it reutrns a bool ''' + return str1 == str2 diff --git a/bookwyrm/views/shelf.py b/bookwyrm/views/shelf.py index c689c09e..02502ff6 100644 --- a/bookwyrm/views/shelf.py +++ b/bookwyrm/views/shelf.py @@ -124,6 +124,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: @@ -139,12 +141,14 @@ def shelve(request): book=book, shelf=desired_shelf, user=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('/')