From 7bf39d3bf749f89c14fb0ab6930915629e1dc572 Mon Sep 17 00:00:00 2001 From: Mouse Reeve Date: Thu, 5 Nov 2020 16:48:15 -0800 Subject: [PATCH] html for updated reading progress flow --- bookwyrm/static/css/format.css | 4 + .../templates/snippets/create_status.html | 9 +- bookwyrm/templates/snippets/reply_form.html | 9 +- .../templates/snippets/shelve_button.html | 153 +++++++++++++++--- bookwyrm/templatetags/fr_display.py | 27 ++-- bookwyrm/views.py | 8 +- 6 files changed, 155 insertions(+), 55 deletions(-) diff --git a/bookwyrm/static/css/format.css b/bookwyrm/static/css/format.css index 51c931e6..db3c20ef 100644 --- a/bookwyrm/static/css/format.css +++ b/bookwyrm/static/css/format.css @@ -15,6 +15,10 @@ input.toggle-control:checked ~ .toggle-content { display: block; } +input.toggle-control:checked ~ .modal.toggle-content { + display: flex; +} + /* --- STARS --- */ .rate-stars button.icon { background: none; diff --git a/bookwyrm/templates/snippets/create_status.html b/bookwyrm/templates/snippets/create_status.html index 28379f0e..9055e2d4 100644 --- a/bookwyrm/templates/snippets/create_status.html +++ b/bookwyrm/templates/snippets/create_status.html @@ -44,14 +44,7 @@
-
- -
+ {% include 'snippets/privacy_select.html' %}
diff --git a/bookwyrm/templates/snippets/reply_form.html b/bookwyrm/templates/snippets/reply_form.html index 48371f63..2d8abd23 100644 --- a/bookwyrm/templates/snippets/reply_form.html +++ b/bookwyrm/templates/snippets/reply_form.html @@ -13,14 +13,7 @@
-
- -
+ {% include 'snippets/privacy_select.html' %}
- - +
+ +
+ +
+ + +
+{% endwith %} {% endif %} diff --git a/bookwyrm/templatetags/fr_display.py b/bookwyrm/templatetags/fr_display.py index 73df1db8..5e719695 100644 --- a/bookwyrm/templatetags/fr_display.py +++ b/bookwyrm/templatetags/fr_display.py @@ -158,22 +158,14 @@ def time_since(date): @register.simple_tag(takes_context=True) -def shelve_button_identifier(context, book): +def active_shelf(context, book): ''' check what shelf a user has a book on, if any ''' #TODO: books can be on multiple shelves, handle that better shelf = models.ShelfBook.objects.filter( shelf__user=context['request'].user, book=book ).first() - if not shelf: - return 'to-read' - - identifier = shelf.shelf.identifier - if identifier == 'to-read': - return 'reading' - if identifier == 'reading': - return 'read' - return 'to-read' + return shelf.shelf if shelf else None @register.simple_tag(takes_context=True) @@ -192,7 +184,7 @@ def shelve_button_text(context, book): return 'Start reading' if identifier == 'reading': return 'I\'m done!' - return 'Want to read' + return 'Read' @register.simple_tag(takes_context=False) @@ -200,4 +192,15 @@ def latest_read_through(book, user): ''' the most recent read activity ''' return models.ReadThrough.objects.filter( user=user, - book=book).order_by('-created_date').first() + book=book + ).order_by('-start_date').first() + + +@register.simple_tag(takes_context=False) +def active_read_through(book, user): + ''' the most recent read activity ''' + return models.ReadThrough.objects.filter( + user=user, + book=book, + finish_date__isnull=True + ).order_by('-start_date').first() diff --git a/bookwyrm/views.py b/bookwyrm/views.py index 6e98225c..9794d585 100644 --- a/bookwyrm/views.py +++ b/bookwyrm/views.py @@ -71,7 +71,7 @@ def home_tab(request, tab): models.Edition.objects.filter( shelves__user=request.user, shelves__identifier='read' - )[:2], + ).order_by('-updated_date')[:2], # to-read models.Edition.objects.filter( shelves__user=request.user, @@ -242,7 +242,11 @@ def about_page(request): def password_reset_request(request): ''' invite management page ''' - return TemplateResponse(request, 'password_reset_request.html', {'title': 'Reset Password'}) + return TemplateResponse( + request, + 'password_reset_request.html', + {'title': 'Reset Password'} + ) def password_reset(request, code):