|
3 | 3 | {% block title %}{{ book.title }}{% endblock %}
|
4 | 4 |
|
5 | 5 | {% block content %}
|
6 |
| - <h1>{{ book.title }}</h1> |
7 |
| - <div class="row"> |
8 |
| - <div class="col-sm-12 col-md-6 col-lg-4 my-2"> |
9 |
| - {% if not book.image %} |
10 |
| - <img class="img-fluid" src="../../static/images/NoCover.jpeg"> |
11 |
| - {% else %} |
12 |
| - <img class="img-fluid" src="{{ book.image }}"> |
13 |
| - {% endif %} |
14 |
| - <div class="d-grid gap-2"> |
15 |
| - {% if not read_by_user %} |
16 |
| - <button type="button" id="read-button" class="btn btn-primary my-2">Mark as read</button> |
| 6 | + <span vocab="https://schema.org/" typeof="Book"> |
| 7 | + <h1> |
| 8 | + <span rel="name">{{ book.title }}</span> |
| 9 | + </h1> |
| 10 | + <div class="row"> |
| 11 | + <div class="col-sm-12 col-md-6 col-lg-4 my-2"> |
| 12 | + {% if not book.image %} |
| 13 | + <img class="img-fluid" src="../../static/images/NoCover.jpeg"> |
17 | 14 | {% else %}
|
18 |
| - <button type="button" id="read-button" class="btn my-2 btn-success" data-bs-toggle="modal" data-bs-target="#read-button-backdrop">Read</button> |
| 15 | + <span property="image" content="{{ book.image }}"></span> |
| 16 | + <img class="img-fluid" src="{{ book.image }}"> |
19 | 17 | {% endif %}
|
20 |
| - |
21 |
| - <!-- Modal --> |
22 |
| - <div class="modal fade" id="read-button-backdrop" data-bs-backdrop="static" data-bs-keyboard="false" tabindex="-1" aria-labelledby="staticBackdropLabel" aria-hidden="true"> |
23 |
| - <div class="modal-dialog"> |
24 |
| - <div class="modal-content"> |
25 |
| - <div class="modal-header"> |
26 |
| - <h1 class="modal-title fs-5" id="staticBackdropLabel">Are you sure you want to remove the book from your reading list?</h1> |
27 |
| - <button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button> |
28 |
| - </div> |
29 |
| - <!-- <div class="modal-body"> |
30 |
| - ... |
31 |
| - </div> --> |
32 |
| - <div class="modal-footer"> |
33 |
| - <button type="button" class="btn btn-danger" data-bs-dismiss="modal">No</button> |
34 |
| - <button type="button" id="remove-book-button" class="btn btn-primary" data-bs-dismiss="modal">Yes</button> |
| 18 | + <div class="d-grid gap-2"> |
| 19 | + {% if not read_by_user %} |
| 20 | + <button type="button" id="read-button" class="btn btn-primary my-2">Mark as read</button> |
| 21 | + {% else %} |
| 22 | + <button type="button" id="read-button" class="btn my-2 btn-success" data-bs-toggle="modal" data-bs-target="#read-button-backdrop">Read</button> |
| 23 | + {% endif %} |
| 24 | + |
| 25 | + <!-- Modal --> |
| 26 | + <div class="modal fade" id="read-button-backdrop" data-bs-backdrop="static" data-bs-keyboard="false" tabindex="-1" aria-labelledby="staticBackdropLabel" aria-hidden="true"> |
| 27 | + <div class="modal-dialog"> |
| 28 | + <div class="modal-content"> |
| 29 | + <div class="modal-header"> |
| 30 | + <h1 class="modal-title fs-5" id="staticBackdropLabel">Are you sure you want to remove the book from your reading list?</h1> |
| 31 | + <button typse="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button> |
| 32 | + </div> |
| 33 | + <!-- <div class="modal-body"> |
| 34 | + ... |
| 35 | + </div> --> |
| 36 | + <div class="modal-footer"> |
| 37 | + <button type="button" class="btn btn-danger" data-bs-dismiss="modal">No</button> |
| 38 | + <button type="button" id="remove-book-button" class="btn btn-primary" data-bs-dismiss="modal">Yes</button> |
| 39 | + </div> |
| 40 | + </div> |
35 | 41 | </div>
|
36 | 42 | </div>
|
37 |
| - </div> |
38 |
| - </div> |
39 |
| - </div> |
| 43 | + </div> |
40 | 44 |
|
41 |
| - <table class="table"> |
42 |
| - <tbody> |
43 |
| - <tr> |
44 |
| - <th scope="col">Authors</th> |
45 |
| - <td id="authors-field"> |
46 |
| - {% if authors %} |
47 |
| - {% for author in authors %} |
48 |
| - <a class="link-secondary" href="{% url 'author' author_id=author.author.openlibrary_key %}">{{ author.author.name }}</a>{% if not forloop.last %}, {% endif %} |
| 45 | + <table class="table"> |
| 46 | + <tbody> |
| 47 | + <tr> |
| 48 | + <th scope="col">Authors</th> |
| 49 | + <td id="authors-field"> |
| 50 | + {% if authors %} |
| 51 | + {% for author in authors %} |
| 52 | + {% url 'author' author_id=author.author.openlibrary_key as author_url%} |
| 53 | + <a class="link-secondary" href="{{ author_url }}"> |
| 54 | + <div property="author" typeof="Person"> |
| 55 | + <span property="name">{{ author.author.name }}</span> |
| 56 | + <span property="url" content="{{ author_url }}"></span> |
| 57 | + </div> |
| 58 | + </a>{% if not forloop.last %}, {% endif %} |
| 59 | + {% endfor %} |
| 60 | + {% else %} |
| 61 | + No authors |
| 62 | + {% endif %} |
| 63 | + </td> |
| 64 | + </tr> |
| 65 | + {% if genres %} |
| 66 | + <tr> |
| 67 | + <th scope="row">Genres</th> |
| 68 | + <td id="genres-field" rel="genre"> |
| 69 | + {% for genre in genres %} |
| 70 | + <a class="link-secondary" href="{% url 'subject' genre.literary_genre.clean_name %}"><span rel="genre" content="{% url 'subject' genre.literary_genre.clean_name %}">{{ genre.literary_genre.name }}</span></a>{% if not forloop.last %}, {% endif %} |
49 | 71 | {% endfor %}
|
| 72 | + </td> |
| 73 | + </tr> |
| 74 | + {% endif %} |
| 75 | + </tbody> |
| 76 | + </table> |
| 77 | + </div> |
| 78 | + <div class="col-sm-12 col-md-6 col-lg-8 my-2"> |
| 79 | + <h2>Summary</h2> |
| 80 | + <hr class="review- separator"> |
| 81 | + <p>{% if book.summary %} |
| 82 | + <span property="abstract">{{ book.summary }}</span> |
| 83 | + {% else %}We are sorry, at the moment, this book does not have summary. |
| 84 | + {% endif %}</p> |
| 85 | + <!-- Nuevo apartado para mostrar las reviews --> |
| 86 | + <div> |
| 87 | + <h2>Reviews</h2> |
| 88 | + {% if reviews %} |
| 89 | + <div rel="aggregateRating" typeof="AggregateRating"> |
| 90 | + <h3><span property="ratingValue">Average rating: {{ book.qualification }}</span>(<span property="reviewCount">{{ book.review_set.all.count }}</span> reviews)</h3> |
| 91 | + </div> |
| 92 | + {% endif %} |
| 93 | + <hr class="review-separator"> |
| 94 | + <h4>Leave a Review</h4> |
| 95 | + {% if user.is_authenticated %} |
| 96 | + {% block review_form %} |
| 97 | + {% if not user_review_exists %} |
| 98 | + <a href="{% url 'create_review' book.openlibrary_key %}" class="btn btn-primary">Write a review</a> |
50 | 99 | {% else %}
|
51 |
| - No authors |
| 100 | + <p>Yoy have already reviewed this book:</p> |
| 101 | + <a href="{% url 'edit_review' book.openlibrary_key %}" class="btn btn-primary">Edit review</a> |
| 102 | + <a href="{% url 'delete_review' book.openlibrary_key %}" class="btn btn-danger">Delete review</a> |
52 | 103 | {% endif %}
|
53 |
| - </td> |
54 |
| - </tr> |
55 |
| - {% if genres %} |
56 |
| - <tr> |
57 |
| - <th scope="row">Genres</th> |
58 |
| - <td id="genres-field"> |
59 |
| - {% for genre in genres %} |
60 |
| - <a class="link-secondary" href="{% url 'subject' genre.literary_genre.clean_name %}">{{ genre.literary_genre.name }}</a>{% if not forloop.last %}, {% endif %} |
61 |
| - {% endfor %} |
62 |
| - </td> |
63 |
| - </tr> |
| 104 | + {% endblock %} |
| 105 | + {% else %} |
| 106 | + <p>Please <a href="{% url 'register' %}">register</a> or <a href="{% url 'login' %}">log in</a> to leave a review.</p> |
64 | 107 | {% endif %}
|
65 |
| - </tbody> |
66 |
| - </table> |
67 |
| - </div> |
68 |
| - <div class="col-sm-12 col-md-6 col-lg-8 my-2"> |
69 |
| - <h2>Summary</h2> |
70 |
| - <hr class="review-separator"> |
71 |
| - <p>{% if book.summary %}{{ book.summary }}{% else %}We are sorry, at the moment, this book does not have summary.{% endif %}</p> |
72 |
| - <!-- Nuevo apartado para mostrar las reviews --> |
73 |
| - <div> |
74 |
| - <h2>Reviews</h2> |
75 |
| - <hr class="review-separator"> |
76 |
| - <h4>Leave a Review</h4> |
77 |
| - {% if user.is_authenticated %} |
78 |
| - {% block review_form %} |
79 |
| - {% if not user_review_exists %} |
80 |
| - <a href="{% url 'create_review' book.openlibrary_key %}" class="btn btn-primary">Write a review</a> |
81 |
| - {% else %} |
82 |
| - <p>Yoy have already reviewed this book:</p> |
83 |
| - <a href="{% url 'edit_review' book.openlibrary_key %}" class="btn btn-primary">Edit review</a> |
84 |
| - <a href="{% url 'delete_review' book.openlibrary_key %}" class="btn btn-danger">Delete review</a> |
85 |
| - {% endif %} |
86 |
| - {% endblock %} |
87 |
| - {% else %} |
88 |
| - <p>Please <a href="{% url 'register' %}">register</a> or <a href="{% url 'login' %}">log in</a> to leave a review.</p> |
89 |
| - {% endif %} |
90 |
| - <hr class="review-separator"> |
91 |
| - {% if reviews %} |
92 |
| - <div class="review-list"> |
93 |
| - {% for review in reviews %} |
94 |
| - <div class="review"> |
95 |
| - <div class="review-header"> |
96 |
| - <div class="review-info">{{ review.user }} - {{review.date}}</div> |
97 |
| - <div class="review-rating"> |
98 |
| - {% for _ in "x"|rjust:review.qualification|make_list %} |
99 |
| - <i class="fas fa-star"></i> |
100 |
| - {% endfor %} |
| 108 | + <hr class="review-separator"> |
| 109 | + {% if reviews %} |
| 110 | + <div class="review-list"> |
| 111 | + {% for review in reviews %} |
| 112 | + <div class="review" rel="review" typeof="Review"> |
| 113 | + <div class="review-header"> |
| 114 | + <div class="review-info"><span property="author" typeof="Person"><span property="name">{{ review.user.username }}</span></span> - <span property="publishDate" content="{{ review.date|date:"c" }}"></span>{{review.date}}</div> |
| 115 | + <div class="review-rating"> |
| 116 | + {% for _ in "x"|rjust:review.qualification|make_list %} |
| 117 | + <i class="fas fa-star"></i> |
| 118 | + {% endfor %} |
| 119 | + <span property="worstRating" content="1"></span> |
| 120 | + <span property="ratingValue" content="{{ review.qualification }}"></span> |
| 121 | + <span property="bestRating" content="5"></span> |
| 122 | + </div> |
101 | 123 | </div>
|
| 124 | + <div class="review-comment"><span property="description">{{ review.comment }}</span></div> |
| 125 | + {% if user.is_authenticated and user == review.user %} |
| 126 | + <div class="review-actions"> |
| 127 | + <a href="{% url 'edit_review' book.openlibrary_key %}" class="btn btn-primary">Edit</a> |
| 128 | + <a href="{% url 'delete_review' book.openlibrary_key %}" class="btn btn-danger">Delete</a> |
| 129 | + </div> |
| 130 | + {% endif %} |
| 131 | + <hr class="review-separator"> |
102 | 132 | </div>
|
103 |
| - <div class="review-comment">{{ review.comment }}</div> |
104 |
| - {% if user.is_authenticated and user == review.user %} |
105 |
| - <div class="review-actions"> |
106 |
| - <a href="{% url 'edit_review' book.openlibrary_key %}" class="btn btn-primary">Edit</a> |
107 |
| - <a href="{% url 'delete_review' book.openlibrary_key %}" class="btn btn-danger">Delete</a> |
108 |
| - </div> |
109 |
| - {% endif %} |
110 |
| - <hr class="review-separator"> |
111 |
| - </div> |
112 |
| - {% endfor %} |
113 |
| - </div> |
114 |
| - {% else %} |
115 |
| - <p>No reviews available for this book.</p> |
116 |
| - {% endif %} |
| 133 | + {% endfor %} |
| 134 | + </div> |
| 135 | + {% else %} |
| 136 | + <p>No reviews available for this book.</p> |
| 137 | + {% endif %} |
| 138 | + </div> |
117 | 139 | </div>
|
118 | 140 | </div>
|
119 |
| - </div> |
| 141 | + </span> |
120 | 142 | {% endblock %}
|
121 | 143 | {% block js %}
|
122 | 144 | <script>
|
|
0 commit comments