reordered add button to be consistent with author and publisher, then allowed author to be a drop-down with a + or - button as appropriate
This commit is contained in:
@@ -68,3 +68,6 @@ def author(id):
|
|||||||
author_form = AuthorForm(request.values, obj=author)
|
author_form = AuthorForm(request.values, obj=author)
|
||||||
message=""
|
message=""
|
||||||
return render_template("author.html", author=author, alert=alert, message=message, author_form=author_form)
|
return render_template("author.html", author=author, alert=alert, message=message, author_form=author_form)
|
||||||
|
|
||||||
|
def GetAuthors():
|
||||||
|
return Author.query.order_by('surname','firstnames').all()
|
||||||
|
|||||||
5
main.py
5
main.py
@@ -15,7 +15,7 @@ db = SQLAlchemy(app)
|
|||||||
ma = Marshmallow(app)
|
ma = Marshmallow(app)
|
||||||
Bootstrap(app)
|
Bootstrap(app)
|
||||||
|
|
||||||
from author import Author, AuthorForm, AuthorSchema
|
from author import Author, AuthorForm, AuthorSchema, GetAuthors
|
||||||
from publisher import Publisher, PublisherForm, PublisherSchema, GetPublishers
|
from publisher import Publisher, PublisherForm, PublisherSchema, GetPublishers
|
||||||
from genre import Genre, GenreForm, GenreSchema, GetGenres
|
from genre import Genre, GenreForm, GenreSchema, GetGenres
|
||||||
from condition import Condition, ConditionForm, ConditionSchema, GetConditionById
|
from condition import Condition, ConditionForm, ConditionSchema, GetConditionById
|
||||||
@@ -173,9 +173,10 @@ def book(id):
|
|||||||
book_form.owned.default = book.owned
|
book_form.owned.default = book.owned
|
||||||
book_form.rating.default = book.rating
|
book_form.rating.default = book.rating
|
||||||
book_form.process()
|
book_form.process()
|
||||||
|
author_list = GetAuthors()
|
||||||
genre_list = GetGenres()
|
genre_list = GetGenres()
|
||||||
publisher_list = GetPublishers()
|
publisher_list = GetPublishers()
|
||||||
return render_template("book.html", books=book_s, subs=sub_book, book_form=book_form, genre_list=genre_list, publisher_list=publisher_list, covertype_list=covertypes )
|
return render_template("book.html", books=book_s, subs=sub_book, book_form=book_form, author_list=author_list, publisher_list=publisher_list, genre_list=genre_list )
|
||||||
|
|
||||||
@app.route("/", methods=["GET"])
|
@app.route("/", methods=["GET"])
|
||||||
def main_page():
|
def main_page():
|
||||||
|
|||||||
@@ -28,13 +28,13 @@
|
|||||||
<div class="col-lg-10">
|
<div class="col-lg-10">
|
||||||
<div class="form-row input-group" style="margin-left:0px; margin-right:0px;">
|
<div class="form-row input-group" style="margin-left:0px; margin-right:0px;">
|
||||||
<div class="input-group-prepend">
|
<div class="input-group-prepend">
|
||||||
<button class="btn btn-outline-primary" type="button">
|
<button class="btn btn-outline-success" type="button">
|
||||||
<a style="color:inherit" href="{{url_for(key, id=books[key][0].id)}}"><i class="far fa-edit"></i>
|
<a style="color:inherit" href="{{url_for(key, id=-1)}}"><i class="fas fa-plus"></i></a>
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
<div class="input-group-prepend">
|
<div class="input-group-prepend">
|
||||||
<button class="btn btn-outline-success" type="button">
|
<button class="btn btn-outline-primary" type="button">
|
||||||
<a style="color:inherit" href="{{url_for(key, id=-1)}}"><i class="fas fa-plus"></i></a>
|
<a style="color:inherit" href="{{url_for(key, id=books[key][0].id)}}"><i class="far fa-edit"></i></a>
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
<select class="form-control" id="publisher">
|
<select class="form-control" id="publisher">
|
||||||
@@ -51,17 +51,40 @@
|
|||||||
</div class="col-lg-10">
|
</div class="col-lg-10">
|
||||||
{% elif key == "author" %}
|
{% elif key == "author" %}
|
||||||
<div class="col-lg-10">
|
<div class="col-lg-10">
|
||||||
<div class="form-row" style="margin-left:0px; margin-right:0px;">
|
<div class="form-row" style="margin-left:0px;margin-right:0px">
|
||||||
{% set cnt = namespace(idx=0) %}
|
{% set cnt = namespace(idx=0) %}
|
||||||
{% for objects in books[key] %}
|
{% for objects in books[key] %}
|
||||||
<span class="form-control col" id="{{key}}[{{cnt.idx}}]">
|
<div class="col input-group" style="padding-left:0px;padding-right:0px">
|
||||||
<a href="{{url_for(key, id=books[key][cnt.idx].id)}}">
|
<div class="input-group-prepend">
|
||||||
{{books.author[cnt.idx].surname + ", " + books.author[cnt.idx].firstnames}}
|
{% if cnt.idx == 0 %}
|
||||||
</a>
|
<button class="btn btn-outline-success" type="button">
|
||||||
</span>
|
<a style="color:inherit" href="{{url_for(key, id=-1)}}"><i class="fas fa-plus"></i></a>
|
||||||
|
</button>
|
||||||
|
{% else %}
|
||||||
|
<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>
|
||||||
|
{% endif %}
|
||||||
|
</div>
|
||||||
|
<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="publisher">
|
||||||
|
{% for auth in author_list %}
|
||||||
|
{% set aname=auth.surname+", "+auth.firstnames %}
|
||||||
|
<option id="{{books.author[cnt.idx].id}}" value="{{books.author[cnt.idx].id}}"
|
||||||
|
{% if books.author[cnt.idx].id == auth.id %}
|
||||||
|
selected
|
||||||
|
{% endif %}
|
||||||
|
>{{aname}}</option>
|
||||||
|
{% endfor %}
|
||||||
|
</select>
|
||||||
|
</div class="col">
|
||||||
{% set cnt.idx = cnt.idx+1 %}
|
{% set cnt.idx = cnt.idx+1 %}
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</div class="row">
|
</div class="form-row">
|
||||||
</div class="col-lg-10">
|
</div class="col-lg-10">
|
||||||
{% else %}
|
{% else %}
|
||||||
<div class="col-lg-10">
|
<div class="col-lg-10">
|
||||||
|
|||||||
Reference in New Issue
Block a user