def save_to_wish(isbn): if current_user.can_save_to_list(isbn): with db.auto_commit(): wish = Wish() wish.isbn = isbn wish.uid = current_user.id db.session.add(wish) else: flash('这本书已添加至赠送清单或已存在心愿清单') return redirect(url_for('web.book_detail', isbn=isbn))
def save_to_wish(isbn): if current_user.can_save_to_list(isbn): with db.auto_to_commit(): wish = Wish() wish.isbn = isbn wish.uid = current_user.id ############################### db.session.add(wish) else: flash("这本书已经添加到你的赠送清单,或已存放到你的心愿清单,请不熬重复添加") return redirect(url_for('web.book_detail', isbn=isbn))
def save_to_wish(isbn): can = current_user.can_save_gift_or_wish(isbn) if can: with db.auto_commit(): wish = Wish() wish.uid = current_user.id wish.isbn = isbn db.session.add(wish) flash('添加到心愿清单成功') else: flash('本书籍isbn号无效,或者已经添加到您的心愿/礼物清单') return redirect(url_for('web.book_detail', isbn=isbn))
def save_to_wish(isbn): if current_user.can_save_to_list(isbn): with db.auto_commit(): wish = Wish() wish.isbn = isbn wish.uid = current_user.id current_user.beans = current_app.config['BEANS_UPLOAD_ONE_BOOK'] db.session.add(wish) # except Exception as e: # db.session.rollback() # raise e else: flash('这本书已添加至你的赠送清单或已存在于你的心愿清单,请不要重复添加') return redirect(url_for('web.book_detail', isbn=isbn))