From 22494aadd27c097c1ef207848b05e68ad0a18ecb Mon Sep 17 00:00:00 2001
From: nberting
Date: Sun, 10 Jun 2018 11:16:47 +0200
Subject: [PATCH 1/3] styling buttons
---
app/static/css/style.css | 10 +++++-----
app/templates/show_book_detail.html | 18 ++++++++++--------
app/views.py | 2 ++
3 files changed, 17 insertions(+), 13 deletions(-)
diff --git a/app/static/css/style.css b/app/static/css/style.css
index 2ea3389..a7f6bbf 100755
--- a/app/static/css/style.css
+++ b/app/static/css/style.css
@@ -385,21 +385,21 @@ box-sizing: border-box;
height: 100%; /* Full height */
overflow: auto; /* Enable scroll if needed */
background-color: rgb(0,0,0); /* Fallback color */
- background-color: rgba(0,0,0,0.4); /* Black w/ opacity */
+ background-color: rgba(0,0,0,0.5); /* Black w/ opacity */
}
/* Modal Content/Box */
.modal-content {
- background-color: #fefefe;
+ background-color: yellow;
margin: 15% auto; /* 15% from the top and centered */
- padding: 20px;
+ padding: 15px;
border: 1px solid #888;
width: 40%; /* Could be more or less, depending on screen size */
}
/* The Close Button */
.close {
- color: red;
+ color: grey;
float: right;
font-size: 28px;
font-weight: bold;
@@ -407,7 +407,7 @@ box-sizing: border-box;
.close:hover,
.close:focus {
- color: black;
+ color: red;
text-decoration: none;
cursor: pointer;
}
diff --git a/app/templates/show_book_detail.html b/app/templates/show_book_detail.html
index 79252d3..ea6b6b9 100755
--- a/app/templates/show_book_detail.html
+++ b/app/templates/show_book_detail.html
@@ -21,18 +21,20 @@
{% endfor %}
-
-
-
-
+{% if book.file %}
+
×
A message from the uploading librarian:
-
"{{book.message or 'Happy reading.'}}"
-
-
-
+ "{{book.message or 'Happy reading.'}}"
+
+
+{% else %}
+{% endif %}
+
+
+
diff --git a/app/views.py b/app/views.py
index 199b264..27cb5fa 100755
--- a/app/views.py
+++ b/app/views.py
@@ -141,12 +141,14 @@ def edit_book_by_id(id):
input_authors = user_form.author.data
category = user_form.category.data
year_published = user_form.year_published.data
+ message = user_form.message.data
if year_published=="":
year_published = None
book = Book.query.filter_by(id=id).first()
book.title = title
book.category = category
book.year_published = year_published
+ book.message = message
#authors update
book.authors.clear()
From b8a6c86a13502c961e60a217077a15cff3c408ce Mon Sep 17 00:00:00 2001
From: nberting
Date: Sun, 10 Jun 2018 12:29:09 +0200
Subject: [PATCH 2/3] reverse query results and some new links on
show_book_detail
---
app/templates/results.html | 5 +++--
app/templates/results_grid.html | 5 ++---
app/templates/show_book_detail.html | 7 ++++++-
app/views.py | 24 ++++++++++++++++++------
4 files changed, 29 insertions(+), 12 deletions(-)
diff --git a/app/templates/results.html b/app/templates/results.html
index 8e88967..296dc8e 100644
--- a/app/templates/results.html
+++ b/app/templates/results.html
@@ -31,7 +31,7 @@
{% endif %}
{% endwith %}
-
+
+
-
Other books
+
More books
-
-
Category: {{ form.category(size=27, class="form-control") }}
Year published: {{ form.year_published(size=8, class="form-control") }}
-
- Add a message for future readers: {{ form.message(size=150, class="form-control") }}
+
+ Add a message for future readers: {{ form.message(size=90, class="form-control") }}
{{ form.file }}
{{ form.upload }}
{{ form.wish }}
-
+
+
+
+
+
+
+
+
+ Titles: |
+ {{ books_all }} |
+
+
+ Authors: |
+ {{ authors_all }} |
+
+
+ Categories: |
+ {{ categories|replace('[', '')|replace(']', '') }} |
+
+
+ Stacks: |
+ {{ stacks_all|replace('[', '')|replace(']', '') }} |
+
+
+ From the years: |
+ {{earliest}} –– {{latest}} |
+
+
+ Gaps in the collection: |
+ At least {{ books_potential }} potential books missing |
+
+
+
+
{% endblock %}
diff --git a/app/templates/show_book_detail.html b/app/templates/show_book_detail.html
index e7a0e77..19e8c64 100755
--- a/app/templates/show_book_detail.html
+++ b/app/templates/show_book_detail.html
@@ -5,21 +5,40 @@
- Year published: {{ book.year_published }}
- Author(s):
{% for author in book.authors %}
- - {{ author.author_name }}
+
+
+
+
+
+
+ Year published: |
+ {{ book.year_published or '––'}} |
+
+
+ Author(s): |
+ {% for author in book.authors %}
- {% endfor %}
+ {{ author.author_name }}
-Category: {{ book.category }}
-
- Included in stack(s): {% for stack in book.stacks %}
+ {% endfor %} |
+
+
+ Category: |
+ {{ book.category }} |
+
+
+ Included in stack(s): |
+ {% for stack in book.stacks %}
- {{ stack.stack_name }}
-
Remove from stack
-
+ – Remove from stack{% endfor %} |
+
- {% endfor %}
+
+
{% if book.file %}
diff --git a/app/views.py b/app/views.py
index 2a97058..a55aa8a 100755
--- a/app/views.py
+++ b/app/views.py
@@ -200,6 +200,17 @@ def edit_book_by_id(id):
@app.route('/add-book', methods=['POST', 'GET'])
def add_book():
upload_form = UploadForm()
+ allbooks = db.session.query(Book).all()
+ books_all = len(allbooks)
+ allauthors = db.session.query(Author).all()
+ authors_all = len(allauthors)
+ stacks_all = [s.stack_name for s in db.session.query(Stack.stack_name)]
+ categories = [r.category for r in db.session.query(Book.category).distinct()]
+ allpotential = db.session.query(Book).filter(Book.file.contains('potential.pdf')).all()
+ books_potential = len(allpotential)
+ earliest = db.session.query(func.min(Book.year_published)).scalar()
+ latest = db.session.query(func.max(Book.year_published)).scalar()
+
if request.method == 'POST':
if upload_form.validate_on_submit():
@@ -268,7 +279,7 @@ def add_book():
return redirect(url_for('show_books'))
flash_errors(upload_form)
- return render_template('add_book.html', form=upload_form)
+ return render_template('add_book.html', form=upload_form, books_all=books_all, authors_all=authors_all, categories=categories, stacks_all=stacks_all, books_potential=books_potential, earliest=earliest, latest=latest)
# Flash errors from the form if validation fails