示例#1
0
文件: front.py 项目: 343829084/zerqu
def home():
    topics, _ = get_all_topics(0)
    topic_users = User.cache.get_dict({o.user_id for o in topics})
    topic_cafes = CafeTopic.get_topics_cafes([o.id for o in topics])
    return render_template(
        'front/index.html',
        topics=topics,
        topic_users=topic_users,
        topic_cafes=topic_cafes,
    )
示例#2
0
def home():
    topics, _ = get_all_topics(0)
    topic_users = User.cache.get_dict({o.user_id for o in topics})
    topic_cafes = CafeTopic.get_topics_cafes([o.id for o in topics])
    return render(
        'front/index.html',
        topics=topics,
        topic_users=topic_users,
        topic_cafes=topic_cafes,
    )
示例#3
0
def timeline():
    cursor = int_or_raise('cursor', 0)
    if request.args.get('show') == 'all':
        topics, cursor = get_all_topics(cursor)
    else:
        topics, cursor = get_timeline_topics(cursor, current_user.id)

    topics_cafes = CafeTopic.get_topics_cafes([t.id for t in topics])
    data = []
    for d in iter_items_with_users(topics):
        d['cafes'] = topics_cafes.get(d['id'])
        data.append(d)
    data = list(iter_topics_with_statuses(data, current_user.id))
    return jsonify(data=data, cursor=cursor)
示例#4
0
def timeline():
    cursor = int_or_raise('cursor', 0)
    if request.args.get('show') == 'all':
        topics, cursor = get_all_topics(cursor)
    else:
        topics, cursor = get_timeline_topics(cursor, current_user.id)

    topics_cafes = CafeTopic.get_topics_cafes([t.id for t in topics])
    data = []
    for d in iter_items_with_users(topics):
        d['cafes'] = topics_cafes.get(d['id'])
        data.append(d)
    data = list(iter_topics_with_statuses(data, current_user.id))
    return jsonify(data=data, cursor=cursor)