forked from mirrors/bookwyrm
Show consistent book status regardless of edition
This commit is contained in:
parent
af823cf645
commit
729e50de63
3 changed files with 15 additions and 14 deletions
|
@ -4,24 +4,24 @@
|
||||||
{% with book.id|uuid as uuid %}
|
{% with book.id|uuid as uuid %}
|
||||||
{% active_shelf book as active_shelf %}
|
{% active_shelf book as active_shelf %}
|
||||||
<div class="field is-grouped">
|
<div class="field is-grouped">
|
||||||
{% if active_shelf.identifier == 'read' %}
|
{% if active_shelf.shelf.identifier == 'read' %}
|
||||||
<button class="button is-small" disabled>
|
<button class="button is-small" disabled>
|
||||||
<span>Read</span> <span class="icon icon-check"></span>
|
<span>Read</span> <span class="icon icon-check"></span>
|
||||||
</button>
|
</button>
|
||||||
{% elif active_shelf.identifier == 'reading' %}
|
{% elif active_shelf.shelf.identifier == 'reading' %}
|
||||||
<label class="button is-small" for="finish-reading-{{ uuid }}" role="button" tabindex="0">
|
<label class="button is-small" for="finish-reading-{{ uuid }}" role="button" tabindex="0">
|
||||||
I'm done!
|
I'm done!
|
||||||
</label>
|
</label>
|
||||||
{% include 'snippets/finish_reading_modal.html' %}
|
{% include 'snippets/finish_reading_modal.html' with book=active_shelf.book %}
|
||||||
{% elif active_shelf.identifier == 'to-read' %}
|
{% elif active_shelf.shelf.identifier == 'to-read' %}
|
||||||
<label class="button is-small" for="start-reading-{{ uuid }}" role="button" tabindex="0">
|
<label class="button is-small" for="start-reading-{{ uuid }}" role="button" tabindex="0">
|
||||||
Start reading
|
Start reading
|
||||||
</label>
|
</label>
|
||||||
{% include 'snippets/start_reading_modal.html' %}
|
{% include 'snippets/start_reading_modal.html' with book=active_shelf.book %}
|
||||||
{% else %}
|
{% else %}
|
||||||
<form name="shelve" action="/shelve/" method="post">
|
<form name="shelve" action="/shelve/" method="post">
|
||||||
{% csrf_token %}
|
{% csrf_token %}
|
||||||
<input type="hidden" name="book" value="{{ book.id }}">
|
<input type="hidden" name="book" value="{{ active_shelf.book.id }}">
|
||||||
<input type="hidden" name="shelf" value="to-read">
|
<input type="hidden" name="shelf" value="to-read">
|
||||||
<button class="button is-small" type="submit">Want to read</button>
|
<button class="button is-small" type="submit">Want to read</button>
|
||||||
</form>
|
</form>
|
||||||
|
@ -40,17 +40,17 @@
|
||||||
<ul class="dropdown-content">
|
<ul class="dropdown-content">
|
||||||
{% for shelf in request.user.shelf_set.all %}
|
{% for shelf in request.user.shelf_set.all %}
|
||||||
<li role="menuitem">
|
<li role="menuitem">
|
||||||
{% if shelf.identifier == 'to-read' %}
|
{% if active_shelf.shelf.identifier == 'to-read' and shelf.identifier == 'reading' %}
|
||||||
<div class="dropdown-item pt-0 pb-0">
|
<div class="dropdown-item pt-0 pb-0">
|
||||||
<label class="button is-small" for="start-reading-{{ uuid }}" role="button" tabindex="0">
|
<label class="button is-small" for="start-reading-{{ uuid }}" role="button" tabindex="0">
|
||||||
Start reading
|
Start reading
|
||||||
</label>
|
</label>
|
||||||
{% include 'snippets/start_reading_modal.html' %}
|
{% include 'snippets/start_reading_modal.html' with book=active_shelf.book %}
|
||||||
</div>
|
</div>
|
||||||
{% else %}
|
{% else %}
|
||||||
<form class="dropdown-item pt-0 pb-0" name="shelve" action="/shelve/" method="post">
|
<form class="dropdown-item pt-0 pb-0" name="shelve" action="/shelve/" method="post">
|
||||||
{% csrf_token %}
|
{% csrf_token %}
|
||||||
<input type="hidden" name="book" value="{{ book.id }}">
|
<input type="hidden" name="book" value="{{ active_shelf.book.id }}">
|
||||||
<button class="button is-small" name="shelf" type="submit" value="{{ shelf.identifier }}" {% if shelf in book.shelf_set.all %} disabled {% endif %}>
|
<button class="button is-small" name="shelf" type="submit" value="{{ shelf.identifier }}" {% if shelf in book.shelf_set.all %} disabled {% endif %}>
|
||||||
<span>{{ shelf.name }}</span>
|
<span>{{ shelf.name }}</span>
|
||||||
{% if shelf in book.shelf_set.all %}<span class="icon icon-check"></span>{% endif %}
|
{% if shelf in book.shelf_set.all %}<span class="icon icon-check"></span>{% endif %}
|
||||||
|
|
|
@ -132,9 +132,10 @@ def time_since(date):
|
||||||
delta = now - date
|
delta = now - date
|
||||||
|
|
||||||
if date < (now - relativedelta(weeks=1)):
|
if date < (now - relativedelta(weeks=1)):
|
||||||
|
formatter = '%b %-d'
|
||||||
if date.year != now.year:
|
if date.year != now.year:
|
||||||
return date.strftime('%b %-d %Y')
|
formatter += ' %Y'
|
||||||
return date.strftime('%b %-d')
|
return date.strftime(formatter)
|
||||||
delta = relativedelta(now, date)
|
delta = relativedelta(now, date)
|
||||||
if delta.days:
|
if delta.days:
|
||||||
return '%dd' % delta.days
|
return '%dd' % delta.days
|
||||||
|
@ -150,9 +151,9 @@ def active_shelf(context, book):
|
||||||
''' check what shelf a user has a book on, if any '''
|
''' check what shelf a user has a book on, if any '''
|
||||||
shelf = models.ShelfBook.objects.filter(
|
shelf = models.ShelfBook.objects.filter(
|
||||||
shelf__user=context['request'].user,
|
shelf__user=context['request'].user,
|
||||||
book=book
|
book__in=book.parent_work.editions.all()
|
||||||
).first()
|
).first()
|
||||||
return shelf.shelf if shelf else None
|
return shelf if shelf else {'book': book}
|
||||||
|
|
||||||
|
|
||||||
@register.simple_tag(takes_context=False)
|
@register.simple_tag(takes_context=False)
|
||||||
|
|
|
@ -675,7 +675,7 @@ def editions_page(request, book_id):
|
||||||
|
|
||||||
data = {
|
data = {
|
||||||
'title': 'Editions of %s' % work.title,
|
'title': 'Editions of %s' % work.title,
|
||||||
'editions': work.edition_set.all(),
|
'editions': work.editions.all(),
|
||||||
'work': work,
|
'work': work,
|
||||||
}
|
}
|
||||||
return TemplateResponse(request, 'editions.html', data)
|
return TemplateResponse(request, 'editions.html', data)
|
||||||
|
|
Loading…
Reference in a new issue