From a6c25cf0f0d42347abb11b4bfe0b5f50a0ca39d7 Mon Sep 17 00:00:00 2001 From: rene Date: Wed, 6 May 2026 19:06:37 +0200 Subject: [PATCH] =?UTF-8?q?Feature:=20Feature-Gating=20nach=20Tier=20?= =?UTF-8?q?=E2=80=94=20Pro-Seiten/Chips=20f=C3=BCr=20Standard=20versteckt,?= =?UTF-8?q?=20Admin=20immer=20alles=20(SW=20by-v737)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/main.py | 2 +- backend/static/index.html | 2 +- backend/static/js/app.js | 55 ++++++++++++++++++++++++----- backend/static/js/pages/settings.js | 7 ++++ backend/static/js/worlds.js | 26 ++++++++++---- backend/static/sw.js | 2 +- 6 files changed, 76 insertions(+), 18 deletions(-) diff --git a/backend/main.py b/backend/main.py index 9c00a1b..eb694a0 100644 --- a/backend/main.py +++ b/backend/main.py @@ -327,7 +327,7 @@ MEDIA_DIR = os.getenv("MEDIA_DIR", "/data/media") os.makedirs(MEDIA_DIR, exist_ok=True) app.mount("/media", StaticFiles(directory=MEDIA_DIR), name="media") -APP_VER = "736" # muss mit APP_VER in app.js übereinstimmen +APP_VER = "737" # muss mit APP_VER in app.js übereinstimmen @app.get("/api/version") async def app_version(): diff --git a/backend/static/index.html b/backend/static/index.html index 5038216..cc3c9db 100644 --- a/backend/static/index.html +++ b/backend/static/index.html @@ -578,7 +578,7 @@ - + diff --git a/backend/static/js/app.js b/backend/static/js/app.js index a8b5cf3..4d15a48 100644 --- a/backend/static/js/app.js +++ b/backend/static/js/app.js @@ -3,7 +3,7 @@ Router, State-Management, Navigation, Initialisierung. ============================================================ */ -const APP_VER = '736'; // ← bei jedem Deploy mit Frontend-Änderungen erhöhen +const APP_VER = '737'; // ← bei jedem Deploy mit Frontend-Änderungen erhöhen const APP_VERSION = '1.4.0'; // ← semantische Version, wird bei make release gesetzt const IS_STAGING = location.hostname === 'staging.banyaro.app'; @@ -43,7 +43,7 @@ const App = (() => { routes: { title: 'Routen', module: null }, events: { title: 'Events', module: null }, poison: { title: 'Giftköder-Alarm', module: null }, - walks: { title: 'Gassi-Treffen', module: null, requiresAuth: true }, + walks: { title: 'Gassi-Treffen', module: null, requiresAuth: true, requiresPro: true }, sitting: { title: 'Sitting', module: null, requiresAuth: true }, forum: { title: 'Forum', module: null }, wiki: { title: 'Wiki', module: null }, @@ -51,12 +51,12 @@ const App = (() => { movies: { title: 'Filme', module: null }, trainingsplaene: { title: 'Trainingspläne', module: null }, uebungen: { title: 'Übungsbibliothek', module: null }, - notes: { title: 'Notizblock', module: null, requiresAuth: true }, + notes: { title: 'Notizblock', module: null, requiresAuth: true, requiresPro: true }, 'erste-hilfe': { title: 'Erste Hilfe', module: null }, settings: { title: 'Einstellungen', module: null }, lost: { title: 'Verlorener Hund', module: null }, - friends: { title: 'Freunde', module: null, requiresAuth: true }, - chat: { title: 'Nachrichten', module: null, requiresAuth: true }, + friends: { title: 'Freunde', module: null, requiresAuth: true, requiresPro: true }, + chat: { title: 'Nachrichten', module: null, requiresAuth: true, requiresPro: true }, social: { title: 'Social Media', module: null, requiresAuth: true }, admin: { title: 'Admin', module: null, requiresAuth: true }, moderation: { title: 'Moderation', module: null, requiresAuth: true }, @@ -74,14 +74,25 @@ const App = (() => { expenses: { title: 'Ausgaben', module: null, requiresAuth: true }, recalls: { title: 'Rückrufe', module: null }, adoption: { title: 'Adoption', module: null }, - playdate: { title: 'Playdate', module: null, requiresAuth: true }, + playdate: { title: 'Playdate', module: null, requiresAuth: true, requiresPro: true }, wetter: { title: 'Wetter', module: null }, - ernaehrung: { title: 'Ernährung', module: null, requiresAuth: true }, + ernaehrung: { title: 'Ernährung', module: null, requiresAuth: true, requiresPro: true }, personality: { title: 'Persönlichkeitstest', module: null }, - reise: { title: 'Reise mit Hund', module: null }, + reise: { title: 'Reise mit Hund', module: null, requiresPro: true }, hilfe: { title: 'Hilfe & FAQ', module: null }, }; + // ---------------------------------------------------------- + // TIER-CHECK — Frontend-Pendant zu has_pro_access() in auth.py + // ---------------------------------------------------------- + function _hasPro(user) { + if (!user) return false; + if (user.rolle === 'admin' || user.rolle === 'moderator') return true; + if (user.is_moderator || user.is_social_media) return true; + const t = user.subscription_tier || 'standard'; + return ['pro','breeder','pro_test','breeder_test'].includes(t); + } + // ---------------------------------------------------------- // AUTH GUARD — Login-Gate Texte pro Seite // ---------------------------------------------------------- @@ -142,6 +153,34 @@ const App = (() => { return; } + // Pro-Guard — nur wenn User eingeloggt aber kein Pro-Zugang + if (page.requiresPro && state.user && !_hasPro(state.user)) { + const container = document.querySelector(`#page-${pageId} .page-body`); + if (container) { + container.innerHTML = ` +
+
+

Ban Yaro Pro

+

+ Dieses Feature ist Teil von Ban Yaro Pro — verfügbar wenn wir die nächste Stufe zünden.
+ Du wirst benachrichtigt wenn es soweit ist. +

+
+
Ban Yaro Pro enthält:
+
    +
  • Mehrere Hunde verwalten
  • +
  • KI-Trainer für personalisiertes Training
  • +
  • Direktnachrichten & Freunde
  • +
  • Gassi-Treffen, Playdate, Ernährung, Reise
  • +
  • Notizblock
  • +
+
+
`; + } + return; + } + if (page.module) { const hasParams = params && Object.keys(params).length > 0; if (hasParams) { diff --git a/backend/static/js/pages/settings.js b/backend/static/js/pages/settings.js index beb8ae0..743004e 100644 --- a/backend/static/js/pages/settings.js +++ b/backend/static/js/pages/settings.js @@ -276,6 +276,13 @@ window.Page_settings = (() => { Hilfe & FAQ + ${!_appState.user?.subscription_tier || _appState.user.subscription_tier === 'standard' || _appState.user.subscription_tier === 'standard_test' ? ` +
+ ⭐ Ban Yaro Pro kommt bald — mehr Features, mehrere Hunde. +
+ ` : ''}