diff --git a/fedireads/forms.py b/fedireads/forms.py index 5041cfe6..ffbf6cd1 100644 --- a/fedireads/forms.py +++ b/fedireads/forms.py @@ -35,11 +35,10 @@ class RatingForm(ModelForm): class ReviewForm(ModelForm): class Meta: model = models.Review - fields = ['name', 'rating', 'content'] + fields = ['name', 'content'] help_texts = {f: None for f in fields} labels = { 'name': 'Title', - 'rating': 'Rating (out of 5)', 'content': 'Review', } diff --git a/fedireads/static/format.css b/fedireads/static/format.css index 32919692..b3cfaca3 100644 --- a/fedireads/static/format.css +++ b/fedireads/static/format.css @@ -326,7 +326,7 @@ button .icon { display: inline; width: min-content; } -.rate-stars form button.icon { +.rate-stars button.icon { background: none; border: none; padding: 0; @@ -336,10 +336,35 @@ button .icon { .rate-stars:hover .icon:before { content: '\e9d9'; } +.rate-stars label { + display: inline; +} .rate-stars form:hover ~ form .icon:before{ content: '\e9d7'; } +.rate-stars input + .icon:before { + content: '\e9d9'; +} +.rate-stars input:checked + .icon:before { + content: '\e9d9'; +} +.rate-stars input:checked + * ~ .icon:before { + content: '\e9d7'; +} +.rate-stars:hover label.icon:before { + content: '\e9d9'; +} +.rate-stars label.icon:hover:before { + content: '\e9d9'; + } +.rate-stars label.icon:hover ~ label.icon:before{ + content: '\e9d7'; +} +.rate-stars input[type="radio"] { + display: none; +} + /* re-usable tab styles */ .tabs { display: flex; diff --git a/fedireads/templates/snippets/create_status.html b/fedireads/templates/snippets/create_status.html index 1f833f07..2913e8a6 100644 --- a/fedireads/templates/snippets/create_status.html +++ b/fedireads/templates/snippets/create_status.html @@ -4,7 +4,7 @@

{% include 'snippets/avatar.html' with user=user %} Your thoughts on - {{ book.title }} +a {{ book.title }} by {% include 'snippets/authors.html' with book=book %}

@@ -27,6 +27,7 @@
{% csrf_token %} + {% include 'snippets/rate_form.html' with book=book %} {{ review_form.as_p }}
diff --git a/fedireads/templatetags/fr_display.py b/fedireads/templatetags/fr_display.py index f07d720b..8a81776a 100644 --- a/fedireads/templatetags/fr_display.py +++ b/fedireads/templatetags/fr_display.py @@ -20,7 +20,6 @@ def get_rating(book, user): book=book, rating__isnull=False, ).order_by('-published_date').first() - print(rating.rating, '\n\n\n') if rating: return rating.rating return 0 diff --git a/fedireads/view_actions.py b/fedireads/view_actions.py index f505288d..8f053a1a 100644 --- a/fedireads/view_actions.py +++ b/fedireads/view_actions.py @@ -213,9 +213,13 @@ def review(request): return redirect('/book/%s' % book_identifier) # TODO: validation, htmlification - name = form.data.get('name') - content = form.data.get('content') - rating = form.cleaned_data.get('rating') + name = form.cleaned_data.get('name') + content = form.cleaned_data.get('content') + rating = form.data.get('rating', None) + try: + rating = int(rating) + except ValueError: + rating = None # throws a value error if the book is not found book = get_or_create_book(book_identifier)