Files
books/templates/book.html

67 lines
2.5 KiB
HTML

{% extends "base.html" %}
{% block main_content %}
<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 col-lg-12">
{% for key in keys %}
<div class="form-row">
<label for="{{key}}" class="col-lg-2 col-form-label">{{key}}:</label>
{% if key == "genre" %}
<div class="form-row col-lg-10">
{% for genre in genre_list %}
{% set gname=genre.name %}
<div class="form-control col" style="margin-left:5px;margin-right:-5px;">
<input id="{{gname}}" name="{{gname}}" type="checkbox"
{% for book_g in books.genre %}
{% if book_g['name'] == gname %}
checked
{% endif %}
{% endfor %}
></input>
<label style="display:inline" for="{{gname}}" class="col-form-label">{{gname}}</label>
</div>
{% endfor %}
</div>
{% elif key == "publisher" %}
<div class="col-lg-10">
<div class="form-row" style="margin-left:0px; margin-right:0px;">
<span class="form-control col" id="{{key}}[0]">
<a href="{{url_for(key, id=books[key][0].id)}}">{{books[key][0].name}}</a>
</span>
</div class="row">
</div class="col-lg-10">
{% elif key == "author" %}
<div class="col-lg-10">
<div class="form-row" style="margin-left:0px; margin-right:0px;">
{% set cnt = namespace(idx=0) %}
{% for objects in books[key] %}
<span class="form-control col" id="{{key}}[{{cnt.idx}}]">
<a href="{{url_for(key, id=books[key][cnt.idx].id)}}">
{{books.author[cnt.idx].surname + ", " + books.author[cnt.idx].firstnames}}
</a>
</span>
{% set cnt.idx = cnt.idx+1 %}
{% endfor %}
</div class="row">
</div class="col-lg-10">
{% else %}
<div class="col-lg-10">
{{book_form[key](class="form-control", value=books[key], rows="5" )}}
</div class="col-lg-10">
{% endif %}
</div class="form-row">
{% endfor %}
</form></div class="row"></div class="container">
{% if books.sub_book|length %}
<p>sub_book is defined: {{books.sub_book}}</p>
{% endif %}
{% if books.subs|length %}
<p>subs is defined {{ books.subs }}</p>
{% endif %}
{% if books.loan|length %}
<p>loan is defined: {{books.loan}}</p>
{% endif %}
{% endblock main_content %}