diff --git a/app/__pycache__/__init__.cpython-36.pyc b/app/__pycache__/__init__.cpython-36.pyc
index d71f35d..419c685 100644
Binary files a/app/__pycache__/__init__.cpython-36.pyc and b/app/__pycache__/__init__.cpython-36.pyc differ
diff --git a/app/forms.py b/app/forms.py
index a4b251f..c9ccbb4 100755
--- a/app/forms.py
+++ b/app/forms.py
@@ -5,4 +5,5 @@ from wtforms.validators import InputRequired
class UserForm(FlaskForm):
title = StringField('title', validators=[InputRequired()])
author = StringField('author', validators=[InputRequired()])
+ tag = StringField('tag', validators=[InputRequired()])
file = FileField()
diff --git a/app/models.py b/app/models.py
index ebe947a..466bc0a 100755
--- a/app/models.py
+++ b/app/models.py
@@ -6,12 +6,14 @@ class Book(db.Model):
title = db.Column(db.String(255))
author = db.Column(db.String(255))
file = db.Column(db.String(255))
+ tag = db.Column(db.String(255))
- def __init__(self, title, author, file):
+ def __init__(self, title, author, file, tag):
self.title = title
self.author = author
self.file = file
+ self.tag = tag
def __repr__(self):
return '
' % self.title
@@ -22,7 +24,8 @@ class BookSchema(Schema):
title = fields.Str()
author = fields.Str()
file = fields.Str()
+ tag = fields.Str()
def must_not_be_blank(data):
if not data:
- raise ValidationError('Data not provided.')
+ raise ValidationError('You forgot to write stuff.')
diff --git a/app/templates/add_book.html b/app/templates/add_book.html
index a27cccd..d5f4654 100755
--- a/app/templates/add_book.html
+++ b/app/templates/add_book.html
@@ -18,6 +18,8 @@
{{ form.csrf_token }}
{{ form.title.label }} {{ form.title(size=20, class="form-control") }}
{{ form.author.label }} {{ form.author(size=20, class="form-control") }}
+ {{ form.tag.label }} {{ form.tag(size=20, class="form-control") }}
+
{{ form.file }}
Upload
diff --git a/app/templates/show_books.html b/app/templates/show_books.html
index 1e592ee..a49fd53 100755
--- a/app/templates/show_books.html
+++ b/app/templates/show_books.html
@@ -19,11 +19,13 @@
Title
Author
+ Tag
{% for book in books %}
{{ book.title }}
{{ book.author }}
+ {{ book.tag}}
{% endfor %}
diff --git a/app/views.py b/app/views.py
index 7a100e9..1233276 100755
--- a/app/views.py
+++ b/app/views.py
@@ -82,8 +82,9 @@ def add_book():
title = user_form.title.data # You could also have used request.form['name']
author = user_form.author.data # You could also have used request.form['email']
+ tag = user_form.tag.data
# save user to database
- book = Book(title, author, filename)
+ book = Book(title, author, filename, tag)
db.session.add(book)
db.session.commit()
flash("%s added to the library" % (title))