forked from mirrors/bookwyrm
Merge pull request #553 from mouse-reeve/pages-percents
Makes pages/percents toggle-able in sidebar for progress readthrough
This commit is contained in:
commit
7ed63bacc9
5 changed files with 106 additions and 93 deletions
36
bookwyrm/migrations/0040_auto_20210122_0057.py
Normal file
36
bookwyrm/migrations/0040_auto_20210122_0057.py
Normal file
|
@ -0,0 +1,36 @@
|
||||||
|
# Generated by Django 3.0.7 on 2021-01-22 00:57
|
||||||
|
|
||||||
|
import bookwyrm.models.fields
|
||||||
|
import django.core.validators
|
||||||
|
from django.db import migrations, models
|
||||||
|
import django.db.models.deletion
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('bookwyrm', '0039_merge_20210120_0753'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name='progressupdate',
|
||||||
|
name='progress',
|
||||||
|
field=models.IntegerField(validators=[django.core.validators.MinValueValidator(0)]),
|
||||||
|
),
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name='progressupdate',
|
||||||
|
name='readthrough',
|
||||||
|
field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='bookwyrm.ReadThrough'),
|
||||||
|
),
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name='progressupdate',
|
||||||
|
name='remote_id',
|
||||||
|
field=bookwyrm.models.fields.RemoteIdField(max_length=255, null=True, validators=[bookwyrm.models.fields.validate_remote_id]),
|
||||||
|
),
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name='readthrough',
|
||||||
|
name='progress',
|
||||||
|
field=models.IntegerField(blank=True, null=True, validators=[django.core.validators.MinValueValidator(0)]),
|
||||||
|
),
|
||||||
|
]
|
|
@ -1,27 +1,27 @@
|
||||||
<form class="field is-grouped is-small" action="/edit-readthrough" method="POST">
|
<form class="field is-grouped is-small" action="/edit-readthrough" method="POST">
|
||||||
{% csrf_token %}
|
{% csrf_token %}
|
||||||
<input type="hidden" name="id" value="{{ readthrough.id }}"/>
|
<input type="hidden" name="id" value="{{ readthrough.id }}"/>
|
||||||
<label class="label is-align-self-center mb-0 pr-2" for="progress">Currently at</label>
|
<div class="field">
|
||||||
<div class="control">
|
<label class="label is-align-self-center mb-0 pr-2" for="progress">Progress:</label>
|
||||||
<div class="field has-addons">
|
<div class="field has-addons mb-0">
|
||||||
<div class="control">
|
<div class="control">
|
||||||
<input
|
<input
|
||||||
aria-label="{% if readthrough.progress_mode == 'PG' %}Current page{% else %}Percent read{% endif %}"
|
aria-label="{% if readthrough.progress_mode == 'PG' %}Current page{% else %}Percent read{% endif %}"
|
||||||
class="input is-small" type="number"
|
class="input is-small" type="number" min="0"
|
||||||
name="progress" size="3" value="{{ readthrough.progress|default:'' }}">
|
name="progress" size="3" value="{{ readthrough.progress|default:'' }}">
|
||||||
</div>
|
</div>
|
||||||
|
<div class="control select is-small">
|
||||||
|
<select name="progress_mode" aria-label="Progress mode">
|
||||||
|
<option value="PG" {% if readthrough.progress_mode == 'PG' %}selected{% endif %}>pages</option>
|
||||||
|
<option value="PCT" {% if readthrough.progress_mode == 'PCT' %}selected{% endif %}>percent</option>
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
<div class="control">
|
<div class="control">
|
||||||
<a class="button is-small is-static">
|
<button class="button is-small px-2 is-primary" type="submit">Save</button>
|
||||||
{% if readthrough.progress_mode == 'PG' %}
|
</div>
|
||||||
pages
|
</div>
|
||||||
{% else %}
|
{% if readthrough.progress_mode == 'PG' and book.pages %}
|
||||||
%
|
<p class="help">of {{ book.pages }} pages</p>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</a>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="control">
|
|
||||||
<button class="button is-small px-2" type="submit">Save</button>
|
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
|
|
|
@ -1,43 +1,16 @@
|
||||||
{% load humanize %}
|
{% load humanize %}
|
||||||
<div class="content block">
|
<div class="content block">
|
||||||
<div id="hide-edit-readthrough-{{ readthrough.id }}">
|
<div id="hide-edit-readthrough-{{ readthrough.id }}">
|
||||||
<dl class="mb-1">
|
<div class="columns">
|
||||||
{% if readthrough.start_date %}
|
<div class="column">
|
||||||
<div class="is-flex">
|
|
||||||
<dt>Started reading:</dt>
|
|
||||||
<dd>{{ readthrough.start_date | naturalday }}</dd>
|
|
||||||
</div>
|
|
||||||
{% endif %}
|
|
||||||
{% if readthrough.finish_date %}
|
|
||||||
<div class="is-flex">
|
|
||||||
<dt>Finished reading:</dt>
|
|
||||||
<dd>{{ readthrough.finish_date | naturalday }}</dd>
|
|
||||||
</div>
|
|
||||||
{% elif readthrough.progress %}
|
|
||||||
<div class="is-flex">
|
|
||||||
<dt>Progress:</dt>
|
|
||||||
{% if readthrough.progress_mode == 'PG' %}
|
|
||||||
<dd>on page {{ readthrough.progress }} of {{ book.pages }}</dd>
|
|
||||||
{% else %}
|
|
||||||
<dd>{{ readthrough.progress }}%</dd>
|
|
||||||
{% endif %}
|
|
||||||
</div>
|
|
||||||
{% endif %}
|
|
||||||
</dl>
|
|
||||||
<div class="field has-addons">
|
|
||||||
<div class="control">
|
|
||||||
{% include 'snippets/toggle/toggle_button.html' with class="is-small" text="Edit read dates" icon="pencil" controls_text="edit-readthrough" controls_uid=readthrough.id focus="edit-readthrough" %}
|
|
||||||
</div>
|
|
||||||
<div class="control">
|
|
||||||
{% include 'snippets/toggle/toggle_button.html' with class="is-small" text="Delete these read dates" icon="x" controls_text="delete-readthrough" controls_uid=readthrough.id focus="modal-title-delete-readthrough" %}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
{% if show_progress %}
|
|
||||||
Progress Updates:
|
Progress Updates:
|
||||||
|
</dl>
|
||||||
<ul>
|
<ul>
|
||||||
{% if readthrough.finish_date %}
|
{% if readthrough.progress %}
|
||||||
<li>{{ readthrough.start_date | naturalday }}: finished</li>
|
<li>{% if readthrough.finish_date %} {{ readthrough.finish_date | naturalday }}: finished {% else %}{% if readthrough.progress_mode == 'PG' %}on page {{ readthrough.progress }}{% if book.pages %} of {{ book.pages }}{% endif %}
|
||||||
{% endif %}
|
{% else %}{{ readthrough.progress }}%{% endif %}{% endif %}
|
||||||
|
{% include 'snippets/toggle/toggle_button.html' with text="Show all updates" controls_text="updates" controls_uid=readthrough.id class="is-small" %}
|
||||||
|
<ul id="updates-{{ readthrough.id }}" class="hidden">
|
||||||
{% for progress_update in readthrough.progress_updates %}
|
{% for progress_update in readthrough.progress_updates %}
|
||||||
<li>
|
<li>
|
||||||
<form name="delete-update" action="/delete-progressupdate" method="POST">
|
<form name="delete-update" action="/delete-progressupdate" method="POST">
|
||||||
|
@ -50,18 +23,30 @@
|
||||||
{% endif %}
|
{% endif %}
|
||||||
<input type="hidden" name="id" value="{{ progress_update.id }}"/>
|
<input type="hidden" name="id" value="{{ progress_update.id }}"/>
|
||||||
<button type="submit" class="button is-small" for="delete-progressupdate-{{ progress_update.id }}" role="button" tabindex="0">
|
<button type="submit" class="button is-small" for="delete-progressupdate-{{ progress_update.id }}" role="button" tabindex="0">
|
||||||
<span class="icon icon-x">
|
<span class="icon icon-x" title="Delete this progress update">
|
||||||
<span class="is-sr-only">Delete this progress update</span>
|
<span class="is-sr-only">Delete this progress update</span>
|
||||||
</span>
|
</span>
|
||||||
</button>
|
</button>
|
||||||
</form>
|
</form>
|
||||||
</li>
|
</li>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
|
</ul>
|
||||||
|
</li>
|
||||||
|
{% endif %}
|
||||||
<li>{{ readthrough.start_date | naturalday }}: started</li>
|
<li>{{ readthrough.start_date | naturalday }}: started</li>
|
||||||
</ul>
|
</ul>
|
||||||
{% elif readthrough.progress_updates|length %}
|
</div>
|
||||||
<a href="?showprogress">Show {{ readthrough.progress_updates|length }} Progress Updates</a>
|
<div class="column is-narrow">
|
||||||
{% endif %}
|
<div class="field has-addons">
|
||||||
|
<div class="control">
|
||||||
|
{% include 'snippets/toggle/toggle_button.html' with class="is-small" text="Edit read dates" icon="pencil" controls_text="edit-readthrough" controls_uid=readthrough.id focus="edit-readthrough" %}
|
||||||
|
</div>
|
||||||
|
<div class="control">
|
||||||
|
{% include 'snippets/toggle/toggle_button.html' with class="is-small" text="Delete these read dates" icon="x" controls_text="delete-readthrough" controls_uid=readthrough.id focus="modal-title-delete-readthrough" %}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
|
@ -9,26 +9,18 @@
|
||||||
</div>
|
</div>
|
||||||
{# Only show progress for editing existing readthroughs #}
|
{# Only show progress for editing existing readthroughs #}
|
||||||
{% if readthrough.id and not readthrough.finish_date %}
|
{% if readthrough.id and not readthrough.finish_date %}
|
||||||
<div class="columns">
|
<label class="label" for="id_progress-{{ readthrough.id }}">
|
||||||
<div class="column">
|
|
||||||
<div class="field">
|
|
||||||
<label class="label">
|
|
||||||
Progress
|
Progress
|
||||||
|
</label>
|
||||||
|
<div class="field has-addons">
|
||||||
|
<div class="control">
|
||||||
<input type="number" name="progress" class="input" id="id_progress-{{ readthrough.id }}" value="{{ readthrough.progress }}">
|
<input type="number" name="progress" class="input" id="id_progress-{{ readthrough.id }}" value="{{ readthrough.progress }}">
|
||||||
</label>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="column">
|
|
||||||
<div class="control mt-5">
|
|
||||||
<label class="radio">
|
|
||||||
<input type="radio" name="progress_mode" id="id_progress_mode-{{ readthrough.id }}" value="PG" {% if readthrough.progress_mode == 'PG' %}checked{% endif %}>
|
|
||||||
pages
|
|
||||||
</label>
|
|
||||||
<label class="radio">
|
|
||||||
<input type="radio" name="progress_mode" id="id_progress_mode-{{ readthrough.id }}" value="PCT" {% if readthrough.progress_mode == 'PCT' %}checked{% endif %}>
|
|
||||||
percent
|
|
||||||
</label>
|
|
||||||
</div>
|
</div>
|
||||||
|
<div class="control select">
|
||||||
|
<select name="progress_mode" aria-label="Progress mode">
|
||||||
|
<option value="PG" {% if readthrough.progress_mode == 'PG' %}selected{% endif %}>pages</option>
|
||||||
|
<option value="PCT" {% if readthrough.progress_mode == 'PCT' %}selected{% endif %}>percent</option>
|
||||||
|
</select>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
|
@ -74,7 +74,8 @@ class Book(View):
|
||||||
|
|
||||||
for readthrough in readthroughs:
|
for readthrough in readthroughs:
|
||||||
readthrough.progress_updates = \
|
readthrough.progress_updates = \
|
||||||
readthrough.progressupdate_set.all().order_by('-updated_date')
|
readthrough.progressupdate_set.all() \
|
||||||
|
.order_by('-updated_date')
|
||||||
|
|
||||||
user_shelves = models.ShelfBook.objects.filter(
|
user_shelves = models.ShelfBook.objects.filter(
|
||||||
added_by=request.user, book=book
|
added_by=request.user, book=book
|
||||||
|
@ -98,7 +99,6 @@ class Book(View):
|
||||||
'user_shelves': user_shelves,
|
'user_shelves': user_shelves,
|
||||||
'other_edition_shelves': other_edition_shelves,
|
'other_edition_shelves': other_edition_shelves,
|
||||||
'readthroughs': readthroughs,
|
'readthroughs': readthroughs,
|
||||||
'show_progress': ('showprogress' in request.GET),
|
|
||||||
'path': '/book/%s' % book_id,
|
'path': '/book/%s' % book_id,
|
||||||
}
|
}
|
||||||
return TemplateResponse(request, 'book.html', data)
|
return TemplateResponse(request, 'book.html', data)
|
||||||
|
|
Loading…
Reference in a new issue