Make inline progress form actually work

This commit is contained in:
Joel Bradshaw 2020-11-25 22:37:18 -08:00
parent e7c0368168
commit 090cf2aea7
4 changed files with 26 additions and 9 deletions

View file

@ -74,6 +74,10 @@ class Book(ActivitypubMixin, BookWyrmModel):
''' reference the work via local id not remote '''
return self.parent_work.remote_id
@property
def latest_readthrough(self):
return self.readthrough_set.order_by('-updated_date').first()
activity_mappings = [
ActivityMapping('id', 'remote_id'),

View file

@ -46,7 +46,17 @@
<div class="toggle-content hidden" role="tabpanel" id="book-{{ book.id }}-panel">
<div class="block">
{% include 'snippets/book_titleby.html' with book=book %}
{% include 'snippets/shelve_button.html' with book=book %}
<div class="columns is-gapless">
<div class="column is-narrow">
{% include 'snippets/shelve_button.html' with book=book %}
{% active_shelf book as active_shelf %}
</div>
{% if active_shelf.identifier == 'reading' and book.latest_readthrough %}
<div class="column">
{% include 'snippets/progress_update.html' with readthrough=book.latest_readthrough %}
</div>
{% endif %}
</div>
</div>
{% include 'snippets/create_status.html' with book=book %}
</div>

View file

@ -1,7 +1,14 @@
<div class="field is-grouped is-small px-2">
<form class="field is-grouped is-small pl-2" action="/edit-readthrough" method="POST">
{% csrf_token %}
<input type="hidden" name="id" value="{{ readthrough.id }}"/>
<div class="control">on page</div>
<div class="control">
<input aria-label="Current page" class="input is-small" type="text" size="3">
<input aria-label="Current page" class="input is-small" type="text" name="pages_read" size="3" value="{{ readthrough.pages_read }}">
</div>
<div class="control">of 100</div>
</div>
{% if book.pages %}
<div class="control">of {{ book.pages }}</div>
{% endif %}
<div class="control">
<button class="button is-small px-2" type="submit">Go</button>
</div>
</form>

View file

@ -63,10 +63,6 @@
</div>
{% endwith %}
</div>
{% if active_shelf.identifier == 'reading' %}
{% include 'snippets/progress_update.html' %}
{% endif %}
</div>
{% endif %}