예제 #1
0
def category_list():
    form = CategoryForm(request.values)
    user_id = session[LOGIN_USER_ID]
    if request.method == 'POST':
        if form.validate_on_submit():
            mongodb.add_category(user_id, form.data['category_name'])
            return jsonify(ok('保存成功'))
        else:
            return jsonify(error(40001))
    categories = mongodb.get_categories(user_id)
    return render_template('admin/category_list.html',
                           form=form, categories=categories)
예제 #2
0
def posts_write():
    """
    博客创作
    :return:
    """
    # todo 这里的文章保存验证有问题,现在先不管了
    user_id = session[LOGIN_USER_ID]
    form = PostsForm(request.form)
    if request.method == 'POST':

        return jsonify(ok('保存成功'))

    categories = mongodb.get_categories(user_id)
    return render_template('admin/posts_write.html', **locals())
예제 #3
0
def category_update():
    category_id = request.values.get('category_id', None)
    category_name = request.values.get('category_name', None)
    if category_id and category_name:
        user_id = session[LOGIN_USER_ID]
        category = mongodb.get_categories(user_id, category_id)
        if not category:
            return jsonify(error(40003))
        if category and category_name != category['name']:
            mongodb.update_category(category_id, category_name)
            return jsonify(ok('修改成功'))
        else:
            return jsonify(error(40002))
    else:
        return jsonify(error(30007))