Major update spanning pricing, market data, and analytics: - Pricing: Replace single-price service fees with 5-tier pricing for same-day, prime, and emergency deliveries across create/edit/finalize - Market: Add Ticker_Price and CompanyPrice models with endpoints for live commodity prices (HO, CL, RB) and competitor price tracking - Stats: Add daily/weekly/monthly gallons endpoints with multi-year comparison and YoY totals for the stats dashboard - Delivery: Add map and history endpoints, fix finalize null-driver crash - Schema: Change fill_location from INTEGER to VARCHAR(250), add pre_load normalization for customer updates, fix admin auth check Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
27 lines
701 B
Python
Executable File
27 lines
701 B
Python
Executable File
from flask_login import current_user
|
|
from flask import abort
|
|
|
|
from functools import wraps
|
|
from app.common.responses import error_response
|
|
|
|
def login_required(f):
|
|
@wraps(f)
|
|
|
|
def decorated_function(*args, **kwargs):
|
|
if current_user.is_authenticated:
|
|
pass
|
|
else:
|
|
abort(401)
|
|
return f(*args, **kwargs)
|
|
|
|
return decorated_function
|
|
|
|
|
|
def admin_required(f):
|
|
@wraps(f)
|
|
def decorated_function(*args, **kwargs):
|
|
if not current_user.is_authenticated or (not current_user.admin_role and not current_user.admin):
|
|
return error_response("Admin access required", 403)
|
|
return f(*args, **kwargs)
|
|
return decorated_function
|