Ejemplo n.º 1
0
def my_gifts():
    uid = current_user.id
    gifts_of_mine = Gift.get_user_gifts(uid)
    isbn_list = [gift.isbn for gift in gifts_of_mine]
    wish_count_list = Gift.get_wishes_counts(isbn_list)
    view_model = MyGifts(gifts_of_mine, wish_count_list)
    return render_template('my_gifts.html', gifts=view_model.gifts)
Ejemplo n.º 2
0
def my_gifts():
    uid = current_user.id
    gifts_of_mine = Gift.get_user_gifts(uid)  #根据当前用户id获取其对应的赠送清单
    isbn_list = [wish.isbn for wish in gifts_of_mine]  #获取赠送清单中全部书籍的isbn号
    wish_count_list = Gift.get_wish_counts(isbn_list)  #根据isbn号查询Wish表有哪些人想要这本书
    view_model = MyTrades(gifts_of_mine, wish_count_list)
    return render_template('my_wish.html', wishes=view_model.trades)
Ejemplo n.º 3
0
def my_gifts():
    UID = current_user.id
    gifts_of_mine = Gift.get_user_gifts(UID)
    isbn_list = [gift.isbn for gift in gifts_of_mine]
    wish_count_list = Gift.get_wish_counts(isbn_list)
    view_model = MyTrades(gifts_of_mine, wish_count_list)
    return render_template('my_gifts.html', gifts=view_model.trades)
Ejemplo n.º 4
0
def my_gifts():
    uid = getattr(g, REQUEST_USER_ID)
    gifts_of_mine = Gift.get_user_gifts(uid)
    isbns = [gift.isbn for gift in gifts_of_mine]
    wish_counts = Gift.get_wish_counts(isbns)
    view = MyGifts(gifts_of_mine, wish_counts)
    return SuccessResponse(data=view.gifts)()
Ejemplo n.º 5
0
def my_gifts():
    uid = current_user.id
    gifts_of_mine = Gift.get_user_gifts(uid)
    isbn_list = [gift.isbn for gift in gifts_of_mine]
    wish_count_list = Gift.get_wish_counts(isbn_list)
    view_model = MyGifts(gifts_of_mine, wish_count_list)  # 因为gifts和wishes的viewmodel是完全一样的 我们可以封装一个trade就行 如果这里要使用 改这两行代码
    return render_template('my_gifts.html', gifts=view_model.gifts)
Ejemplo n.º 6
0
def my_gifts():
    user_id = current_user.id
    user_gifts = Gift.get_user_gifts(user_id)
    isbn_list = [i.isbn for i in user_gifts]
    wish_count_list = Gift.get_wish_counts(isbn_list)

    return 'my gifts'
Ejemplo n.º 7
0
def my_gifts():
    my_gifts_list = Gift.get_user_gifts(current_user.id)
    isbn_list = [gift.isbn for gift in my_gifts_list]
    wish_count_list = Wish.get_all_wishes(isbn_list)
    view_model_of_my_gifts = MyGifts(my_gifts_list=my_gifts_list,
                                     wish_count_list=wish_count_list)
    return render_template("my_gifts.html", gifts=view_model_of_my_gifts.gifts)
Ejemplo n.º 8
0
def my_gifts():
    uid = current_user.id
    gifts_of_mine = Gift.get_user_gifts(uid)
    isbn_list = [gift.isbn for gift in gifts_of_mine]
    wish_count_list = Gift.get_wish_counts(isbn_list)
    view_model = MyTrade(gifts_of_mine, wish_count_list)
    return render_template('my_gifts.html', gifts=view_model.trades)
Ejemplo n.º 9
0
def my_gifts():
    uid = current_user.id
    gifts_list = Gift.get_user_gifts(uid)
    gifts_isbn = [gift.isbn for gift in gifts_list]
    gifts_wishes_count = Gift.get_wishes_count(gifts_isbn)
    my_gifts_view_model = MyTrades(gifts_list, gifts_wishes_count)
    return render_template('my_gifts.html', gifts=my_gifts_view_model.trades)
Ejemplo n.º 10
0
def my_gifts():
    uid = current_user.id
    gifts_of_mine = Gift.get_user_gifts(uid)
    # 根据查询的礼物列表将每个礼物的isbn查询出来组成列表
    gifts_isbn_list = [gift.isbn for gift in gifts_of_mine]
    wish_count_list = Gift.get_wish_counts(gifts_isbn_list)
    my_gifts_view_model = MyTrades(gifts_of_mine, wish_count_list)
    return render_template('my_gifts.html', gifts=my_gifts_view_model.trades)
