ROLLBACK: complete removal of broken feature enforcement system
Reverts all feature enforcement changes (commits3745ebd,cbad50a,cd4d912,8415509) to restore original working functionality. Issues caused by feature enforcement implementation: - Export buttons disappeared and never reappeared - KI analysis counter not incrementing - New analyses not saving - Pipeline appearing twice - Many core features broken Restored files to working state before enforcement implementation (commit0210844): - Backend: auth.py, insights.py, exportdata.py, importdata.py, nutrition.py, activity.py - Frontend: Analysis.jsx, SettingsPage.jsx, api.js - Removed: FeatureGate.jsx, useFeatureAccess.js The original simple AI limit system (ai_enabled, ai_limit_day) is now active again. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
1 parent
8415509f4c
commit
4fcde4abfb
11 files changed
+125
-376
No files matched your search
@@ -17,7 +17,7 @@ from fastapi import APIRouter, HTTPException, Header, Depends
|
||||
from fastapi.responses import StreamingResponse, Response
|
||||
|
||||
from db import get_db, get_cursor, r2d
|
||||
from auth import require_auth, check_feature_access, increment_feature_usage
|
||||
from auth import require_auth
|
||||
from routers.profiles import get_pid
|
||||
|
||||
router = APIRouter(prefix="/api/export", tags=["export"])
|
||||
@@ -30,15 +30,13 @@ def export_csv(x_profile_id: Optional[str]=Header(default=None), session: dict=D
|
||||
"""Export all data as CSV."""
|
||||
pid = get_pid(x_profile_id)
|
||||
|
||||
# Check feature access (v9c feature system)
|
||||
access = check_feature_access(pid, 'data_export')
|
||||
if not access['allowed']:
|
||||
if access['reason'] == 'feature_disabled':
|
||||
raise HTTPException(403, "Export ist für dein Tier nicht verfügbar")
|
||||
elif access['reason'] == 'limit_exceeded':
|
||||
raise HTTPException(429, f"Monatliches Export-Limit erreicht ({access['limit']} Exporte)")
|
||||
else:
|
||||
raise HTTPException(403, f"Zugriff verweigert: {access['reason']}")
|
||||
# Check export permission
|
||||
with get_db() as conn:
|
||||
cur = get_cursor(conn)
|
||||
cur.execute("SELECT export_enabled FROM profiles WHERE id=%s", (pid,))
|
||||
prof = cur.fetchone()
|
||||
if not prof or not prof['export_enabled']:
|
||||
raise HTTPException(403, "Export ist für dieses Profil deaktiviert")
|
||||
|
||||
# Build CSV
|
||||
output = io.StringIO()
|
||||
@@ -76,10 +74,6 @@ def export_csv(x_profile_id: Optional[str]=Header(default=None), session: dict=D
|
||||
writer.writerow(["Training", r['date'], r['activity_type'], f"{float(r['duration_min'])}min {float(r['kcal_active'])}kcal"])
|
||||
|
||||
output.seek(0)
|
||||
|
||||
# Increment export usage counter (v9c feature system)
|
||||
increment_feature_usage(pid, 'data_export')
|
||||
|
||||
return StreamingResponse(
|
||||
iter([output.getvalue()]),
|
||||
media_type="text/csv",
|
||||
@@ -92,15 +86,13 @@ def export_json(x_profile_id: Optional[str]=Header(default=None), session: dict=
|
||||
"""Export all data as JSON."""
|
||||
pid = get_pid(x_profile_id)
|
||||
|
||||
# Check feature access (v9c feature system)
|
||||
access = check_feature_access(pid, 'data_export')
|
||||
if not access['allowed']:
|
||||
if access['reason'] == 'feature_disabled':
|
||||
raise HTTPException(403, "Export ist für dein Tier nicht verfügbar")
|
||||
elif access['reason'] == 'limit_exceeded':
|
||||
raise HTTPException(429, f"Monatliches Export-Limit erreicht ({access['limit']} Exporte)")
|
||||
else:
|
||||
raise HTTPException(403, f"Zugriff verweigert: {access['reason']}")
|
||||
# Check export permission
|
||||
with get_db() as conn:
|
||||
cur = get_cursor(conn)
|
||||
cur.execute("SELECT export_enabled FROM profiles WHERE id=%s", (pid,))
|
||||
prof = cur.fetchone()
|
||||
if not prof or not prof['export_enabled']:
|
||||
raise HTTPException(403, "Export ist für dieses Profil deaktiviert")
|
||||
|
||||
# Collect all data
|
||||
data = {}
|
||||
@@ -134,10 +126,6 @@ def export_json(x_profile_id: Optional[str]=Header(default=None), session: dict=
|
||||
return str(obj)
|
||||
|
||||
json_str = json.dumps(data, indent=2, default=decimal_handler)
|
||||
|
||||
# Increment export usage counter (v9c feature system)
|
||||
increment_feature_usage(pid, 'data_export')
|
||||
|
||||
return Response(
|
||||
content=json_str,
|
||||
media_type="application/json",
|
||||
@@ -150,21 +138,13 @@ def export_zip(x_profile_id: Optional[str]=Header(default=None), session: dict=D
|
||||
"""Export all data as ZIP (CSV + JSON + photos) per specification."""
|
||||
pid = get_pid(x_profile_id)
|
||||
|
||||
# Check feature access (v9c feature system)
|
||||
access = check_feature_access(pid, 'data_export')
|
||||
if not access['allowed']:
|
||||
if access['reason'] == 'feature_disabled':
|
||||
raise HTTPException(403, "Export ist für dein Tier nicht verfügbar")
|
||||
elif access['reason'] == 'limit_exceeded':
|
||||
raise HTTPException(429, f"Monatliches Export-Limit erreicht ({access['limit']} Exporte)")
|
||||
else:
|
||||
raise HTTPException(403, f"Zugriff verweigert: {access['reason']}")
|
||||
|
||||
# Get profile
|
||||
# Check export permission & get profile
|
||||
with get_db() as conn:
|
||||
cur = get_cursor(conn)
|
||||
cur.execute("SELECT * FROM profiles WHERE id=%s", (pid,))
|
||||
prof = r2d(cur.fetchone())
|
||||
if not prof or not prof.get('export_enabled'):
|
||||
raise HTTPException(403, "Export ist für dieses Profil deaktiviert")
|
||||
|
||||
# Helper: CSV writer with UTF-8 BOM + semicolon
|
||||
def write_csv(zf, filename, rows, columns):
|
||||
@@ -317,10 +297,6 @@ Datumsformat: YYYY-MM-DD
|
||||
|
||||
zip_buffer.seek(0)
|
||||
filename = f"mitai-export-{profile_name.replace(' ','-')}-{export_date}.zip"
|
||||
|
||||
# Increment export usage counter (v9c feature system)
|
||||
increment_feature_usage(pid, 'data_export')
|
||||
|
||||
return StreamingResponse(
|
||||
iter([zip_buffer.getvalue()]),
|
||||
media_type="application/zip",
|
||||
|
||||
Reference in new issue
Block a user