resolved conflicts
This commit is contained in:
commit
cac319cd62
@ -14,6 +14,7 @@ class AuthorForm(NoCsrfForm):
|
|||||||
class UserForm(FlaskForm):
|
class UserForm(FlaskForm):
|
||||||
title = StringField('title', validators=[InputRequired()])
|
title = StringField('title', validators=[InputRequired()])
|
||||||
author = FieldList(FormField(AuthorForm, default=lambda: Author()), min_entries=1)
|
author = FieldList(FormField(AuthorForm, default=lambda: Author()), min_entries=1)
|
||||||
|
tag = StringField('tag', validators=[InputRequired()])
|
||||||
file = FileField()
|
file = FileField()
|
||||||
|
|
||||||
class UserForm_Edit(FlaskForm):
|
class UserForm_Edit(FlaskForm):
|
||||||
|
@ -9,12 +9,16 @@ class Book(db.Model):
|
|||||||
cover = db.Column(db.String(255))
|
cover = db.Column(db.String(255))
|
||||||
fileformat = db.Column(db.String(255))
|
fileformat = db.Column(db.String(255))
|
||||||
author = db.relationship('Author')
|
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.title = title
|
||||||
self.file = file
|
self.file = file
|
||||||
self.cover = cover
|
self.cover = cover
|
||||||
self.fileformat = fileformat
|
self.fileformat = fileformat
|
||||||
|
self.tag = tag
|
||||||
|
|
||||||
|
|
||||||
def __repr__(self):
|
def __repr__(self):
|
||||||
return '<Title %r>' % self.title
|
return '<Title %r>' % self.title
|
||||||
@ -40,7 +44,8 @@ class BookSchema(Schema):
|
|||||||
file = fields.Str()
|
file = fields.Str()
|
||||||
cover = fields.Str()
|
cover = fields.Str()
|
||||||
fileformat = fields.Str()
|
fileformat = fields.Str()
|
||||||
|
tag = fields.Str()
|
||||||
|
|
||||||
def must_not_be_blank(data):
|
def must_not_be_blank(data):
|
||||||
if not data:
|
if not data:
|
||||||
raise ValidationError('Data not provided.')
|
raise ValidationError('You forgot to write stuff.')
|
||||||
|
@ -35,6 +35,7 @@
|
|||||||
</table>
|
</table>
|
||||||
</div>
|
</div>
|
||||||
<br>
|
<br>
|
||||||
|
<div class="form-group">{{ form.tag.label }} {{ form.tag(size=20, class="form-control") }}</div>
|
||||||
{{ form.file }}
|
{{ form.file }}
|
||||||
<button type="submit" class="btn btn-primary">Upload</button>
|
<button type="submit" class="btn btn-primary">Upload</button>
|
||||||
</form>
|
</form>
|
||||||
|
@ -20,18 +20,27 @@
|
|||||||
<th>Cover</th>
|
<th>Cover</th>
|
||||||
<th>Title</th>
|
<th>Title</th>
|
||||||
<th>Author</th>
|
<th>Author</th>
|
||||||
|
<<<<<<< HEAD
|
||||||
<th>Filetype</th>
|
<th>Filetype</th>
|
||||||
|
=======
|
||||||
|
<th>Tag</th>
|
||||||
|
>>>>>>> 18f7acebcd760ab12a86ada4423cbefcbdaafdf5
|
||||||
</tr>
|
</tr>
|
||||||
{% for book in books %}
|
{% for book in books %}
|
||||||
<tr>
|
<tr>
|
||||||
<td><img src="../uploads/cover/{{ book.cover }}" width="80"></td>
|
<td><img src="../uploads/cover/{{ book.cover }}" width="80"></td>
|
||||||
<td><a href="books/{{ book.id }}">{{ book.title }}</a></td>
|
<td><a href="books/{{ book.id }}">{{ book.title }}</a></td>
|
||||||
|
<<<<<<< HEAD
|
||||||
<td> {% for author in book.author %}
|
<td> {% for author in book.author %}
|
||||||
|
|
||||||
<li> {{ author.author_name }}</li>
|
<li> {{ author.author_name }}</li>
|
||||||
|
|
||||||
{% endfor %}</td>
|
{% endfor %}</td>
|
||||||
<td>{{ book.fileformat }}</td>
|
<td>{{ book.fileformat }}</td>
|
||||||
|
=======
|
||||||
|
<td>{{ book.author }}</td>
|
||||||
|
<td>{{ book.tag}}</td>
|
||||||
|
>>>>>>> 18f7acebcd760ab12a86ada4423cbefcbdaafdf5
|
||||||
</tr>
|
</tr>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</table>
|
</table>
|
||||||
|
BIN
app/uploads/The_Moral_Of_The_Xerox.pdf
Normal file
BIN
app/uploads/The_Moral_Of_The_Xerox.pdf
Normal file
Binary file not shown.
@ -127,10 +127,11 @@ def add_book():
|
|||||||
file.save(fullpath)
|
file.save(fullpath)
|
||||||
cover = get_cover(fullpath, name)
|
cover = get_cover(fullpath, name)
|
||||||
title = user_form.title.data # You could also have used request.form['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(author)
|
||||||
print(len(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.add(book)
|
||||||
db.session.commit()
|
db.session.commit()
|
||||||
book = Book.query.filter_by(title=title).first()
|
book = Book.query.filter_by(title=title).first()
|
||||||
@ -138,7 +139,6 @@ def add_book():
|
|||||||
this_author = Author(this_author.get('author_name'))
|
this_author = Author(this_author.get('author_name'))
|
||||||
book.author.append(this_author)
|
book.author.append(this_author)
|
||||||
db.session.commit()
|
db.session.commit()
|
||||||
#author = "hallo"
|
|
||||||
# save user to database
|
# save user to database
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user