06/03 Optimize codes, fix transactions import functions
This commit is contained in:
@@ -221,6 +221,18 @@ def edit(id):
|
||||
title='Edit Transaction')
|
||||
|
||||
|
||||
@transactions_bp.route('/<int:id>/set-category', methods=['POST'])
|
||||
@login_required
|
||||
def set_category(id):
|
||||
"""AJAX endpoint: update only the category of a transaction."""
|
||||
txn = db.get_or_404(Transaction, id)
|
||||
data = request.get_json(silent=True) or {}
|
||||
raw = data.get('category_id')
|
||||
txn.category_id = int(raw) if raw else None
|
||||
db.session.commit()
|
||||
return jsonify({'ok': True, 'category_id': txn.category_id})
|
||||
|
||||
|
||||
@transactions_bp.route('/<int:id>/delete', methods=['POST'])
|
||||
@login_required
|
||||
def delete(id):
|
||||
|
||||
Reference in New Issue
Block a user