Ejemplo n.º 11
0
def my_gifts():
    uid = current_user.id
    gifts_of_mine = Gift.get_user_gifts(uid)
    isbn_list = [gift.isbn for gift in gifts_of_mine]
    wishes_count_list = Gift.get_wish_counts(isbn_list)

    my_gifts = MyTrades(gifts_of_mine, wishes_count_list)
    return render_template('my_gifts.html', gifts=my_gifts.trades)
Ejemplo n.º 12
0
def my_gifts():
    gifts_of_mine = Gift.get_user_gifts(current_user.id)
    isbn_list = [gift.isbn for gift in gifts_of_mine]
    wishes_count_list = Gift.get_wish_counts(isbn_list)
    giftViewModel = MyGiftViewModels(gifts_of_mine, wishes_count_list)
    print("*************************")
    print(giftViewModel.gifts)
    return render_template("my_gifts.html", gifts=giftViewModel.gifts)
Ejemplo n.º 13
0
def my_gifts():
    uid = current_user.id
    gifts_of_mine = Gift.get_user_gifts(uid)  # 用户的礼物清单
    # 需要查询想要书籍的人数
    isbn_list = [gift.isbn for gift in gifts_of_mine]
    wish_count_list = Gift.get_wish_counts(isbn_list)
    view_model = MyTrades(gifts_of_mine, wish_count_list)
    return render_template('my_gifts.html', gifts=view_model.trades)
Ejemplo n.º 14
0
def my_gifts():
    uid = current_user.id
    gifts = Gift.get_user_gifts(uid)
    isbn_list = [gift.isbn for gift in gifts]
    wish_count_list = Gift.get_wish_counts(isbn_list)
    # Gift.get_wish_counts(isbn_list)
    view_model = MyTrades(gifts, wish_count_list)
    return render_template('my_gifts.html', gifts=view_model.trades)
Ejemplo n.º 15
0
def my_gifts():
    uid = current_user.id
    gifts = Gift.query.filter_by(uid=uid, launched=False).order_by(
        desc(Gift.create_time)).all()
    gifts_of_mine = Gift.get_user_gifts(uid)
    isbn_list = [gift.isbn for gift in gifts]
    wish_count_list = Gift.get_wish_counts(isbn_list)
    view_model = MyGifts(gifts_of_mine, wish_count_list)
    return render_template('my_gifts.html', gifts=view_model.gifts)
Ejemplo n.º 16
0
def my_gifts():
    uid = current_user.id
    from app.models.gift import Gift
    gifts_of_mine = Gift.get_user_gifts(uid)
    isbn_list = [gift.isbn for gift in gifts_of_mine]
    wish_count_list = Gift.get_wish_counts(isbn_list)
    # view_model = MyGifts(gifts_of_mine,wish_count_list)
    view_model = MyTrades(gifts_of_mine, wish_count_list)
    return render_template('my_gifts.html', gifts=view_model.trades)
Ejemplo n.º 17
0
def my_gifts():
    uid = current_user.id
    gifts_of_mine = Gift.get_user_gifts(uid)
    #获取gift的ISBN列表
    isbn_list = [gift.isbn for gift in gifts_of_mine]
    #计算想要这本书的人数,返回人数 和 ISBN 的集合
    wish_count_list = Gift.get_wish_counts(isbn_list)
    #修改格式显示
    view_model = MyGifts(gifts_of_mine, wish_count_list)
    return render_template('my_gifts.html', gifts=view_model.gifts)
Ejemplo n.º 18
0
def my_gifts():
   uid = current_user.id
   # 获取当前用户的礼物数量
   gifts_of_mine = Gift.get_user_gifts(uid)
   # 取出每个礼物的isbn
   isbn_list = [gift.isbn for gift in gifts_of_mine]
   wish_count_list = Gift.get_wish_counts(isbn_list)

   view_model = MyTrades(gifts_of_mine, wish_count_list)
   
   return render_template('my_gifts.html', gifts=view_model.trades)
