resolved conflicts

This commit is contained in:
Alex 2018-05-23 14:29:56 +02:00
commit cac319cd62
6 changed files with 21 additions and 5 deletions

View File

@ -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):

View File

@ -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.')

View File

@ -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>

View File

@ -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>

Binary file not shown.

View File

@ -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