125 lines
4.6 KiB
HTML
125 lines
4.6 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-fluid"><div class="row"><form class="form col-lg-10">
|
|
{% 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="form-row col input-group" style="margin-left:0px; margin-right:0px;">
|
|
<div class="input-group-prepend">
|
|
<button class="btn btn-outline-primary" type="button">
|
|
<a style="color:inherit" href="{{url_for(key, id=books[key][0].id)}}"><i class="far fa-edit"></i></a>
|
|
</button>
|
|
</div>
|
|
<select class="form-control" id="publisher">
|
|
{% for pub in publisher_list %}
|
|
{% set pname=pub.name %}
|
|
<option id="{{pub.id}}" value="{{pub.id}}"
|
|
{% if books.publisher[0].name == pname %}
|
|
selected
|
|
{% endif %}
|
|
>{{pname}}</option>
|
|
{% endfor %}
|
|
</select>
|
|
</div class="row">
|
|
{% elif key == "author" %}
|
|
<div class="form-row col" style="margin-left:0px;margin-right:0px">
|
|
{% set cnt = namespace(idx=0) %}
|
|
{% for objects in books[key] %}
|
|
<div class="col input-group" style="padding-left:0px;padding-right:0px">
|
|
{% if cnt.idx > 0 %}
|
|
<div class="input-group-prepend">
|
|
<button class="btn btn-outline-danger" type="button">
|
|
<a style="color:inherit" href="{{url_for(key, id=-1)}}"><i class="fas fa-minus"></i></a>
|
|
</button>
|
|
</div>
|
|
{% endif %}
|
|
<div class="input-group-prepend">
|
|
<button class="btn btn-outline-primary" type="button">
|
|
<a style="color:inherit" href="{{url_for(key, id=books[key][cnt.idx].id)}}"><i class="far fa-edit"></i></a>
|
|
</button>
|
|
</div>
|
|
<select class="form-control" id="author[{{cnt.idx}}]">
|
|
{% for auth in author_list %}
|
|
{% set aname=auth.surname+", "+auth.firstnames %}
|
|
<option id="{{auth.id}}" value="{{auth.id}}"
|
|
{% if books.author[cnt.idx].id == auth.id %}
|
|
selected
|
|
{% endif %}
|
|
>{{aname}}</option>
|
|
{% endfor %}
|
|
</select>
|
|
</div class="col">
|
|
{% set cnt.idx = cnt.idx+1 %}
|
|
{% endfor %}
|
|
<div class="input-group-append">
|
|
<button class="btn btn-outline-success" type="button">
|
|
<a style="color:inherit" href="{{url_for(key, id=-1)}}"><i class="fas fa-plus"></i></a>
|
|
</button>
|
|
</div>
|
|
</div class="form-row">
|
|
{% else %}
|
|
<div class="col">
|
|
{{book_form[key](class="form-control", value=books[key], rows="5" )}}
|
|
</div class="col">
|
|
{% endif %}
|
|
</div class="form-row">
|
|
{% endfor %}
|
|
{% if books.series|length %}
|
|
<div class="form-row">
|
|
<label for="series" class="col-lg-2 col-form-label">Series:</label>
|
|
<table>
|
|
{% for s in books.series %}
|
|
<tr><td>
|
|
Book {{ SeriesBookNum( s.id, books.id ) }} of {{s.num_books}} in <a href="/series/{{s.id}}">{{s.title}}</a>
|
|
</td></tr>
|
|
{% endfor %}
|
|
</table>
|
|
</div>
|
|
</form>
|
|
{% endif %}
|
|
{% 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 %}
|
|
<div class="col">
|
|
<div class="card border-primary" style="max-width: 18rem;">
|
|
<div class="card-header bg-primary text-white">Loaned to</div>
|
|
<div class="card-body text-primary">
|
|
<h5 class="card-title">{{books.loan[0].firstnames}} {{books.loan[0].surname}}</h5>
|
|
<p class="card-text">
|
|
When: {{books.loan[0].date_lent}}<br>
|
|
Contact: {{books.loan[0].contact_details}}
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
{% endif %}
|
|
</div class="row">
|
|
</div class="container">
|
|
|
|
{% endblock main_content %}
|