Exemplo n.º 1
0
def delete_category(category_id):
    trans_list = Transaction.query.filter_by(category_id=category_id).all()
    if len(trans_list) > 0:
        return 'Category is connected to some transactions', 400

    Category.get(category_id).delete()
    return jsonify(response=True)
Exemplo n.º 2
0
def post_category():
    user_id = current_user.id
    name = request.json['category']['name']
    cat_id = request.json['category']['id']
    category = Category(name, user_id)
    category.id = cat_id
    ret = category.update()
    return jsonify(response=ret.serialize())
Exemplo n.º 3
0
def put_category():
    user_id = current_user.id
    name = request.json['category']['name']
    category = Category(name, user_id)
    ret = category.add()
    return jsonify(response=ret.serialize())
Exemplo n.º 4
0
def get_categories():
    user_id = current_user.id
    di.init_categories(user_id)
    return jsonify(response=Category.serialize_list(Category.all(user_id)))