You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

book.html 6.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164
  1. {% extends 'base.html' %}
  2. {% block content %}
  3. {% if book['thumbnail'] %}
  4. <img class="img-fluid mx-auto d-block" src={{ book['thumbnail'] }} alt="cover for {{ book['Title'] }}">
  5. {% else %}
  6. <div class="row">
  7. <div class="col">
  8. <h1 class="text-center">{% block title %} {{ book['Title'] or resource['name'] }} {% endblock %}</h1>
  9. </div>
  10. </div>
  11. {% endif %}
  12. {% if current_user.is_authenticated %}
  13. <div class="row text-center py-3">
  14. <a href="{{ url_for('book.edit_book', book_id=resource['id']) }}">
  15. <span class="badge bg-dark">Edit</span>
  16. </a>
  17. </div>
  18. {% endif %}
  19. <div class="row">
  20. <div class="col">
  21. <table class="table table-hover">
  22. <tbody>
  23. {% if book %}
  24. <!-- fields for books from isbntools -->
  25. {% if book['Title'] %}
  26. <tr>
  27. <th>
  28. Title:
  29. </th>
  30. <td>
  31. {{ book['Title'] }}
  32. </td>
  33. </tr>
  34. {% endif %}
  35. {% if book['Authors'] %}
  36. <tr>
  37. {% if book['Authors']|length > 1 %}
  38. <th>
  39. Authors:
  40. </th>
  41. <td>
  42. {% for author in book['Authors'] %}
  43. {{ author }},
  44. {% endfor %}
  45. </td>
  46. {% else %}
  47. <th>
  48. Author:
  49. </th>
  50. <td>
  51. {% for author in book['Authors'] %}
  52. {{ author }}
  53. {% endfor %}
  54. </td>
  55. {% endif %}
  56. </tr>
  57. {% endif %}
  58. {% if book['ISBN-13'] %}
  59. <tr>
  60. <th>
  61. ISBN-13:
  62. </th>
  63. <td>
  64. {{ book['ISBN-13'] }}
  65. </td>
  66. </tr>
  67. {% endif %}
  68. {% if book['Year'] %}
  69. <tr>
  70. <th>
  71. Publication year:
  72. </th>
  73. <td>
  74. {{ book['Year'] }}
  75. </td>
  76. </tr>
  77. {% endif %}
  78. {% if book['Publisher'] %}
  79. <tr>
  80. <th>
  81. Publisher:
  82. </th>
  83. <td>
  84. {{ book['Publisher'] }}
  85. </td>
  86. </tr>
  87. {% endif %}
  88. {% else %}
  89. <!-- fields for books from database -->
  90. {% if resource['name'] %}
  91. <tr>
  92. <th>
  93. Title:
  94. </th>
  95. <td>
  96. {{ resource['name'] }}
  97. </td>
  98. </tr>
  99. {% endif %}
  100. {% if resource['author'] %}
  101. <tr>
  102. <th>
  103. Author:
  104. </th>
  105. <td>
  106. {{ resource['author'] }}
  107. </td>
  108. </tr>
  109. {% endif %}
  110. {% endif %}
  111. </tbody>
  112. </table>
  113. </div>
  114. </div>
  115. {% if relationships %}
  116. <div class="row">
  117. <div class="col">
  118. <h2 class="text-center">Linked resources:</h2>
  119. </div>
  120. </div>
  121. <div class="row">
  122. {% for relationship in relationships %}
  123. <div class="col-md-4 col-sm-6 py-3">
  124. {% if relationship['type'] == 'tool' %}
  125. <div class="card text-dark bg-tool mb-3">
  126. <div class="card-body">
  127. <a href="{{ url_for('tool.show_tool', tool_id=relationship['id']) }}">
  128. <h3 class="card-title text-center text-dark">{{ relationship['name'] }}</h3>
  129. </a>
  130. <p class="card-text">
  131. {{ relationship['description']|truncate(100) }}
  132. </p>
  133. </div>
  134. </div>
  135. {% elif relationship['type'] == 'practice' %}
  136. <div class="card text-dark bg-practice mb-3">
  137. <div class="card-body">
  138. <a href="{{ url_for('practice.show_practice', practice_id=relationship['id']) }}">
  139. <h3 class="card-title text-center text-dark">{{ relationship['name'] }}</h3>
  140. </a>
  141. <p class="card-text">
  142. {{ relationship['description']|truncate(100) }}
  143. </p>
  144. </div>
  145. </div>
  146. {% elif relationship['type'] == 'book' %}
  147. <div class="card text-dark bg-book mb-3">
  148. <div class="card-body">
  149. <a href="{{ url_for('book.show_book', book_id=relationship['id']) }}">
  150. <h3 class="card-title text-center text-dark">{{ relationship['name'] }}</h3>
  151. </a>
  152. <p class="card-text">
  153. {{ relationship['description']|truncate(100) }}
  154. </p>
  155. </div>
  156. </div>
  157. {% endif %}
  158. </div>
  159. {% endfor %}
  160. </div>
  161. {% endif %}
  162. {% endblock %}