mirror of
https://github.com/bookwyrm-social/bookwyrm.git
synced 2024-11-27 20:11:14 +00:00
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">
|
||||
{% csrf_token %}
|
||||
<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="control">
|
||||
<div class="field has-addons">
|
||||
<div class="field">
|
||||
<label class="label is-align-self-center mb-0 pr-2" for="progress">Progress:</label>
|
||||
<div class="field has-addons mb-0">
|
||||
<div class="control">
|
||||
<input
|
||||
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:'' }}">
|
||||
</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">
|
||||
<a class="button is-small is-static">
|
||||
{% if readthrough.progress_mode == 'PG' %}
|
||||
pages
|
||||
{% else %}
|
||||
%
|
||||
<button class="button is-small px-2 is-primary" type="submit">Save</button>
|
||||
</div>
|
||||
</div>
|
||||
{% if readthrough.progress_mode == 'PG' and book.pages %}
|
||||
<p class="help">of {{ book.pages }} pages</p>
|
||||
{% endif %}
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="control">
|
||||
<button class="button is-small px-2" type="submit">Save</button>
|
||||
</div>
|
||||
</form>
|
||||
|
|
|
@ -1,43 +1,16 @@
|
|||
{% load humanize %}
|
||||
<div class="content block">
|
||||
<div id="hide-edit-readthrough-{{ readthrough.id }}">
|
||||
<dl class="mb-1">
|
||||
{% if readthrough.start_date %}
|
||||
<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 %}
|
||||
<div class="columns">
|
||||
<div class="column">
|
||||
Progress Updates:
|
||||
</dl>
|
||||
<ul>
|
||||
{% if readthrough.finish_date %}
|
||||
<li>{{ readthrough.start_date | naturalday }}: finished</li>
|
||||
{% endif %}
|
||||
{% if readthrough.progress %}
|
||||
<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 %}
|
||||
{% 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 %}
|
||||
<li>
|
||||
<form name="delete-update" action="/delete-progressupdate" method="POST">
|
||||
|
@ -50,18 +23,30 @@
|
|||
{% endif %}
|
||||
<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">
|
||||
<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>
|
||||
</button>
|
||||
</form>
|
||||
</li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
</li>
|
||||
{% endif %}
|
||||
<li>{{ readthrough.start_date | naturalday }}: started</li>
|
||||
</ul>
|
||||
{% elif readthrough.progress_updates|length %}
|
||||
<a href="?showprogress">Show {{ readthrough.progress_updates|length }} Progress Updates</a>
|
||||
{% endif %}
|
||||
</div>
|
||||
<div class="column is-narrow">
|
||||
<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>
|
||||
|
||||
|
|
|
@ -9,26 +9,18 @@
|
|||
</div>
|
||||
{# Only show progress for editing existing readthroughs #}
|
||||
{% if readthrough.id and not readthrough.finish_date %}
|
||||
<div class="columns">
|
||||
<div class="column">
|
||||
<div class="field">
|
||||
<label class="label">
|
||||
<label class="label" for="id_progress-{{ readthrough.id }}">
|
||||
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 }}">
|
||||
</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 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>
|
||||
{% endif %}
|
||||
|
|
|
@ -74,7 +74,8 @@ class Book(View):
|
|||
|
||||
for readthrough in readthroughs:
|
||||
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(
|
||||
added_by=request.user, book=book
|
||||
|
@ -98,7 +99,6 @@ class Book(View):
|
|||
'user_shelves': user_shelves,
|
||||
'other_edition_shelves': other_edition_shelves,
|
||||
'readthroughs': readthroughs,
|
||||
'show_progress': ('showprogress' in request.GET),
|
||||
'path': '/book/%s' % book_id,
|
||||
}
|
||||
return TemplateResponse(request, 'book.html', data)
|
||||
|
|
Loading…
Reference in a new issue