Spaces:
Running
Running
Update main.py
Browse files
main.py
CHANGED
|
@@ -555,37 +555,6 @@ def admin_action_on_listing(listing_id):
|
|
| 555 |
return jsonify({'success': True, 'message': f"Listing {listing_id} {new_status}."}), 200
|
| 556 |
except Exception as e: return handle_route_errors(e, uid_context=reviewer_uid)
|
| 557 |
|
| 558 |
-
# --- Admin Endpoint to Get All Listings ---
|
| 559 |
-
@app.route('/api/admin/listings/all', methods=['GET'])
|
| 560 |
-
def admin_get_all_listings():
|
| 561 |
-
auth_header = request.headers.get('Authorization')
|
| 562 |
-
admin_uid = None # For error logging context
|
| 563 |
-
try:
|
| 564 |
-
admin_uid = verify_admin(auth_header) # Ensures only an admin can access
|
| 565 |
-
|
| 566 |
-
if not FIREBASE_INITIALIZED:
|
| 567 |
-
# This check might be redundant if verify_admin already checks and raises ConnectionError
|
| 568 |
-
logger.error("admin_get_all_listings: Firebase not initialized.")
|
| 569 |
-
return jsonify({'error': 'Server configuration error: Firebase not ready.'}), 503
|
| 570 |
-
|
| 571 |
-
listings_ref = db.reference('listings', app=db_app)
|
| 572 |
-
all_listings = listings_ref.get() # This will be None if the 'listings' node doesn't exist
|
| 573 |
-
|
| 574 |
-
# If all_listings is None (node doesn't exist), return an empty object,
|
| 575 |
-
# otherwise return the fetched listings.
|
| 576 |
-
# The frontend should be prepared to handle an empty object or null.
|
| 577 |
-
response_data = all_listings if all_listings is not None else {}
|
| 578 |
-
|
| 579 |
-
# Note: For very large numbers of listings, consider implementing pagination.
|
| 580 |
-
# This current implementation returns all listings at once.
|
| 581 |
-
|
| 582 |
-
return jsonify(response_data), 200
|
| 583 |
-
|
| 584 |
-
except Exception as e:
|
| 585 |
-
# This will catch errors from verify_admin (like PermissionError, ValueError, ConnectionError)
|
| 586 |
-
# and also errors from Firebase DB operations (like firebase_exceptions.FirebaseError)
|
| 587 |
-
# or any other unexpected exceptions.
|
| 588 |
-
return handle_route_errors(e, uid_context=admin_uid)
|
| 589 |
|
| 590 |
# --- Deal Management (MODIFIED SECTION) ---
|
| 591 |
@app.route('/api/deals/propose', methods=['POST'])
|
|
|
|
| 555 |
return jsonify({'success': True, 'message': f"Listing {listing_id} {new_status}."}), 200
|
| 556 |
except Exception as e: return handle_route_errors(e, uid_context=reviewer_uid)
|
| 557 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 558 |
|
| 559 |
# --- Deal Management (MODIFIED SECTION) ---
|
| 560 |
@app.route('/api/deals/propose', methods=['POST'])
|