Exemple #1
0
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('my_wish.html', wishes=view_model.gifts)
Exemple #2
0
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_gifts_counts(isbn_list)
    view_Model = MyTrades(wishes_of_mine, gift_count_list)
    return render_template('my_wish.html', wishes=view_Model.trades)
Exemple #3
0
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))
Exemple #4
0
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))
Exemple #5
0
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))
Exemple #6
0
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))
Exemple #7
0
def my_wish():
    wishes = Wish.my_wish(current_user.id)
    isbn_list = [isbn.book.isbn for isbn in wishes]
    trades = []
    if len(isbn_list) > 0:
        isbn_count_list = Gift.get_gift_cout_by_isbnlist(isbn_list)
        trades = MyTradesView(wishes, isbn_count_list).trades
    return render_template('my_wish.html', wishes=trades)
Exemple #8
0
def my_gifts():
    gifts = Gift.my_gift(current_user.id)
    isbn_list = [isbn.book.isbn for isbn in gifts]
    trades = []
    if len(isbn_list) > 0:
        isbn_count_list = Wish.get_wish_cout_by_isbnlist(isbn_list)
        trades = MyTradesView(gifts, isbn_count_list).trades
    return render_template('my_gifts.html', gifts=trades)