made genre use the schemas properly to return actual joined data, not just genre_id. Also made author/publisher/genre all use many=True, while that is nto true for publisher, it makes the jinja code consisten -- Might need to fix this one day if the writing to the database is somehow more automatic and needs it to be an actual one-to-many, not a many-to-many

This commit is contained in:
2020-11-08 15:46:59 +11:00
parent c4fe3422a3
commit a57d68ecfa
2 changed files with 21 additions and 17 deletions

View File

@@ -44,36 +44,42 @@
</tbody>
</table>
{% else %}
<h3>View/Edit Book</h1>
{% set keys = [ 'title', 'author', 'publisher', 'owned', 'covertype', 'condition', 'year_published', 'rating', 'notes', 'blurb' ] %}
<h3><center>View/Edit Book</center></h1>
{% set keys = [ 'title', 'author', 'publisher', 'genre', 'owned', 'covertype', 'condition', 'year_published', 'rating', 'notes', 'blurb' ] %}
<div class="container">
<div class="row">
<form class="form">
<div class="row with-margin">
<form class="form col-lg-12">
{% for key in keys %}
<div class="form-group row">
<label for="{{key}}" class="col-sm-4 col-form-label">{{key}}:</label>
<div class="col-sm-8">
<div class="input-group input-group-lg">
<label for="{{key}}" class="col-lg-2 col-form-label">{{key}}:</label>
<div class="col-lg-10">
{% if books[key] is iterable and books[key] is not string %}
<table>
{% for objects in books[key] %}
<tr>
{% for attr in objects %}
<label for="{{attr}}" class="col-sm-4 col-form-label">{{attr}}:</label>
<input type="text" class="form-control" id="not-sure-{{key}}-{{attr}}" value="{{objects[attr]}}">
{% if attr != "id" %}
<td>
<input type="text" class="form-control input-lg" id="not-sure-{{key}}-{{attr}}" value="{{objects[attr]}}">
</td>
{% endif %}
{% endfor %}
</tr>
{% endfor %}
</table>
{% else %}
{% if key == "notes" or key == "blurb" %}
<textarea rows="10" type="text" class="form-control" id="{{key}}">{{books[key]}}</textarea>
<textarea rows="5" type="text" class="form-control input-lg" id="{{key}}">{{books[key]}}</textarea>
{% else %}
<input type="text" class="form-control" id="{{key}}" value="{{books[key]}}">
<input type="text" class="form-control input-lg" id="{{key}}" value="{{books[key]}}">
{% endif %}
{% endif %}
</div>
</div class="col-lg-8">
</div class="form-group">
{% endfor %}
</form>
</div class="row">
</div class="container">
{{books.genre}}
{% if books.sub_book is defined %}
<p>sub_book is defined: {{books.sub_book}}</p>
{% endif %}