예제 #1
0
파일: topics.py 프로젝트: VincentRong/zerqu
def update_topic(tid):
    topic = Topic.query.get(tid)
    if not topic:
        raise NotFound('Topic')

    if not topic.editable:
        raise Denied('updating this topic')

    form = TopicForm.create_api_form(obj=topic)
    topic = form.update_topic(current_user.id)
    data = make_topic_response(topic)
    data['user'] = dict(current_user)
    data['content'] = topic.html
    return jsonify(data)
예제 #2
0
def update_topic(tid):
    topic = Topic.query.get(tid)
    if not topic:
        raise NotFound('Topic')

    if not topic.editable:
        raise Denied('updating this topic')

    form = TopicForm.create_api_form(obj=topic)
    topic = form.update_topic(current_user.id)
    data = make_topic_response(topic)
    data['user'] = dict(current_user)
    data['content'] = topic.html
    return jsonify(data)
예제 #3
0
파일: cafes.py 프로젝트: valley51/zerqu
def create_cafe_topic(slug):
    cafe = Cafe.cache.first_or_404(slug=slug)

    if not current_user.is_active:
        raise InvalidAccount(description='Your account is not active')

    if cafe.permission == Cafe.PERMISSION_PUBLIC:
        CafeMember.get_or_create(cafe.id, current_user.id)

    form = TopicForm.create_api_form()
    topic = form.create_topic(current_user.id)

    with db.auto_commit():
        cafe.create_cafe_topic(topic.id, current_user.id)

    data = dict(topic)
    data['user'] = dict(current_user)
    data['content'] = topic.html
    return jsonify(data), 201
예제 #4
0
파일: topics.py 프로젝트: VincentRong/zerqu
def create_topic():
    form = TopicForm.create_api_form()
    topic = form.create_topic(current_user.id)
    data = make_topic_response(topic)
    return jsonify(data)