UI for editable readthroughs
This commit is contained in:
parent
f35ed0e555
commit
5641c36539
|
@ -29,6 +29,7 @@ class CustomForm(ModelForm):
|
||||||
visible.field.widget.attrs['rows'] = None
|
visible.field.widget.attrs['rows'] = None
|
||||||
visible.field.widget.attrs['class'] = css_classes[input_type]
|
visible.field.widget.attrs['class'] = css_classes[input_type]
|
||||||
|
|
||||||
|
|
||||||
class LoginForm(CustomForm):
|
class LoginForm(CustomForm):
|
||||||
class Meta:
|
class Meta:
|
||||||
model = models.User
|
model = models.User
|
||||||
|
@ -158,3 +159,9 @@ class CreateInviteForm(CustomForm):
|
||||||
choices=[(i, "%d uses" % (i,)) for i in [1, 5, 10, 25, 50, 100]]
|
choices=[(i, "%d uses" % (i,)) for i in [1, 5, 10, 25, 50, 100]]
|
||||||
+ [(None, 'Unlimited')])
|
+ [(None, 'Unlimited')])
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
class ReadThroughForm(CustomForm):
|
||||||
|
class Meta:
|
||||||
|
model = models.ReadThrough
|
||||||
|
fields = ['user', 'book', 'start_date', 'finish_date']
|
||||||
|
|
|
@ -56,10 +56,60 @@
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{% for readthrough in readthroughs %}
|
{% for readthrough in readthroughs %}
|
||||||
<div class="block">
|
<div class="content block">
|
||||||
{{ readthrough.start_date }}
|
<input class="toggle-control" type="radio" name="show-edit-readthrough" id="show-readthrough-{{ readthrough.id }}" checked>
|
||||||
{{ readthrough.finish_date }}
|
<div class="toggle-content hidden">
|
||||||
{{ readthrough.pages_read }}
|
<dl>
|
||||||
|
<dt>Started reading:</dt>
|
||||||
|
<dd>{{ readthrough.start_date | naturalday }}</dd>
|
||||||
|
<dt>Finished reading:</dt>
|
||||||
|
<dd>{{ readthrough.finish_date | naturalday }}</dd>
|
||||||
|
</dl>
|
||||||
|
<div class="field is-grouped">
|
||||||
|
<label class="button is-small" for="edit-readthrough-{{ readthrough.id }}">
|
||||||
|
<span class="icon icon-pencil">
|
||||||
|
<span class="is-sr-only">Edit readthrough dates</span>
|
||||||
|
</span>
|
||||||
|
</label>
|
||||||
|
<form name="delete-readthrough-{{ readthrough.id }}" action="/delete-readthrough" method="POST">
|
||||||
|
{% csrf_token %}
|
||||||
|
<input type="hidden" name="readthrough" value="{{ readthrough.id }}">
|
||||||
|
<button class="button is-small" type="submit">
|
||||||
|
<span class="icon icon-x">
|
||||||
|
<span class="is-sr-only">Delete this readthrough</span>
|
||||||
|
</span>
|
||||||
|
</button>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="content block">
|
||||||
|
<input class="toggle-control" type="radio" name="show-edit-readthrough" id="edit-readthrough-{{ readthrough.id }}">
|
||||||
|
<div class="toggle-content hidden">
|
||||||
|
<form name="edit-readthrough" action="/edit-readthrough" method="post">
|
||||||
|
{% csrf_token %}
|
||||||
|
<input type="hidden" name="id" value="{{ readthrough.id }}">
|
||||||
|
<input type="hidden" name="user" value="{{ request.user.id }}">
|
||||||
|
<input type="hidden" name="book" value="{{ readthrough.book.id }}">
|
||||||
|
<div class="field">
|
||||||
|
<label class="label" for="start_date-{{ readthrough.id }}">
|
||||||
|
Started reading
|
||||||
|
<input type="date" name="start_date-{{ readthrough.id }}" 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-{{ readthrough.id }}">
|
||||||
|
Finished reading
|
||||||
|
<input type="date" name="finish_date-{{ readthrough.id }}" class="input" id="id_finish_date-{{ readthrough.id }}" value="{{ readthrough.finish_date | date:"Y-m-d" }}">
|
||||||
|
</label>
|
||||||
|
</div>
|
||||||
|
<div class="field is-grouped">
|
||||||
|
<button class="button is-small" type="submit">Save</button>
|
||||||
|
<label class="button is-small" for="show-readthrough-{{ readthrough.id }}">Cancel</label>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
|
|
||||||
|
|
|
@ -493,7 +493,6 @@ def book_page(request, book_id):
|
||||||
book=book,
|
book=book,
|
||||||
).order_by('start_date')
|
).order_by('start_date')
|
||||||
|
|
||||||
|
|
||||||
rating = reviews.aggregate(Avg('rating'))
|
rating = reviews.aggregate(Avg('rating'))
|
||||||
tags = models.Tag.objects.filter(
|
tags = models.Tag.objects.filter(
|
||||||
book=book
|
book=book
|
||||||
|
@ -508,10 +507,10 @@ def book_page(request, book_id):
|
||||||
'rating': rating['rating__avg'],
|
'rating': rating['rating__avg'],
|
||||||
'tags': tags,
|
'tags': tags,
|
||||||
'user_tags': user_tags,
|
'user_tags': user_tags,
|
||||||
'readthroughs': readthroughs,
|
|
||||||
'review_form': forms.ReviewForm(),
|
'review_form': forms.ReviewForm(),
|
||||||
'quotation_form': forms.QuotationForm(),
|
'quotation_form': forms.QuotationForm(),
|
||||||
'comment_form': forms.CommentForm(),
|
'comment_form': forms.CommentForm(),
|
||||||
|
'readthroughs': readthroughs,
|
||||||
'tag_form': forms.TagForm(),
|
'tag_form': forms.TagForm(),
|
||||||
'path': '/book/%s' % book_id,
|
'path': '/book/%s' % book_id,
|
||||||
'cover_form': forms.CoverForm(instance=book),
|
'cover_form': forms.CoverForm(instance=book),
|
||||||
|
|
Loading…
Reference in New Issue