diff --git a/bookwyrm/activitystreams.py b/bookwyrm/activitystreams.py index 86321cd83..ff3c55fbd 100644 --- a/bookwyrm/activitystreams.py +++ b/bookwyrm/activitystreams.py @@ -55,6 +55,8 @@ class ActivityStream(RedisStore): return ( models.Status.objects.select_subclasses() .filter(id__in=statuses) + .select_related("user", "reply_parent") + .prefetch_related("mention_books", "mention_users") .order_by("-published_date") ) diff --git a/bookwyrm/models/user.py b/bookwyrm/models/user.py index 7d821c5ba..d9f3eba99 100644 --- a/bookwyrm/models/user.py +++ b/bookwyrm/models/user.py @@ -381,17 +381,16 @@ class AnnualGoal(BookWyrmModel): return {r.book.id: r.rating for r in reviews} @property - def progress_percent(self): - """how close to your goal, in percent form""" - return int(float(self.book_count / self.goal) * 100) - - @property - def book_count(self): + def progress(self): """how many books you've read this year""" - return self.user.readthrough_set.filter( + count = self.user.readthrough_set.filter( finish_date__year__gte=self.year, finish_date__year__lt=self.year + 1, ).count() + return { + "count": count, + "percent": int(float(count / self.goal) * 100), + } @app.task diff --git a/bookwyrm/static/css/bookwyrm.css b/bookwyrm/static/css/bookwyrm.css index fcb32e212..3db25d1fe 100644 --- a/bookwyrm/static/css/bookwyrm.css +++ b/bookwyrm/static/css/bookwyrm.css @@ -43,6 +43,19 @@ body { white-space: nowrap !important; width: 0.01em !important; } + + .m-0-mobile { + margin: 0 !important; + } + + .card-footer.is-stacked-mobile { + flex-direction: column; + } + + .card-footer.is-stacked-mobile .card-footer-item:not(:last-child) { + border-bottom: 1px solid #ededed; + border-right: 0; + } } .button.is-transparent { @@ -331,6 +344,49 @@ body { } } +/* Book list + ******************************************************************************/ + +ol.ordered-list { + list-style: none; + counter-reset: list-counter; +} + +ol.ordered-list li { + counter-increment: list-counter; +} + +ol.ordered-list li::before { + content: counter(list-counter); + position: absolute; + left: -20px; + width: 20px; + height: 24px; + background-color: #fff; + border: 1px solid #dbdbdb; + border-right: 0; + border-top-left-radius: 2px; + border-top-right-radius: 2px; + display: flex; + justify-content: center; + align-items: center; + color: #888; + font-size: 0.8em; + font-weight: bold; +} + +@media only screen and (max-width: 768px) { + ol.ordered-list li::before { + left: 0; + z-index: 1; + border: 0; + border-right: 1px solid #dbdbdb; + border-bottom: 1px solid #dbdbdb; + border-radius: 0; + border-bottom-right-radius: 2px; + } +} + /* Dimensions * @todo These could be in rem. ******************************************************************************/ diff --git a/bookwyrm/templates/book/book.html b/bookwyrm/templates/book/book.html index fb0a45101..df76d8e11 100644 --- a/bookwyrm/templates/book/book.html +++ b/bookwyrm/templates/book/book.html @@ -1,7 +1,7 @@ {% extends 'layout.html' %} {% load i18n %}{% load bookwyrm_tags %}{% load humanize %}{% load utilities %} -{% block title %}{{ book.title }}{% endblock %} +{% block title %}{{ book|title }}{% endblock %} {% block content %} {% with user_authenticated=request.user.is_authenticated can_edit_book=perms.bookwyrm.edit_book %} @@ -137,7 +137,7 @@ {# user's relationship to the book #}
- {% for shelf in user_shelves %} + {% for shelf in user_shelfbooks %}

{% blocktrans with path=shelf.shelf.local_path shelf_name=shelf.shelf.name %}This edition is on your {{ shelf_name }} shelf.{% endblocktrans %} {% include 'snippets/shelf_selector.html' with current=shelf.shelf %} diff --git a/bookwyrm/templates/get_started/book_preview.html b/bookwyrm/templates/get_started/book_preview.html index 578fef708..d8941ad50 100644 --- a/bookwyrm/templates/get_started/book_preview.html +++ b/bookwyrm/templates/get_started/book_preview.html @@ -5,7 +5,7 @@

diff --git a/bookwyrm/templates/layout.html b/bookwyrm/templates/layout.html index bad1cb6e5..1158d82db 100644 --- a/bookwyrm/templates/layout.html +++ b/bookwyrm/templates/layout.html @@ -134,12 +134,14 @@ {% trans "Notifications" %} + {% with request.user.unread_notification_count as notification_count %} - {{ request.user.unread_notification_count }} + {{ notification_count }} + {% endwith %}
{% else %} @@ -193,8 +195,11 @@
+ {# almost every view needs to know the user shelves #} + {% with request.user.shelf_set.all as user_shelves %} {% block content %} {% endblock %} + {% endwith %}
diff --git a/bookwyrm/templates/lists/list.html b/bookwyrm/templates/lists/list.html index d740ee80f..4dc9660a3 100644 --- a/bookwyrm/templates/lists/list.html +++ b/bookwyrm/templates/lists/list.html @@ -27,7 +27,7 @@ {% if not items.object_list.exists %}

{% trans "This list is currently empty" %}

{% else %} -
    +
      {% for item in items %}
    1. @@ -35,16 +35,17 @@
      -
      + -
      +

      {% include 'snippets/book_titleby.html' %}

      @@ -59,7 +60,7 @@
      {% endwith %} -
    2. {% endfor %} diff --git a/bookwyrm/templates/snippets/block_button.html b/bookwyrm/templates/snippets/block_button.html index 7e9fcaea3..3cad78f6d 100644 --- a/bookwyrm/templates/snippets/block_button.html +++ b/bookwyrm/templates/snippets/block_button.html @@ -1,5 +1,5 @@ {% load i18n %} -{% if not user in request.user.blocks.all %} +{% if not blocks %} {% csrf_token %} diff --git a/bookwyrm/templates/snippets/boost_button.html b/bookwyrm/templates/snippets/boost_button.html index 5b84ea44e..0f9274068 100644 --- a/bookwyrm/templates/snippets/boost_button.html +++ b/bookwyrm/templates/snippets/boost_button.html @@ -3,14 +3,31 @@ {% load i18n %} {% with status.id|uuid as uuid %} - +{% with request.user|boosted:status as boosted %} + {% csrf_token %} - -
      + {% csrf_token %}
      {% endwith %} +{% endwith %} diff --git a/bookwyrm/templates/snippets/fav_button.html b/bookwyrm/templates/snippets/fav_button.html index 40fa2d25f..6c4cfe9aa 100644 --- a/bookwyrm/templates/snippets/fav_button.html +++ b/bookwyrm/templates/snippets/fav_button.html @@ -3,7 +3,8 @@ {% load i18n %} {% with status.id|uuid as uuid %} -
      +{% with request.user|liked:status as liked %} + {% csrf_token %}
      -
      + {% csrf_token %}
      {% endwith %} +{% endwith %} diff --git a/bookwyrm/templates/snippets/follow_button.html b/bookwyrm/templates/snippets/follow_button.html index 495bc3e98..0cbe6b8cd 100644 --- a/bookwyrm/templates/snippets/follow_button.html +++ b/bookwyrm/templates/snippets/follow_button.html @@ -1,7 +1,7 @@ {% load i18n %} {% if request.user == user or not request.user.is_authenticated %} {% elif user in request.user.blocks.all %} -{% include 'snippets/block_button.html' %} +{% include 'snippets/block_button.html' with blocks=True %} {% else %}
      diff --git a/bookwyrm/templates/snippets/goal_progress.html b/bookwyrm/templates/snippets/goal_progress.html index 2d46181ef..d0229b689 100644 --- a/bookwyrm/templates/snippets/goal_progress.html +++ b/bookwyrm/templates/snippets/goal_progress.html @@ -1,16 +1,19 @@ {% load i18n %} {% load humanize %} + +{% with goal.progress as progress %}

      - {% if goal.progress_percent >= 100 %} + {% if progress.percent >= 100 %} {% trans "Success!" %} - {% elif goal.progress_percent %} - {% blocktrans with percent=goal.progress_percent %}{{ percent }}% complete!{% endblocktrans %} + {% elif progress.percent %} + {% blocktrans with percent=progress.percent %}{{ percent }}% complete!{% endblocktrans %} {% endif %} {% if goal.user == request.user %} - {% blocktrans with read_count=goal.book_count|intcomma goal_count=goal.goal|intcomma path=goal.local_path %}You've read {{ read_count }} of {{ goal_count}} books.{% endblocktrans %} + {% blocktrans with read_count=progress.count|intcomma goal_count=goal.goal|intcomma path=goal.local_path %}You've read {{ read_count }} of {{ goal_count}} books.{% endblocktrans %} {% else %} - {% blocktrans with username=goal.user.display_name read_count=goal.book_count|intcomma goal_count=goal.goal|intcomma path=goal.local_path %}{{ username }} has read {{ read_count }} of {{ goal_count}} books.{% endblocktrans %} + {% blocktrans with username=goal.user.display_name read_count=progress.count|intcomma goal_count=goal.goal|intcomma path=goal.local_path %}{{ username }} has read {{ read_count }} of {{ goal_count}} books.{% endblocktrans %} {% endif %}

      - + +{% endwith %} diff --git a/bookwyrm/templates/snippets/shelf_selector.html b/bookwyrm/templates/snippets/shelf_selector.html index 0036a4e90..ca5a39f6e 100644 --- a/bookwyrm/templates/snippets/shelf_selector.html +++ b/bookwyrm/templates/snippets/shelf_selector.html @@ -6,7 +6,7 @@ {% endblock %} {% block dropdown-list %} -{% for shelf in request.user.shelf_set.all %} +{% for shelf in user_shelves %}
      {% 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_options.html' with class="shelf-option is-small" shelves=user_shelves active_shelf=active_shelf button_uuid=uuid %}
      {% include 'snippets/shelve_button/shelve_button_dropdown.html' with class="is-small" button_uuid=uuid%} {% endif %} @@ -25,7 +25,7 @@ {% include 'snippets/shelve_button/finish_reading_modal.html' with book=active_shelf.book controls_text="finish-reading" controls_uid=uuid readthrough=readthrough %} -{% include 'snippets/shelve_button/progress_update_modal.html' with book=shelf_book.book controls_text="progress-update" controls_uid=uuid readthrough=readthrough %} +{% include 'snippets/shelve_button/progress_update_modal.html' with book=active_shelf_book.book controls_text="progress-update" 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 4439bfc28..353a37a1c 100644 --- a/bookwyrm/templates/snippets/shelve_button/shelve_button_dropdown.html +++ b/bookwyrm/templates/snippets/shelve_button/shelve_button_dropdown.html @@ -7,5 +7,5 @@ {% 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 is-radiusless is-white" %} +{% include 'snippets/shelve_button/shelve_button_options.html' with active_shelf=active_shelf shelves=user_shelves dropdown=True class="shelf-option is-fullwidth is-small is-radiusless is-white" %} {% endblock %} diff --git a/bookwyrm/templates/snippets/status/layout.html b/bookwyrm/templates/snippets/status/layout.html index 6fd7ebde6..b1d361fe0 100644 --- a/bookwyrm/templates/snippets/status/layout.html +++ b/bookwyrm/templates/snippets/status/layout.html @@ -15,7 +15,7 @@