Fix NoneType error when user has no subscription
g.subscription is explicitly set to None in load_user, so
g.get("subscription", {}) returns None (key exists), not {}.
Use (g.get(...) or {}) to coalesce None to an empty dict.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -97,7 +97,7 @@ async def index():
|
|||||||
"""Coffee analytics dashboard."""
|
"""Coffee analytics dashboard."""
|
||||||
user = g.user
|
user = g.user
|
||||||
stats = await get_user_stats(g.user["id"])
|
stats = await get_user_stats(g.user["id"])
|
||||||
plan = g.get("subscription", {}).get("plan", "free")
|
plan = (g.get("subscription") or {}).get("plan", "free")
|
||||||
|
|
||||||
# Fetch all analytics data in parallel (empty lists if DB not available)
|
# Fetch all analytics data in parallel (empty lists if DB not available)
|
||||||
if analytics._conn is not None:
|
if analytics._conn is not None:
|
||||||
@@ -144,7 +144,7 @@ async def index():
|
|||||||
async def countries():
|
async def countries():
|
||||||
"""Country comparison page."""
|
"""Country comparison page."""
|
||||||
user = g.user
|
user = g.user
|
||||||
plan = g.get("subscription", {}).get("plan", "free")
|
plan = (g.get("subscription") or {}).get("plan", "free")
|
||||||
|
|
||||||
# Get available countries for coffee
|
# Get available countries for coffee
|
||||||
all_countries = await analytics.get_top_countries(analytics.COFFEE_COMMODITY_CODE, "Production", limit=50)
|
all_countries = await analytics.get_top_countries(analytics.COFFEE_COMMODITY_CODE, "Production", limit=50)
|
||||||
|
|||||||
Reference in New Issue
Block a user