diff --git a/app/forms.py b/app/forms.py index 211872c..607a15b 100755 --- a/app/forms.py +++ b/app/forms.py @@ -1,5 +1,5 @@ from flask_wtf import FlaskForm -from wtforms import StringField, FileField +from wtforms import StringField, FileField, validators from wtforms.validators import InputRequired, DataRequired from wtforms import FieldList from wtforms import Form as NoCsrfForm @@ -15,6 +15,7 @@ class UploadForm(FlaskForm): title = StringField('title', validators=[InputRequired()]) author = FieldList(FormField(AuthorForm, default=lambda: Author()), min_entries=1) category = StringField('category', validators=[InputRequired()]) + year_published = StringField('year published', [validators.Length(min=4, max=4)]) file = FileField() upload = SubmitField(label='Upload') wish = SubmitField(label='''I don't have the file, but wish I did.''') diff --git a/app/models.py b/app/models.py index ea199b3..c0235a7 100755 --- a/app/models.py +++ b/app/models.py @@ -20,6 +20,8 @@ class Book(db.Model): cover = db.Column(db.String(255)) fileformat = db.Column(db.String(255)) category = db.Column(db.String(255)) + year_published = db.Column(db.Numeric(4,0)) + html = db.Column(db.String(255)) authors = db.relationship('Author', secondary=authors,cascade="delete", lazy='subquery', backref=db.backref('books', lazy=True),passive_deletes=True) stacks = db.relationship('Stack', secondary=stacks, lazy='subquery', @@ -27,12 +29,13 @@ class Book(db.Model): scapeX = db.Column(db.Numeric(10,2)) scapeY = db.Column(db.Numeric(10,2)) - def __init__(self, title, file, cover, fileformat, category): + def __init__(self, title, file, cover, fileformat, category, year_published): self.title = title self.file = file self.cover = cover self.fileformat = fileformat self.category = category + self.year_published = year_published self.scapeX = 0 self.scapeY = 0 diff --git a/app/templates/add_book.html b/app/templates/add_book.html index 2121566..c01dc37 100755 --- a/app/templates/add_book.html +++ b/app/templates/add_book.html @@ -36,6 +36,9 @@
{{ form.category.label }} {{ form.category(size=20, class="form-control") }}
+
+
{{ form.year_published.label }} {{ form.year_published(size=4, class="form-control") }}
+
{{ form.file }} {{ form.upload }} {{ form.wish }} diff --git a/app/templates/base.html b/app/templates/base.html index ea87afe..b3eab28 100755 --- a/app/templates/base.html +++ b/app/templates/base.html @@ -42,7 +42,7 @@ $( ".no_cover" ).each(function() { - var string = $(this).children("p").html() + var string = $(this).attr('id') var randomColor = colorHash(string).rgb $(this).css({ diff --git a/app/templates/results.html b/app/templates/results.html index 9262d35..dcbe3cf 100644 --- a/app/templates/results.html +++ b/app/templates/results.html @@ -36,7 +36,7 @@ {% for book in books %} - + {{ book.title }} {% for author in book.authors %} @@ -66,7 +66,7 @@ {% for book in books_all %} - + {{ book.title }} {% for author in book.authors %} @@ -87,5 +87,3 @@ {% endblock %} - - diff --git a/app/templates/scape.html b/app/templates/scape.html index 75745f9..7e222f3 100644 --- a/app/templates/scape.html +++ b/app/templates/scape.html @@ -20,10 +20,8 @@ {% for book in books|sort(attribute='title', reverse = False) %}
- -

{{ book.title }}

- -
+ +

{{ book.title }}

{% endfor %} @@ -40,7 +38,7 @@ $( ".no_cover" ).each(function() { - var string = $(this).children("p").html() + var string = $(this).attr('id'); var randomColor = colorHash(string).rgb $(this).css({ diff --git a/app/templates/show_book_detail.html b/app/templates/show_book_detail.html index 7a1cce5..4963946 100755 --- a/app/templates/show_book_detail.html +++ b/app/templates/show_book_detail.html @@ -4,16 +4,16 @@

{{ book.title }}

- - - - +

Author(s):

+

{{ book.category }}

+

{{ book.year_published }}

+

Stack(s):