Browse Source

resolved conflicts

ansible-setup-and-deploy
Alex 6 years ago
parent
commit
cac319cd62
  1. 1
      app/forms.py
  2. 9
      app/models.py
  3. 1
      app/templates/add_book.html
  4. 9
      app/templates/show_books.html
  5. BIN
      app/uploads/The_Moral_Of_The_Xerox.pdf
  6. 6
      app/views.py

1
app/forms.py

@ -14,6 +14,7 @@ class AuthorForm(NoCsrfForm):
class UserForm(FlaskForm):
title = StringField('title', validators=[InputRequired()])
author = FieldList(FormField(AuthorForm, default=lambda: Author()), min_entries=1)
tag = StringField('tag', validators=[InputRequired()])
file = FileField()
class UserForm_Edit(FlaskForm):

9
app/models.py

@ -9,12 +9,16 @@ class Book(db.Model):
cover = db.Column(db.String(255))
fileformat = db.Column(db.String(255))
author = db.relationship('Author')
tag = db.Column(db.String(255))
def __init__(self, title, file, cover, fileformat, tag):
def __init__(self, title, file, cover, fileformat):
self.title = title
self.file = file
self.cover = cover
self.fileformat = fileformat
self.tag = tag
def __repr__(self):
return '<Title %r>' % self.title
@ -40,7 +44,8 @@ class BookSchema(Schema):
file = fields.Str()
cover = fields.Str()
fileformat = 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.')

1
app/templates/add_book.html

@ -35,6 +35,7 @@
</table>
</div>
<br>
<div class="form-group">{{ form.tag.label }} {{ form.tag(size=20, class="form-control") }}</div>
{{ form.file }}
<button type="submit" class="btn btn-primary">Upload</button>
</form>

9
app/templates/show_books.html

@ -20,18 +20,27 @@
<th>Cover</th>
<th>Title</th>
<th>Author</th>
<<<<<<< HEAD
<th>Filetype</th>
=======
<th>Tag</th>
>>>>>>> 18f7acebcd760ab12a86ada4423cbefcbdaafdf5
</tr>
{% for book in books %}
<tr>
<td><img src="../uploads/cover/{{ book.cover }}" width="80"></td>
<td><a href="books/{{ book.id }}">{{ book.title }}</a></td>
<<<<<<< HEAD
<td> {% for author in book.author %}
<li> {{ author.author_name }}</li>
{% endfor %}</td>
<td>{{ book.fileformat }}</td>
=======
<td>{{ book.author }}</td>
<td>{{ book.tag}}</td>
>>>>>>> 18f7acebcd760ab12a86ada4423cbefcbdaafdf5
</tr>
{% endfor %}
</table>

BIN
app/uploads/The_Moral_Of_The_Xerox.pdf

Binary file not shown.

6
app/views.py

@ -127,10 +127,11 @@ def add_book():
file.save(fullpath)
cover = get_cover(fullpath, name)
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']
author = user_form.author.data # You could also have used
tag = user_form.tag.data
print(author)
print(len(author))
book = Book(title, filename, cover, file_extension)
book = Book(title, filename, cover, file_extension, tag)
db.session.add(book)
db.session.commit()
book = Book.query.filter_by(title=title).first()
@ -138,7 +139,6 @@ def add_book():
this_author = Author(this_author.get('author_name'))
book.author.append(this_author)
db.session.commit()
#author = "hallo"
# save user to database

Loading…
Cancel
Save