rairo commited on
Commit
44c69bf
·
verified ·
1 Parent(s): c19b014

Update main.py

Browse files
Files changed (1) hide show
  1. main.py +37 -0
main.py CHANGED
@@ -443,6 +443,43 @@ def admin_reset_password(uid):
443
  except Exception as e:
444
  return jsonify({'error': str(e)}), 400
445
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
446
  # ========================================
447
  # User management endpoint for profile
448
  # ========================================
 
443
  except Exception as e:
444
  return jsonify({'error': str(e)}), 400
445
 
446
+
447
+ @app.route('/api/admin/transactions/<string:transaction_id>', methods=['DELETE'])
448
+ def delete_transaction(transaction_id):
449
+ """Allow admin users to delete transactions."""
450
+ try:
451
+ verify_admin(request.headers.get('Authorization', ''))
452
+ transactions_ref = db.reference(f'transactions/{transaction_id}')
453
+ transaction_data = transactions_ref.get()
454
+
455
+ if not transaction_data:
456
+ return jsonify({'error': 'Transaction not found'}), 404
457
+
458
+ transactions_ref.delete()
459
+ return jsonify({'success': True, 'message': 'Transaction deleted successfully'})
460
+
461
+ except Exception as e:
462
+ return jsonify({'error': str(e)}), 500
463
+
464
+ @app.route('/api/admin/transactions/<string:transaction_id>', methods=['PUT'])
465
+ def edit_transaction(transaction_id):
466
+ """Allow admin users to edit transactions."""
467
+ try:
468
+ verify_admin(request.headers.get('Authorization', ''))
469
+ transactions_ref = db.reference(f'transactions/{transaction_id}')
470
+ transaction_data = transactions_ref.get()
471
+
472
+ if not transaction_data:
473
+ return jsonify({'error': 'Transaction not found'}), 404
474
+
475
+ update_data = request.get_json()
476
+ transactions_ref.update(update_data)
477
+
478
+ return jsonify({'success': True, 'updated_transaction': update_data})
479
+
480
+ except Exception as e:
481
+ return jsonify({'error': str(e)}), 500
482
+
483
  # ========================================
484
  # User management endpoint for profile
485
  # ========================================