예제 #1
0
파일: topics.py 프로젝트: VincentRong/zerqu
def view_topic(tid):
    topic = Topic.cache.get_or_404(tid)
    data = make_topic_response(topic)

    # /api/topic/:id?content=raw vs ?content=html
    content_format = request.args.get('content')
    if content_format == 'raw':
        data['content'] = topic.content
    else:
        data['content'] = topic.html
        TopicStat(tid).increase('views')

    data['cafes'] = CafeTopic.get_topic_cafes(tid, 1)
    data['user'] = User.cache.get(topic.user_id)
    return jsonify(data)
예제 #2
0
def view_topic(tid):
    topic = Topic.cache.get_or_404(tid)
    data = make_topic_response(topic)

    # /api/topic/:id?content=raw vs ?content=html
    content_format = request.args.get('content')
    if content_format == 'raw':
        data['content'] = topic.content
    else:
        data['content'] = topic.html
        TopicStat(tid).increase('views')

    data['cafes'] = CafeTopic.get_topic_cafes(tid, 1)
    data['user'] = User.cache.get(topic.user_id)
    return jsonify(data)