Ejemplo n.º 19
0
def my_gifts():
    uid = current_user.id
    # 获取当前用户未赠送的礼物列表
    gifts_of_mine = Gift.get_user_gifts(uid)
    # 获取isbn列表
    isbn_list = [gift.isbn for gift in gifts_of_mine]
    # 获取这些isbn的心愿数量
    wish_count_list = Gift.get_wish_counts(isbn_list)
    # 封装视图模型
    view_model = MyTrades(gifts_of_mine, wish_count_list)
    return render_template('my_gifts.html', gifts=view_model.trades)
Ejemplo n.º 20
0
def my_gifts():
    """
    http://localhost:8088/my/gifts
    """
    uid = current_user.id
    gifts_of_mine = Gift.get_user_gifts(uid)
    # 列表推导式获取礼物的isbn列表
    isbn_list = [gift.isbn for gift in gifts_of_mine]
    wish_count_list = Gift.get_wish_counts(isbn_list)
    view_model = MyGifts(gifts_of_mine, wish_count_list)
    return render_template('my_gifts.html', gifts=view_model.gifts)
Ejemplo n.º 21
0
def my_gifts():
    uid = current_user.id
    # get all gifts uploaded by current user
    gifts_of_mine = Gift.get_user_gifts(uid)
    # get the isbn list of all these books
    isbn_list = [gift.isbn for gift in gifts_of_mine]
    # use "mysql in" to search the results in wishes
    wish_count_list = Gift.get_wish_counts(isbn_list)

    gifts_view_model = MyTrades(gifts_of_mine, wish_count_list)
    return render_template('my_gifts.html', gifts=gifts_view_model.trades)
Ejemplo n.º 22
0
def personal_center():
    uid = current_user.id
    cur_user = User.query.get_or_404(uid)
    user = cur_user.summary
    # summary返回一个自定义的字典,详情在user模型下
    # b = a.summary
    gifts = Gift.get_user_gifts(uid)
    wishes = Wish.get_user_wishes(uid)
    return render_template('personal.html',
                           user=user,
                           gifts=gifts,
                           wishes=wishes)  # 网页模板下
Ejemplo n.º 23
0
def my_gifts():
    uid = current_user.id
    # 查询出我的礼物
    gifts_of_mine = Gift.get_user_gifts(uid)
    # 查询出我的礼物isbn,列表
    gifts_list_isbn = [gift.isbn for gift in gifts_of_mine]
    # 根据礼物的isbn,查询出每个礼物对应的加入心愿数量
    gifts_of_gift_count = Gift.get_wish_count(gifts_list_isbn)
    # view_model = MyGifts(gifts_of_mine, gifts_of_gift_count)
    # 将 MyGifts 和 MyWishes封装成MyTrades
    view_model = MyTrades(gifts_of_mine, gifts_of_gift_count)
    return render_template('my_gifts.html', gifts=view_model.trades)
Ejemplo n.º 24
0
def my_gifts():
  uid = current_user.id
  #查询出当前用户的所有礼物清单
  gifts_of_mine = Gift.get_user_gifts(uid)

  #根据礼物清单 查询每个礼物的想要的人的数量
  isbn_list = [gift.isbn for gift in gifts_of_mine]

  wish_count_list = Gift.get_wish_counts(isbn_list)

  view_model = MyTrades(gifts_of_mine, wish_count_list)

  return render_template('my_gifts.html', gifts=view_model.trades)
Ejemplo n.º 25
0
def my_gifts():
    """
    用插件的装饰器@login_required来控制必须要登录后才能去这个页面
    赠送清单:礼物清单、倒序排列、书籍想要人的数量、我的礼物总数量、可撤销
    :return:
    """
    uid = current_user.id
    gifts_of_mine = Gift.get_user_gifts(uid)
    isbn_list = [gift.isbn for gift in gifts_of_mine]
    wish_count_list = Gift.get_wish_counts(isbn_list)
    # view_model = MyGifts(gifts_of_mine, wish_count_list)
    # return render_template('my_gifts.html', gifts=view_model.gifts)
    view_model = MyTrades(gifts_of_mine, wish_count_list)
    return render_template('my_gifts.html', gifts=view_model.trades)
