first pass at using jinja2 to make an edit form dynamically, its a bit hit and miss :(
This commit is contained in:
@@ -44,8 +44,35 @@
|
||||
</tbody>
|
||||
</table>
|
||||
{% else %}
|
||||
<h3>Book</h1>
|
||||
<p>{{books.title}}, {{ books.author[0]['surname'] }}, {{books.author[0]['firstnames']}} </p>
|
||||
<h3>View/Edit Book</h1>
|
||||
{% set keys = [ 'title', 'author', 'publisher', 'owned', 'covertype', 'condition', 'year_published', 'rating', 'notes', 'blurb' ] %}
|
||||
<div class="container">
|
||||
<div class="row">
|
||||
<form class="form">
|
||||
{% 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">
|
||||
{% if books[key] is iterable and books[key] is not string %}
|
||||
{% for objects in books[key] %}
|
||||
{% 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]}}">
|
||||
{% endfor %}
|
||||
{% endfor %}
|
||||
{% else %}
|
||||
{% if key == "notes" or key == "blurb" %}
|
||||
<textarea rows="10" type="text" class="form-control" id="{{key}}">{{books[key]}}</textarea>
|
||||
{% else %}
|
||||
<input type="text" class="form-control" id="{{key}}" value="{{books[key]}}">
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
</div>
|
||||
</div class="form-group">
|
||||
{% endfor %}
|
||||
</form>
|
||||
</div class="row">
|
||||
</div class="container">
|
||||
{% if books.sub_book is defined %}
|
||||
<p>sub_book is defined: {{books.sub_book}}</p>
|
||||
{% endif %}
|
||||
|
||||
Reference in New Issue
Block a user