From 5641c36539555938f0a47f0f82cddeb6d33c39c1 Mon Sep 17 00:00:00 2001 From: Mouse Reeve Date: Thu, 29 Oct 2020 22:38:01 -0700 Subject: [PATCH 1/3] UI for editable readthroughs --- bookwyrm/forms.py | 7 +++++ bookwyrm/templates/book.html | 58 +++++++++++++++++++++++++++++++++--- bookwyrm/views.py | 3 +- 3 files changed, 62 insertions(+), 6 deletions(-) diff --git a/bookwyrm/forms.py b/bookwyrm/forms.py index 0c3b19ba4..1edc5d5c2 100644 --- a/bookwyrm/forms.py +++ b/bookwyrm/forms.py @@ -29,6 +29,7 @@ class CustomForm(ModelForm): visible.field.widget.attrs['rows'] = None visible.field.widget.attrs['class'] = css_classes[input_type] + class LoginForm(CustomForm): class Meta: model = models.User @@ -158,3 +159,9 @@ class CreateInviteForm(CustomForm): choices=[(i, "%d uses" % (i,)) for i in [1, 5, 10, 25, 50, 100]] + [(None, 'Unlimited')]) } + + +class ReadThroughForm(CustomForm): + class Meta: + model = models.ReadThrough + fields = ['user', 'book', 'start_date', 'finish_date'] diff --git a/bookwyrm/templates/book.html b/bookwyrm/templates/book.html index c5d529ed9..8b1696008 100644 --- a/bookwyrm/templates/book.html +++ b/bookwyrm/templates/book.html @@ -56,10 +56,60 @@ {% for readthrough in readthroughs %} -
- {{ readthrough.start_date }} - {{ readthrough.finish_date }} - {{ readthrough.pages_read }} +
+ + +
+ +
+ +
{% endfor %} diff --git a/bookwyrm/views.py b/bookwyrm/views.py index b1bb25f45..67586a229 100644 --- a/bookwyrm/views.py +++ b/bookwyrm/views.py @@ -493,7 +493,6 @@ def book_page(request, book_id): book=book, ).order_by('start_date') - rating = reviews.aggregate(Avg('rating')) tags = models.Tag.objects.filter( book=book @@ -508,10 +507,10 @@ def book_page(request, book_id): 'rating': rating['rating__avg'], 'tags': tags, 'user_tags': user_tags, - 'readthroughs': readthroughs, 'review_form': forms.ReviewForm(), 'quotation_form': forms.QuotationForm(), 'comment_form': forms.CommentForm(), + 'readthroughs': readthroughs, 'tag_form': forms.TagForm(), 'path': '/book/%s' % book_id, 'cover_form': forms.CoverForm(instance=book), From e39bf026cb8cc4f4f485609c7fd7b19f72711afa Mon Sep 17 00:00:00 2001 From: Mouse Reeve Date: Fri, 30 Oct 2020 10:40:05 -0700 Subject: [PATCH 2/3] Handle edit and delete readthroughs --- bookwyrm/templates/book.html | 12 ++++----- bookwyrm/urls.py | 3 +++ bookwyrm/view_actions.py | 47 ++++++++++++++++++++++++++++++++++++ 3 files changed, 55 insertions(+), 7 deletions(-) diff --git a/bookwyrm/templates/book.html b/bookwyrm/templates/book.html index 8b1696008..f05fd7edd 100644 --- a/bookwyrm/templates/book.html +++ b/bookwyrm/templates/book.html @@ -73,7 +73,7 @@
{% csrf_token %} - +