本文整理汇总了Python中models.Book.remove_author方法的典型用法代码示例。如果您正苦于以下问题:Python Book.remove_author方法的具体用法?Python Book.remove_author怎么用?Python Book.remove_author使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类models.Book
的用法示例。
在下文中一共展示了Book.remove_author方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: edit_book
# 需要导入模块: from models import Book [as 别名]
# 或者: from models.Book import remove_author [as 别名]
#.........这里部分代码省略.........
length = float(xml.Items.Item.ItemAttributes.PackageDimensions.Length)
book.length = round(length * 2.54/100, 1)
except AttributeError:
book.length = ''
try:
width = float(xml.Items.Item.ItemAttributes.PackageDimensions.Width)
book.width = round(width * 2.54/100, 1)
except AttributeError:
book.width = ''
try:
mass = float(xml.Items.Item.ItemAttributes.PackageDimensions.Weight)
book.mass = round(mass * 0.45/100,2)
except AttributeError:
book.mass = ''
try:
book.numberofpages = int(xml.Items.Item.ItemAttributes.NumberOfPages)
except AttributeError:
book.numberofpages = ''
try:
book.summary = unicode(xml.Items.Item.EditorialReviews.EditorialReview.Content)
except AttributeError:
book.summary = ''
title = 'Ajouter un livre d\'Amazon dans la bibliotheque'
else:
book = Book.query.get(number)
title = book.title
if os.path.exists('app/static/covers/' + str(book.id)):
book.img = True
form = BookForm()
form.authortoadd.choices = Author.query.filter(Author!=book.authors)
update = False
#if form.validate_on_submit():
if request.form=='POST' and form.validate():
#print form.errors
book.title = unicode(form.title.data)
# on ajoute les élements en dessous, mais s'ils ne sont pas là, c'est pas grave !
if form.ean.data != book.ean:
book.ean = unicode(form.ean.data)
update = True
if form.isbn.data != book.isbn:
book.isbn = unicode(form.isbn.data)
update = True
if form.thickness.data != book.thickness:
book.thickness = unicode(form.thickness.data)
update = True
if form.width.data != book.width:
book.width = unicode(form.width.data)
update = True
if form.length.data != book.length:
book.length = form.length.data
update = True
if form.summary.data != book.summary and form.summary.data != None:
book.summary = unicode(form.summary.data)
update = True
if form.mass.data != book.mass:
book.mass = form.mass.data
update = True
#if form.numberofpages.data != book.numberofpages:
# book.numberofpages = int(form.numberofpages.data)
# if type(book.numberofpages) == 'int'
# update = True
if form.publisher.data != book.publisher and form.publisher.data != None:
book.publisher = unicode(form.publisher.data)
update = True
#
# gestion des auteurs
if request.form.getlist('authortodelete'):
for item in request.form.getlist('authortodelete'):
a = Author.query.get(item)
book.remove_author(a)
update = True
#
if request.form.getlist('authortoadd'):
for item in request.form.getlist('authortoadd'):
# Same as authors, see upside.
if item != '__None':
a = Author.query.get(item)
book.add_author(a)
update = True
# adding the book to the db
if update:
db.session.add(book)
db.session.commit()
db.session.refresh(book)
image_finale = False
if amazon_img:
image_finale = urllib.urlopen(amazon_img)
if request.method == 'POST' and request.files['cover']:
image_finale = request.files['cover']
if image_finale:
fileurl = 'app/static/covers/' + str(book.id)
image = FileStorage(image_finale).save(fileurl)
return redirect('/admin')
return render_template('edit_book.html', form = form, book = book, title = title, amazon_img = amazon_img)