Book page and review form

This commit is contained in:
Mouse Reeve 2020-09-29 11:00:54 -07:00
parent 32f305e285
commit 61fa15a0c2
6 changed files with 96 additions and 62 deletions

View file

@ -54,6 +54,29 @@ input.toggle-control:checked ~ .toggle-content {
content: '\e9d7';
}
/* stars in a review form */
.form-rate-stars:hover .icon:before {
content: '\e9d9';
}
.form-rate-stars input + .icon:before {
content: '\e9d9';
}
.form-rate-stars input:checked + .icon:before {
content: '\e9d9';
}
.form-rate-stars input:checked + * ~ .icon:before {
content: '\e9d7';
}
.form-rate-stars:hover label.icon:before {
content: '\e9d9';
}
.form-rate-stars label.icon:hover:before {
content: '\e9d9';
}
.form-rate-stars label.icon:hover ~ label.icon:before{
content: '\e9d7';
}
/* --- BOOK COVERS --- */
.book-cover {

View file

@ -47,9 +47,9 @@ function tabChange(e) {
var tabs = target.parentElement.children;
for (i = 0; i < tabs.length; i++) {
if (tabs[i].getAttribute('data-id') == identifier) {
tabs[i].className += ' active';
tabs[i].className += ' is-active';
} else {
tabs[i].className = tabs[i].className.replace('active', '');
tabs[i].className = tabs[i].className.replace('is-active', '');
}
}

View file

@ -1,22 +1,26 @@
{% extends 'layout.html' %}
{% load fr_display %}
{% block content %}
<div class="content-container">
<h2>
{% include 'snippets/book_titleby.html' with book=book %}
{% if request.user.is_authenticated %}
<a href="{{ book.id }}/edit" class="edit-link">edit
<span class="icon icon-pencil">
<span class="hidden-text">Edit Book</span>
</span>
</a>
{% endif %}
</h2>
<div class="block">
<div class="level">
<h2 class="title level-left">
<span>{% include 'snippets/book_titleby.html' with book=book %}</span>
</h2>
<div class="row">
{% if request.user.is_authenticated %}
<div class="level-right">
<a href="{{ book.id }}/edit">edit
<span class="icon icon-pencil">
<span class="hidden-text">Edit Book</span>
</span>
</a>
</div>
{% endif %}
</div>
<div class="cover-container">
<div class="columns">
<div class="column is-narrow">
{% include 'snippets/book_cover.html' with book=book size=large %}
{% include 'snippets/rate_action.html' with user=request.user book=book %}
{% include 'snippets/shelve_button.html' %}
@ -25,69 +29,66 @@
<form name="add-cover" method="POST" action="/upload_cover/{{ book.id }}" enctype="multipart/form-data">
{% csrf_token %}
{{ cover_form.as_p }}
<button type="submit">Add cover</button>
<button class="button" type="submit">Add cover</button>
</form>
{% endif %}
<dl>
{% for field in info_fields %}
<dl class="content">
{% for field in info_fields %}
{% if field.value %}
<dt>{{ field.name }}:</dt>
<dd>{{ field.value }}</dd>
{% endif %}
{% endfor %}
{% endfor %}
</dl>
</div>
<div class="column">
<h3>{{ active_tab }} rating: {% include 'snippets/stars.html' with rating=rating %}</h3>
<div class="block">
<h3>{% include 'snippets/stars.html' with rating=rating %}</h3>
{% include 'snippets/book_description.html' %}
{% include 'snippets/book_description.html' %}
{% if book.parent_work.edition_set.count > 1 %}
<p><a href="/editions/{{ book.parent_work.id }}">{{ book.parent_work.edition_set.count }} editions</a></p>
{% endif %}
{% if book.parent_work.edition_set.count > 1 %}
<p><a href="/editions/{{ book.parent_work.id }}">{{ book.parent_work.edition_set.count }} editions</a></p>
{% endif %}
</div>
{% if request.user.is_authenticated %}
<div class="compose">
<div class="block">
{% include 'snippets/create_status.html' with book=book hide_cover=True %}
</div>
<div>
<div class="block">
<h3>Tags</h3>
<form name="tag" action="/tag/" method="post">
{% csrf_token %}
<input type="hidden" name="book" value="{{ book.id }}">
<input type="text" name="name">
<button type="submit">Add tag</button>
<input class="input" type="text" name="name">
<button class="button" type="submit">Add tag</button>
</form>
</div>
<div class="tag-cloud">
{% endif %}
<div class="block">
{% for tag in tags %}
{% include 'snippets/tag.html' with book=book tag=tag user_tags=user_tags %}
{% endfor %}
</div>
{% endif %}
</div>
</div>
</div>
{% if request.user.is_authenticated %}
<div class="content-container tabs">
{% include 'snippets/tabs.html' with tabs=feed_tabs active_tab=active_tab path=path %}
</div>
{% endif %}
{% if not reviews %}
<div class="content-container">
<div class="block">
<p>No reviews yet!</p>
</div>
{% endif %}
{% for review in reviews %}
<div class="content-container">
<div class="block">
{% include 'snippets/status.html' with status=review hide_book=True depth=1 %}
</div>
{% endfor %}

View file

@ -1,6 +1,6 @@
{% load fr_display %}
{% if book.description %}
<blockquote>{{ book.description | description }}</blockquote>
<blockquote class="content">{{ book.description | description }}</blockquote>
{% elif book.parent_work.description %}
<blockquote>{{ book.parent_work.description | description }}</blockquote>
{% endif %}

View file

@ -1,43 +1,53 @@
{% load humanize %}
{% load fr_display %}
<div class="tabs secondary">
<div class="tab active" data-id="tab-review-{{ book.id }}" data-category="tab-option-{{ book.id }}">
<a href="/book/{{ book.id }}/review" onclick="tabChange(event)">Review</a>
</div>
<div class="tab" data-id="tab-comment-{{ book.id }}" data-category="tab-option-{{ book.id }}">
<a href="/book/{{ book.id }}/comment" onclick="tabChange(event)">Comment</a>
</div>
<div class="tab" data-id="tab-quotation-{{ book.id }}" data-category="tab-option-{{ book.id }}">
<a href="/book/{{ book.id }}/quotation" onclick="tabChange(event)">Quote</a>
</div>
<div class="tabs is-boxed">
<ul>
<li class="is-active" data-id="tab-review-{{ book.id }}" data-category="tab-option-{{ book.id }}">
<a href="/book/{{ book.id }}/review" onclick="tabChange(event)">Review</a>
</li>
<li data-id="tab-comment-{{ book.id }}" data-category="tab-option-{{ book.id }}">
<a href="/book/{{ book.id }}/comment" onclick="tabChange(event)">Comment</a>
</li>
<li data-id="tab-quotation-{{ book.id }}" data-category="tab-option-{{ book.id }}">
<a href="/book/{{ book.id }}/quotation" onclick="tabChange(event)">Quote</a>
</li>
</ul>
</div>
<div class="book-preview row">
<div class="columns">
{% if not hide_cover %}
<div class="cover-container">
<div class="column is-narrow">
{% include 'snippets/book_cover.html' with book=book %}
</div>
{% endif %}
<form class="tab-option-{{ book.id }} review-form" name="review" action="/review/" method="post" id="tab-review-{{ book.id }}">
<form class="tab-option-{{ book.id }} column" name="review" action="/review/" method="post" id="tab-review-{{ book.id }}">
{% csrf_token %}
<input type="hidden" name="book" value="{{ book.id }}">
{% include 'snippets/rate_form.html' with book=book %}
{{ review_form.as_p }}
<button type="submit">post review</button>
<div class="control">
<label class="label" for="id_name">Title:</label>
{{ review_form.name }}
</div>
<div class="control">
<label class="label" for="id_content">Review:</label>
{% include 'snippets/rate_form.html' with book=book %}
{{ review_form.content }}
</div>
<button class="button is-primary" type="submit">post review</button>
</form>
<form class="hidden tab-option-{{ book.id }} review-form" name="comment" action="/comment/" method="post" id="tab-comment-{{ book.id }}">
<form class="hidden tab-option-{{ book.id }} column" name="comment" action="/comment/" method="post" id="tab-comment-{{ book.id }}">
{% csrf_token %}
<input type="hidden" name="book" value="{{ book.id }}">
{{ comment_form.as_p }}
<button type="submit">post comment</button>
<button class="button is-primary" type="submit">post comment</button>
</form>
<form class="hidden tab-option-{{ book.id }} review-form quote-form" name="quotation" action="/quotate/" method="post" id="tab-quotation-{{ book.id }}">
<form class="hidden tab-option-{{ book.id }} column" name="quotation" action="/quotate/" method="post" id="tab-quotation-{{ book.id }}">
{% csrf_token %}
<input type="hidden" name="book" value="{{ book.id }}">
{{ quotation_form.as_p }}
<button typr="submit">post quote</button>
<button class="button is-primary" type="submit">post quote</button>
</form>
</div>

View file

@ -1,9 +1,9 @@
{% load fr_display %}
<span class="hidden-text">Rating</span>
<div class="field is-grouped stars rate-stars">
<input type="radio" name="rating" value="" checked>
<div class="field is-grouped stars form-rate-stars">
<input class="hidden" type="radio" name="rating" value="" checked>
{% for i in '12345'|make_list %}
<input id="book{{book.id}}-star-{{ forloop.counter }}" type="radio" name="rating" value="{{ forloop.counter }}">
<input class="hidden" id="book{{book.id}}-star-{{ forloop.counter }}" type="radio" name="rating" value="{{ forloop.counter }}">
<label class="icon icon-star-empty" for="book{{book.id}}-star-{{ forloop.counter }}">
<span class="hidden-text">{{ forloop.counter }} star{{ forloop.counter | pluralize }}</span>
</label>