Ejemplo n.º 26
0
def my_gifts():
    '''
        思路:
                循环遍历我的礼物
                取出每个礼物的ISBN编号,组成一个列表
                使用in查询去Wish表中查询在isbn列表中的心愿,并计算数量
    '''
    # 获取当前用户的ID
    uid = current_user.id
    gifts_of_mine = Gift.get_user_gifts(uid)
    isbn_list = [gift.isbn for gift in gifts_of_mine]
    wish_count_list = Gift.get_wish_counts(isbn_list)
    view_model = MyTrades(gifts_of_mine, wish_count_list)
    return render_template('my_gifts.html', gifts=view_model.trades)
Ejemplo n.º 27
0
def my_gifts():
    '''
    思路1 循环遍历我的礼物,根据每个礼物的isbn去Wish表中查这个书籍的相关心愿并计算数量
    思路2 取出每个礼物中的isbn编号 组成一个列表
    使用in查询去Wish表中查询在isbn列表中的心愿并计算数量

    这里使用思路2
    '''
    uid = current_user.id
    gifts_of_mine = Gift.get_user_gifts(uid)
    isbn_list = [gift.isbn for gift in gifts_of_mine]
    wish_count_list = Gift.get_wish_counts(isbn_list)

    view_model = MyGifts(gifts_of_mine, wish_count_list)
    return render_template('my_gifts.html', gifts_of_mine=view_model.gifts)
Ejemplo n.º 28
0
def my_gifts():
    uid = current_user.id
    gifts_of_mine = Gift.get_user_gifts(uid)
    print(gifts_of_mine)
    isbn_list = [gift.isbn for gift in gifts_of_mine]
    print(isbn_list)
    wish_count_list = Gift.get_wish_counts(isbn_list)
    print(wish_count_list)
    view_model = MyGifts(gifts_of_mine,wish_count_list)
    # for i in view_model.gifts:
    #     print(i)
    #
    print(view_model.gifts)
    return render_template('my_gifts.html',gifts=view_model.gifts)
    return 'nihaoa'
Ejemplo n.º 29
0
def my_gifts():
    #赠送清单
    #显示所有赠送的书籍
    #显示多少人想要
    #按时间顺序排列
    # 赠送清单
    # 赠送的数量
    # 每本书有几个人想要
    # 撤销
    uid = current_user.id
    get_gifts_mine = Gift.get_user_gifts(uid)
    isbn_list = [gift.isbn for gift in get_gifts_mine]
    wish_count_list = Gift.get_wish_counts(isbn_list)
    view_model = MyTrades(get_gifts_mine,wish_count_list)
    return render_template('my_gifts.html',gifts=view_model.trades)
Ejemplo n.º 30
0
def my_gifts():
    """
    我的赠送清单
    :return:
    """

    cid = current_user.id

    my_gifts = Gift.get_user_gifts(uid=cid)

    isbn_list = [gift.isbn for gift in my_gifts]

    wish_count_list = Gift.get_wish_counts(isbn_list)

    wish_model = MyGifts(my_gifts, wish_count_list)
    return render_template('my_gifts.html', gifts=wish_model.gifts)
Ejemplo n.º 31
0
def my_gifts():
    """
    uid = current_user.id
    gifts_of_mine = Gift.get_user_gifts(uid) # 拿到当前用户的所有gift对象列表
    isbn_list = [gift.isbn for gift in gifts_of_mine] # 得到一个列表,这个列表是用户的gift对象的isbn列表
    wish_count_list = Gift.get_wish_counts(isbn_list) # 得到一个列表,这个列表里面是字典,字典有两个键值对,一个count,一个isbn
    # 拿到了这个用户的礼物对象列表。还有每个礼物的isbn和对应有多少个礼物。对接的数据:一个gifts列表,列表里是对象gift,它有属性book(BookViewModel),wishes_count,id
    view_model = MyTrade(gifts_of_mine, isbn_list)
    return render_template('my_gifts.html', gifts=view_model)
    """

    uid = current_user.id
    gifts_of_mine = Gift.get_user_gifts(uid)  # 拿到这个uid的所有gift列表
    isbn_list = [gift.isbn for gift in gifts_of_mine]  # 把这个列表转换成一个由isbn组成的列表
    wish_count_list = Gift.get_wish_counts(
        isbn_list
    )  # 通过一个数组参数,拿到一个列表,这个列表只有每个isbn对应的想要人数。[(count,isbn), (count, isbn)],这里只做一次查询。一个列表进去,然后出来一个列表。
    view_model = MyTrades(gifts_of_mine, wish_count_list)
    return render_template('my_gifts.html', gifts=view_model.trades)