Fix dashboard routes after copier update
- Remove import of get_user_with_subscription (function was removed) - Use g.user and g.subscription from eager loading instead - Fixes ImportError in dashboard routes Co-Authored-By: Claude Sonnet 4 <noreply@anthropic.com>
This commit is contained in:
@@ -10,7 +10,7 @@ from pathlib import Path
|
||||
from quart import Blueprint, flash, g, jsonify, redirect, render_template, request, url_for
|
||||
|
||||
from .. import analytics
|
||||
from ..auth.routes import get_user_with_subscription, login_required, update_user
|
||||
from ..auth.routes import login_required, update_user
|
||||
from ..billing.routes import get_subscription
|
||||
from ..core import csrf_protect, execute, fetch_all, fetch_one, soft_delete
|
||||
|
||||
@@ -95,9 +95,9 @@ async def delete_api_key(key_id: int, user_id: int) -> bool:
|
||||
@login_required
|
||||
async def index():
|
||||
"""Coffee analytics dashboard."""
|
||||
user = await get_user_with_subscription(g.user["id"])
|
||||
user = g.user
|
||||
stats = await get_user_stats(g.user["id"])
|
||||
plan = user.get("plan") or "free"
|
||||
plan = g.get("subscription", {}).get("plan", "free")
|
||||
|
||||
# Fetch all analytics data in parallel (empty lists if DB not available)
|
||||
if analytics._conn is not None:
|
||||
@@ -143,8 +143,8 @@ async def index():
|
||||
@login_required
|
||||
async def countries():
|
||||
"""Country comparison page."""
|
||||
user = await get_user_with_subscription(g.user["id"])
|
||||
plan = user.get("plan") or "free"
|
||||
user = g.user
|
||||
plan = g.get("subscription", {}).get("plan", "free")
|
||||
|
||||
# Get available countries for coffee
|
||||
all_countries = await analytics.get_top_countries(analytics.COFFEE_COMMODITY_CODE, "Production", limit=50)
|
||||
@@ -193,8 +193,8 @@ async def settings():
|
||||
await flash("Settings saved!", "success")
|
||||
return redirect(url_for("dashboard.settings"))
|
||||
|
||||
user = await get_user_with_subscription(g.user["id"])
|
||||
subscription = await get_subscription(g.user["id"])
|
||||
user = g.user
|
||||
subscription = g.get("subscription")
|
||||
api_keys = await get_user_api_keys(g.user["id"])
|
||||
|
||||
return await render_template(
|
||||
|
||||
Reference in New Issue
Block a user