split out old books into book and books.html, all *.html now using extends and {% block %} in jinja2. So navbar is now present in all URLs
This commit is contained in:
@@ -1,10 +1,9 @@
|
|||||||
{% extends "base.html" %}
|
{% extends "base.html" %} {% block main_content %}
|
||||||
{% block main_content %}
|
|
||||||
<h3><center>Author</center></h3>
|
<h3><center>Author</center></h3>
|
||||||
<div class="container">
|
<div class="container">
|
||||||
<right>
|
<right>
|
||||||
{% if message|length %}
|
{% if message|length %}
|
||||||
<div class="row alert alert-success">
|
<div class="row alert alert-{{alert}}">
|
||||||
{{message}}
|
{{message}}
|
||||||
</div>
|
</div>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
@@ -20,7 +19,8 @@
|
|||||||
<div class="col-xl-12">
|
<div class="col-xl-12">
|
||||||
<br></br>
|
<br></br>
|
||||||
</div>
|
</div>
|
||||||
{{ wtf.form_field( author_form.submit, button_map={'submit':'primary'}, horizontal_columns=('xl', 2, 10), class="btn btn-primary offset-xl-1 col-xl-2" )}}
|
{{ wtf.form_field( author_form.submit, horizontal_columns=('xl', 2, 2), class="btn btn-primary offset-xl-1 col-xl-2" )}}
|
||||||
|
{{ wtf.form_field( author_form.delete, horizontal_columns=('xl', 2, 2), class="btn btn-danger offset-xl-1 col-xl-2" )}}
|
||||||
</form>
|
</form>
|
||||||
</div class="row">
|
</div class="row">
|
||||||
</div class="container">
|
</div class="container">
|
||||||
|
|||||||
@@ -4,13 +4,11 @@
|
|||||||
<h3>Authors</h3>
|
<h3>Authors</h3>
|
||||||
<table id="book_table" class="table table-striped table-sm" data-toolbar="#toolbar" data-search="true">
|
<table id="book_table" class="table table-striped table-sm" data-toolbar="#toolbar" data-search="true">
|
||||||
<thead>
|
<thead>
|
||||||
<tr class="thead-light"><th>Surname</th><th>Firstname(s)</th><th>Action</th></tr>
|
<tr class="thead-light"><th>Surname</th><th>Firstname(s)</th></tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
{% for author in authors %}
|
{% for author in authors %}
|
||||||
<tr><td>{{author.surname}}</td><td>{{author.firstnames}}</td><td>
|
<tr><td><a href="{{url_for('author', id=author.id )}}">{{author.surname}}</a></td><td>{{author.firstnames}}</td></tr>
|
||||||
icons for: E, D
|
|
||||||
</td></tr>
|
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
|
|||||||
@@ -24,13 +24,13 @@
|
|||||||
<div class="nav-item dropdown">
|
<div class="nav-item dropdown">
|
||||||
<a class="nav-item dropdown nav-link dropdown-toggle" href="#" id="BookMenu" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">Books</a>
|
<a class="nav-item dropdown nav-link dropdown-toggle" href="#" id="BookMenu" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">Books</a>
|
||||||
<div class="dropdown-menu" aria-labelledby="BookMenu">
|
<div class="dropdown-menu" aria-labelledby="BookMenu">
|
||||||
<a class="dropdown-item" href="#">Show All</a>
|
<a class="dropdown-item" href="{{url_for('books')}}">Show All</a>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="nav-item dropdown">
|
<div class="nav-item dropdown">
|
||||||
<a class="nav-item dropdown nav-link dropdown-toggle" href="#" id="AuthorMenu" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">Authors</a>
|
<a class="nav-item dropdown nav-link dropdown-toggle" href="#" id="AuthorMenu" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">Authors</a>
|
||||||
<div class="dropdown-menu" aria-labelledby="AuthorMenu">
|
<div class="dropdown-menu" aria-labelledby="AuthorMenu">
|
||||||
<a class="dropdown-item" href="/authors">Show All</a>
|
<a class="dropdown-item" href="{{url_for('authors')}}">Show All</a>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="nav-item dropdown">
|
<div class="nav-item dropdown">
|
||||||
|
|||||||
43
templates/book.html
Normal file
43
templates/book.html
Normal file
@@ -0,0 +1,43 @@
|
|||||||
|
{% 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 with-margin">
|
||||||
|
<form class="form col-lg-12">
|
||||||
|
{% for key in keys %}
|
||||||
|
<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 %}
|
||||||
|
{% 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="5" type="text" class="form-control input-lg" id="{{key}}">{{books[key]}}</textarea>
|
||||||
|
{% else %}
|
||||||
|
<input type="text" class="form-control input-lg" id="{{key}}" value="{{books[key]}}">
|
||||||
|
{% endif %}
|
||||||
|
{% endif %}
|
||||||
|
</div class="col-lg-8">
|
||||||
|
</div class="form-group">
|
||||||
|
{% endfor %}
|
||||||
|
</form>
|
||||||
|
</div class="row">
|
||||||
|
</div class="container">
|
||||||
|
{% if books.sub_book|length %}
|
||||||
|
<p>sub_book is defined: {{books.sub_book}}</p>
|
||||||
|
{% endif %}
|
||||||
|
{{ books.subs }}
|
||||||
|
{% endblock main_content %}
|
||||||
@@ -1,18 +1,5 @@
|
|||||||
<html>
|
{% extends "base.html" %}
|
||||||
<head>
|
{% block main_content %}
|
||||||
<!-- Required meta tags -->
|
|
||||||
<meta charset="utf-8">
|
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
|
|
||||||
|
|
||||||
<!-- Bootstrap CSS -->
|
|
||||||
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@4.5.3/dist/css/bootstrap.min.css" integrity="sha384-TX8t27EcRE3e/ihU7zmQxVncDAy5uIKz4rEkgIXeMed4M0jlfIDPvg6uqKI2xXr2" crossorigin="anonymous">
|
|
||||||
<link rel="stylesheet" href="https://unpkg.com/bootstrap-table@1.18.0/dist/bootstrap-table.min.css">
|
|
||||||
<link rel="stylesheet" href="https://cdn.datatables.net/1.10.22/css/dataTables.bootstrap4.min.css">
|
|
||||||
<script src="https://kit.fontawesome.com/9b4c7cf470.js" crossorigin="anonymous"></script>
|
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
|
|
||||||
{% if books is not mapping %}
|
|
||||||
<h3>All Books</h1>
|
<h3>All Books</h1>
|
||||||
<table id="book_table" class="table table-striped table-sm" data-toolbar="#toolbar" data-search="true">
|
<table id="book_table" class="table table-striped table-sm" data-toolbar="#toolbar" data-search="true">
|
||||||
<thead>
|
<thead>
|
||||||
@@ -43,58 +30,4 @@
|
|||||||
{% endfor %}
|
{% endfor %}
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
{% else %}
|
{% endblock 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 with-margin">
|
|
||||||
<form class="form col-lg-12">
|
|
||||||
{% for key in keys %}
|
|
||||||
<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 %}
|
|
||||||
{% 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="5" type="text" class="form-control input-lg" id="{{key}}">{{books[key]}}</textarea>
|
|
||||||
{% else %}
|
|
||||||
<input type="text" class="form-control input-lg" id="{{key}}" value="{{books[key]}}">
|
|
||||||
{% endif %}
|
|
||||||
{% endif %}
|
|
||||||
</div class="col-lg-8">
|
|
||||||
</div class="form-group">
|
|
||||||
{% endfor %}
|
|
||||||
</form>
|
|
||||||
</div class="row">
|
|
||||||
</div class="container">
|
|
||||||
{% if books.sub_book|length %}
|
|
||||||
<p>sub_book is defined: {{books.sub_book}}</p>
|
|
||||||
{% endif %}
|
|
||||||
{{ books.subs }}
|
|
||||||
{% endif %}
|
|
||||||
|
|
||||||
<!-- code to get bootstrap & bootstrap datatable to work -->
|
|
||||||
<script src="https://code.jquery.com/jquery-3.5.1.slim.min.js" integrity="sha384-DfXdz2htPH0lsSSs5nCTpuj/zy4C+OGpamoFVy38MVBnE+IbbVYUew+OrCXaRkfj" crossorigin="anonymous"></script>
|
|
||||||
<script src="https://cdn.jsdelivr.net/npm/bootstrap@4.5.3/dist/js/bootstrap.bundle.min.js" integrity="sha384-ho+j7jyWK8fNQe+A12Hb8AhRq26LrZ/JpcUGGOn+Y7RsweNrtN/tE3MoK7ZeZDyx" crossorigin="anonymous"></script>
|
|
||||||
<script src="https://cdn.datatables.net/1.10.22/js/jquery.dataTables.min.js"></script>
|
|
||||||
<script src="https://cdn.datatables.net/1.10.22/js/dataTables.bootstrap4.min.js"></script>
|
|
||||||
<script>
|
|
||||||
$(document).ready(function() {
|
|
||||||
$('#book_table').DataTable( { 'pageLength': 25 } );
|
|
||||||
} );
|
|
||||||
</script>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
||||||
|
|||||||
Reference in New Issue
Block a user