From 07dcffefa1131f9a363654818ef4a0ee906b1aa1 Mon Sep 17 00:00:00 2001 From: nberting Date: Fri, 1 Jun 2018 17:20:12 +0200 Subject: [PATCH] added category & title options to search --- app/forms.py | 5 ++- app/static/css/style.css | 3 +- app/templates/edit_book_detail.html | 6 +-- app/templates/header.html | 2 +- app/templates/results.html | 42 ++++++++++++--------- app/templates/show_book_detail.html | 6 +-- app/templates/show_books.html | 5 +-- app/views.py | 57 +++++++++++++++++------------ 8 files changed, 74 insertions(+), 52 deletions(-) diff --git a/app/forms.py b/app/forms.py index 607a15b..5c84f77 100755 --- a/app/forms.py +++ b/app/forms.py @@ -3,7 +3,7 @@ from wtforms import StringField, FileField, validators from wtforms.validators import InputRequired, DataRequired from wtforms import FieldList from wtforms import Form as NoCsrfForm -from wtforms.fields import StringField, FormField, SubmitField +from wtforms.fields import StringField, FormField, SubmitField, SelectField from app.models import Book, BookSchema, Author # - - - Forms - - - @@ -26,4 +26,7 @@ class EditForm(FlaskForm): category = StringField('category', validators=[InputRequired()]) class SearchForm(FlaskForm): + choices = [('Title', 'Title'), + ('Category', 'Category')] + select = SelectField('', choices=choices) search = StringField('', validators=[InputRequired()]) diff --git a/app/static/css/style.css b/app/static/css/style.css index f442e51..103fc59 100755 --- a/app/static/css/style.css +++ b/app/static/css/style.css @@ -74,13 +74,14 @@ font-size: 16px; .search input{ margin: 0; float: left; -width: 400px; +width: 320px; height: 36px; font-size: 20px; font-weight: regular; padding: 2px; background:rgba(50, 50, 50, 0.2); border:0px; +box-shadow: inset 0 0 5px rgba(000,000,000, 0.2); } .button { diff --git a/app/templates/edit_book_detail.html b/app/templates/edit_book_detail.html index f7f9a27..3447d7a 100755 --- a/app/templates/edit_book_detail.html +++ b/app/templates/edit_book_detail.html @@ -11,9 +11,9 @@ {{ form.csrf_token }}

{{ form.title.label }} {{ form.title(size=20, class="form-control") }}

- - - + + +

{{ form.author.label }} -
-

Search Results for: {{ query }}

{% with messages = get_flashed_messages() %} @@ -26,17 +25,18 @@ {% endif %} {% endwith %} - - - +
Cover
+ + - + + {% for book in books %} - + - - + + {% endfor %}
{{ book.title }} {% for author in book.authors %} @@ -45,8 +45,12 @@ {% endfor %} {{ book.fileformat }}{{ book.tag}}
{{ book.category}} {% for stack in book.stacks %} + +
  • {{ stack.stack_name }}
  • + {% endfor %} +
    @@ -56,28 +60,32 @@

    Other books

    - - - +
    Cover
    + + - + + {% for book in books_all %} - + - - + + {% endfor %}
    {{ book.title }} {% for author in book.authors %}
  • {{ author.author_name }}
  • - {% endfor %}
    {{ book.fileformat }}{{ book.tag}}
    {{ book.category}} {% for stack in book.stacks %} + +
  • {{ stack.stack_name }}
  • + {% endfor %} +

    diff --git a/app/templates/show_book_detail.html b/app/templates/show_book_detail.html index 4963946..42cd67d 100755 --- a/app/templates/show_book_detail.html +++ b/app/templates/show_book_detail.html @@ -4,15 +4,15 @@

    {{ book.title }}

    - +

    Author(s):

    -

    {{ book.category }}

    -

    {{ book.year_published }}

    +

    Category: {{ book.category }}

    +

    Year published: {{ book.year_published }}

    Stack(s):

      {% for stack in book.stacks %}
    • {{ stack.stack_name }} diff --git a/app/templates/show_books.html b/app/templates/show_books.html index f6c5667..16272c2 100755 --- a/app/templates/show_books.html +++ b/app/templates/show_books.html @@ -2,9 +2,9 @@ {% block main %}
      - {% from "_formhelpers.html" import render_field %}
      +
      {{ form.select(style="width: 100px; margin: 10px; float: left; font-size: 20px") }}
      @@ -36,8 +36,7 @@ - - +