示例#1
0
def create_topic_comment(tid):
    topic = Topic.cache.get_or_404(tid)
    form = CommentForm.create_api_form()
    comment = form.create_comment(current_user.id, topic.id)
    rv = dict(comment)
    rv['content'] = markup(rv['content'])
    rv['user'] = dict(current_user)
    return jsonify(rv), 201
示例#2
0
def create_topic_comment(tid):
    topic = Topic.cache.get_or_404(tid)
    form = CommentForm.create_api_form()
    comment = form.create_comment(current_user.id, topic.id)
    rv = dict(comment)
    rv['content'] = markup(rv['content'])
    rv['user'] = dict(current_user)
    return jsonify(rv), 201
示例#3
0
def view_topic_comments(tid):
    topic = Topic.cache.get_or_404(tid)
    comments, cursor = cursor_query(Comment,
                                    lambda q: q.filter_by(topic_id=topic.id))
    data = []

    if current_user:
        statuses = Comment.get_multi_statuses([c['id'] for c in comments],
                                              current_user.id)
    else:
        statuses = {}
    for d in iter_items_with_users(comments):
        d['content'] = markup(d['content'])
        # update status
        d.update(statuses.get(str(d['id']), {}))
        data.append(d)
    return jsonify(data=data, cursor=cursor)
示例#4
0
def view_topic_comments(tid):
    topic = Topic.cache.get_or_404(tid)
    comments, cursor = cursor_query(
        Comment, lambda q: q.filter_by(topic_id=topic.id)
    )
    data = []

    if current_user:
        statuses = Comment.get_multi_statuses(
            [c['id'] for c in comments],
            current_user.id
        )
    else:
        statuses = {}
    for d in iter_items_with_users(comments):
        d['content'] = markup(d['content'])
        # update status
        d.update(statuses.get(str(d['id']), {}))
        data.append(d)
    return jsonify(data=data, cursor=cursor)
示例#5
0
文件: topic.py 项目: 343829084/zerqu
 def html(self):
     return markup(self.content)
示例#6
0
 def html(self):
     return markup(self.content)
示例#7
0
def preview_text():
    data = request.get_json()
    text = data.get('text')
    if not text:
        return ''
    return markup(text)