def redraw_from_wish(isbn): pass uid = current_user.id Wish.redraw_from_wish(uid=uid, isbn=isbn) return redirect(url_for('web.my_wish'))
def my_wish(): uid = current_user.id wishes_of_mine = Wish.get_user_wishes(uid) isbn_list = [wish.isbn for wish in wishes_of_mine] gift_count_list = Wish.get_gift_counts(isbn_list) view_model = MyTrades(wishes_of_mine, gift_count_list) return render_template('my_wish.html', wishes=view_model.trades)
def my_wish(): uid = current_user.id wishes = Wish.get_user_wishes(uid) isbn_list = [wish.isbn for wish in wishes] gift_count_list = Wish.get_gift_connts(isbn_list) view_model = MyWishes(wishes,gift_count_list) render_template('my_wish.html', wishes=view_model.gifts)
def my_wish(): uid = current_user.id wishes_list = Wish.get_user_wishes(uid) wishes_isbn = [gift.isbn for gift in wishes_list] wishes_gifts_count = Wish.get_gifts_count(wishes_isbn) my_wishes_view_model = MyTrades(wishes_list, wishes_gifts_count) return render_template('my_wish.html', wishes=my_wishes_view_model.trades)
def my_wish(): uid = current_user.id wishes = Wish.get_user_wish(uid) isbn_list = [wish.isbn for wish in wishes] wish_count = Wish.wish_count(isbn_list) wish_model = WishViewModel(wishes, wish_count) return render_template('my_wish.html', wishes=wish_model.assamble())
def my_wish(): uid = current_user.id wishes_of_mine = Wish.get_user_wishes(uid) isbn_list = [wish.isbn for wish in wishes_of_mine] gift_count_list = Wish.get_gift_count(isbn_list) my_wish_view_model = MyWishesViewModel(wishes_of_mine, gift_count_list) return render_template('my_wishes.html', wishes=my_wish_view_model.wishes)
def my_wish(): uid = getattr(g, REQUEST_USER_ID) wishes_of_mine = Wish.get_user_wishes(uid) isbns = [wish.isbn for wish in wishes_of_mine] gift_counts = Wish.get_gift_counts(isbns) wishes = MyWishes(wishes_of_mine, gift_counts) return SuccessResponse(data=wishes.gifts)()
def my_wish(): uid = current_user.id wishes_of_mine = Wish.my_wishes(uid) wish_isbns = [wish.isbn for wish in wishes_of_mine] count_list = Wish.get_gift_count(wish_isbns) view_model = MyWishes(wishes_of_mine, count_list).wishes return render_template('my_wish.html', wishes=view_model)
def my_wish(): uid = current_user.id wishes_of_mine = Wish.get_my_wish(uid) isbn_list = [wish.isbn for wish in wishes_of_mine] my_gift_count = Wish.get_gift_count(isbn_list) view_wishes = MyWishes(wishes_of_mine, my_gift_count) return render_template('my_wish.html', wishes=view_wishes.wishes)
def my_wish(): uid = current_user.id wishes_of_mine = Wish.get_user_wishes(uid) isbn_list = [gift.isbn for gift in wishes_of_mine] gift_count_list = Wish.get_gift_counts(isbn_list) view_model = MyTrade(wishes_of_mine, gift_count_list) return render_template('my_wish.html', wishes=view_model.trades)
def my_wish(): '''处理心愿清单页面。''' uid = current_user.id wishes_of_mine = Wish.get_user_wishes(uid) isbn_list = [wish.isbn for wish in wishes_of_mine] gift_count_list = Wish.get_gift_counts(isbn_list) view_model = MyWishes(wishes_of_mine, gift_count_list) return render_template('web/my_wishes.html', wishes=view_model.wishes)
def my_wish(): from app.view_models.wish import MyWishes uid = current_user.id wishes_of_mine = Wish.get_user_wishes(uid) book_id_list = [wish.book_id for wish in wishes_of_mine] wish_count_list = Wish.get_gift_counts(book_id_list) view_model = MyWishes(wishes_of_mine, wish_count_list) return render_template('my_wish.html', wishes=view_model.wishes)
def my_wish(): uid = current_user.id trade_of_mine = Wish.get_user_wish(uid) isbn_list = [trade.isbn for trade in trade_of_mine] trade_count_dict = Wish.get_wish_counts(isbn_list) wishs = MyTrade(trade_of_mine, trade_count_dict).trade return render_template('my_wish.html', wishes=wishs)
def my_wish(): uid = current_user.id # Gift.get_user_gifts(uid) wishes_of_mine = Wish.get_user_gifts(uid) isbn_list = [gift.isbn for gift in wishes_of_mine] gift_count_list = Wish.get_wish_counts(isbn_list) view_model = MyWishes(wishes_of_mine, gift_count_list) return render_template('my_wish.html', wishes=view_model.gifts) pass
def save_to_wish(isbn): if current_user.can_save_to_list(isbn): with db.auto_commit(): wish = Wish() wish.uid = current_user.id wish.isbn = isbn db.session.add(wish) else: flash('这本书已经添加至你的赠送清单或者已存在于你的心愿清单,请不要重复添加')
def my_wish(): # 1,wish表查wishes # 2.isbn_list # 3,gift表查x人要送 wishes = Wish.get_wishes_by(current_user.id) isbn_list = [wish.isbn for wish in wishes] gifts_count = Wish.get_gifts_count(isbn_list) my_wishes = MyWishes(wishes, gifts_count) return render_template('my_wish.html', wishes=my_wishes.wishes)
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 my_wish(): uid = current_user.id wishes_of_mine = Wish.get_user_wishes(uid) # 获取wish的ISBN列表 isbn_list = [wish.isbn for wish in wishes_of_mine] # 计算想送这本书的人数,返回人数 和 ISBN 的集合 gift_count_list = Wish.get_gifts_counts(isbn_list) #gift 和 wish 的模板结构一样,复用gift的模板 view_model = MyGifts(wishes_of_mine, gift_count_list) return render_template('my_wishes.html', wishes=view_model.gifts)
def save_to_wish(isbn): if current_user.can_save_to_db(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_commit(): wish = Wish() wish.uid = current_user.id wish.isbn = isbn db.session.add(wish) else: flash('这本书已在您的愿望清单或赠送清单') return render_template(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.uid = current_user.id wish.isbn = isbn db.session.add(wish) else: flash("you already added this book in your wish list") return redirect(url_for('web.book_detail', isbn=isbn))
def save_to_wish(isbn): if current_user.can_save_to_list(isbn): wish = Wish() attrs_dict = {'isbn': isbn, 'uid': current_user.id} with db.auto_commit(): wish.set_attrs(attrs_dict) 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): wish = Wish() wish.isbn = isbn wish.uid = current_user.id with db.auto_commit(): 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_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 set_data(): print('开始生成虚拟数据......') try: User.generate_fake(50) Book.generate_fake(50) Present.generate_fake(50) Wish.generate_fake(50) except Exception as e: raise e print('完成....')
def my_wish(): cid = current_user.id my_gifts = Wish.get_user_wishes(uid=cid) isbn_list = [wish.isbn for wish in my_gifts] wish_count_list = Wish.get_gift_counts(isbn_list) # view model层 wish_model = MyWishes(my_gifts, wish_count_list) return render_template('my_wish.html', wishes=wish_model.gifts) pass
def save_to_wish(isbn): if current_user.can_save_to_list(isbn): with db.auto_commit(): wish = Wish() wish.uid = current_user.id wish.isbn = isbn db.session.add(wish) else: flash('这本书已添加到你的赠送清单或已存在于你的心愿清单,请不要重复添加') return redirect(url_for('web.book_detail', isbn=isbn))
def save_to_wish(isbn): if current_user.can_add_list(isbn): with db.auto_commit(): gift = Wish() gift.isbn = isbn gift.uid = current_user.id db.session.add(gift) 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_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_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_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) else: flash('这本书已经添加至你的赠送清单或已存在于你的心愿清单,请不要重复添加') return redirect(url_for('web.book_detail', isbn=isbn))
def save_to_wish(isbn): if current_user.can_save_to_list(isbn): # auto_commit为自定义上下文管理器 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): # 事务,保证user和gift的一致性,rollback # try: 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) # db.session.commit() # except Exception as e: # db.session.rollback() # raise e else: flash('这本书已经添加至你的赠送清单或者一存在于你的心愿清单,请不要重复添加') return redirect('web.book_detail', isbn=isbn)