html for updated reading progress flow

This commit is contained in:
Mouse Reeve 2020-11-05 16:48:15 -08:00
parent 7612df5161
commit 7bf39d3bf7
6 changed files with 155 additions and 55 deletions

View file

@ -15,6 +15,10 @@ input.toggle-control:checked ~ .toggle-content {
display: block;
}
input.toggle-control:checked ~ .modal.toggle-content {
display: flex;
}
/* --- STARS --- */
.rate-stars button.icon {
background: none;

View file

@ -44,14 +44,7 @@
<textarea name="content" class="textarea" id="id_content_{{ book.id }}_review"></textarea>
</div>
<div class="control is-grouped">
<div class="select">
<select name="privacy">
<option value="public" selected>Public</option>
<option value="unlisted">Unlisted</option>
<option value="followers">Followers only</option>
<option value="direct">Private</option>
</select>
</div>
{% include 'snippets/privacy_select.html' %}
<button class="button is-primary" type="submit">post review</button>
</div>
</form>

View file

@ -13,14 +13,7 @@
<div class="column is-narrow">
<div class="field">
<div class="select">
<select name="privacy">
<option value="public" selected>Public</option>
<option value="unlisted">Unlisted</option>
<option value="followers">Followers only</option>
<option value="direct">Private</option>
</select>
</div>
{% include 'snippets/privacy_select.html' %}
</div>
<div class="field">
<button class="button is-primary" type="submit">

View file

@ -1,34 +1,137 @@
{% load fr_display %}
{% if request.user.is_authenticated %}
{% with book.id|uuid as uuid %}
{% active_shelf book as active_shelf %}
<div class="field is-grouped">
<form name="shelve" action="/shelve/" method="post">
{% csrf_token %}
<input type="hidden" name="book" value="{{ book.id }}">
<input type="hidden" name="shelf" value="{% shelve_button_identifier book %}">
<button class="button is-small" type="submit" style="">{% shelve_button_text book %}</button>
</form>
<div class="dropdown is-hoverable">
{% if not hide_pulldown %}
<div class="button dropdown-trigger is-small" >
<span class="icon icon-arrow-down"><span class="is-sr-only">More shelves</span></span>
</div>
<div class="dropdown-menu">
<ul class="dropdown-content">
<form class="dropdown-item" name="shelve" action="/shelve/" method="post">
{% csrf_token %}
<input type="hidden" name="book" value="{{ book.id }}">
{% for shelf in request.user.shelf_set.all %}
<li>
<button class="is-small" name="shelf" type="submit" value="{{ shelf.identifier }}" {% if shelf in book.shelf_set.all %} disabled {% endif %}>{{ shelf.name }} {% if shelf in book.shelf_set.all %} ✓ {% endif %}</button>
</li>
{% endfor %}
</form>
</ul>
</div>
{% if active_shelf.identifier == 'read' %}
<button class="button is-small" disabled>Read ✓</button>
{% elif active_shelf.identifier == 'reading' %}
<label class="button is-small" for="finish-reading-{{ uuid }}">
I'm done!
</label>
{% elif active_shelf.identifier == 'to-read' %}
<label class="button is-small" for="start-reading-{{ uuid }}">
Start reading
</label>
{% else %}
<form name="shelve" action="/shelve/" method="post">
{% csrf_token %}
<input type="hidden" name="book" value="{{ book.id }}">
<input type="hidden" name="shelf" value="to-read">
<button class="button is-small" type="submit">Want to read</button>
</form>
{% endif %}
<div class="dropdown is-hoverable">
<div class="button dropdown-trigger is-small">
<span class="icon icon-arrow-down"><span class="is-sr-only">More shelves</span></span>
</div>
<div class="dropdown-menu">
<ul class="dropdown-content">
<form class="dropdown-item" name="shelve" action="/shelve/" method="post">
{% csrf_token %}
<input type="hidden" name="book" value="{{ book.id }}">
{% for shelf in request.user.shelf_set.all %}
<li>
<button class="button is-small" name="shelf" type="submit" value="{{ shelf.identifier }}" {% if shelf in book.shelf_set.all %} disabled {% endif %}>{{ shelf.name }} {% if shelf in book.shelf_set.all %} ✓ {% endif %}</button>
</li>
{% endfor %}
</form>
</ul>
</div>
</div>
</div>
<div>
<input class="toggle-control" type="checkbox" name="start-reading-{{ uuid }}" id="start-reading-{{ uuid }}">
<div class="modal toggle-content hidden">
<div class="modal-background"></div>
<div class="modal-card">
<header class="modal-card-head">
<p class="modal-card-title">Reading "{{ book.title }}"</p>
<label class="delete" for="start-reading-{{ uuid }}" aria-label="close"></label>
</header>
<form name="start-reading" action="/start-reading" method="post">
<section class="modal-card-body">
{% csrf_token %}
<div class="field">
<label class="label" for="start_date">
Started reading
<input type="date" name="start_date" class="input" id="id_start_date-{{ uuid }}" value="{% now "Y-m-d" %}">
</label>
</div>
</form>
</section>
<footer class="modal-card-foot">
<div class="columns">
<div class="column field is-grouped">
{% include 'snippets/privacy_select.html' %}
<label for="post-status">
<input type="checkbox" name="post-status" class="checkbox" checked>
Post to feed
</label>
</div>
<div class="column">
<button class="button is-success">Save</button>
<button class="button">Cancel</button>
</div>
</div>
</footer>
</form>
</div>
<label class="modal-close is-large" for="finish-reading-{{ uuid }}" aria-label="close"></label>
</div>
</div>
<div>
<input class="toggle-control" type="checkbox" name="finish-reading-{{ uuid }}" id="finish-reading-{{ uuid }}">
<div class="modal toggle-content hidden">
<div class="modal-background"></div>
<div class="modal-card">
<header class="modal-card-head">
<p class="modal-card-title">Finished "{{ book.title }}"</p>
<label class="delete" for="finish-reading-{{ uuid }}" aria-label="close"></label>
</header>
{% active_read_through book user as readthrough %}
<form name="finish-reading" action="/finish-reading" method="post">
<section class="modal-card-body">
{% csrf_token %}
<input type="hidden" name="id" value="{{ readthrough.id }}">
<div class="field">
<label class="label" for="start_date">
Started reading
<input type="date" name="start_date" class="input" id="id_start_date-{{ readthrough.id }}" value="{{ readthrough.start_date | date:"Y-m-d" }}">
</label>
</div>
<div class="field">
<label class="label" for="finish_date">
Finished reading
<input type="date" name="finish_date" class="input" id="id_finish_date-{{ readthrough.id }}" value="{% now "Y-m-d" %}">
</label>
</div>
</form>
</section>
<footer class="modal-card-foot">
<div class="columns">
<div class="column field is-grouped">
{% include 'snippets/privacy_select.html' %}
<label for="post-status">
<input type="checkbox" name="post-status" class="checkbox" checked>
Post to feed
</label>
</div>
<div class="column">
<button class="button is-success">Save</button>
<button class="button">Cancel</button>
</div>
</div>
</footer>
</form>
</div>
<label class="modal-close is-large" for="finish-reading-{{ uuid }}" aria-label="close"></label>
</div>
</div>
{% endwith %}
{% endif %}

View file

@ -158,22 +158,14 @@ def time_since(date):
@register.simple_tag(takes_context=True)
def shelve_button_identifier(context, book):
def active_shelf(context, book):
''' check what shelf a user has a book on, if any '''
#TODO: books can be on multiple shelves, handle that better
shelf = models.ShelfBook.objects.filter(
shelf__user=context['request'].user,
book=book
).first()
if not shelf:
return 'to-read'
identifier = shelf.shelf.identifier
if identifier == 'to-read':
return 'reading'
if identifier == 'reading':
return 'read'
return 'to-read'
return shelf.shelf if shelf else None
@register.simple_tag(takes_context=True)
@ -192,7 +184,7 @@ def shelve_button_text(context, book):
return 'Start reading'
if identifier == 'reading':
return 'I\'m done!'
return 'Want to read'
return 'Read'
@register.simple_tag(takes_context=False)
@ -200,4 +192,15 @@ def latest_read_through(book, user):
''' the most recent read activity '''
return models.ReadThrough.objects.filter(
user=user,
book=book).order_by('-created_date').first()
book=book
).order_by('-start_date').first()
@register.simple_tag(takes_context=False)
def active_read_through(book, user):
''' the most recent read activity '''
return models.ReadThrough.objects.filter(
user=user,
book=book,
finish_date__isnull=True
).order_by('-start_date').first()

View file

@ -71,7 +71,7 @@ def home_tab(request, tab):
models.Edition.objects.filter(
shelves__user=request.user,
shelves__identifier='read'
)[:2],
).order_by('-updated_date')[:2],
# to-read
models.Edition.objects.filter(
shelves__user=request.user,
@ -242,7 +242,11 @@ def about_page(request):
def password_reset_request(request):
''' invite management page '''
return TemplateResponse(request, 'password_reset_request.html', {'title': 'Reset Password'})
return TemplateResponse(
request,
'password_reset_request.html',
{'title': 'Reset Password'}
)
def password_reset(request, code):