Jun 28 - Update tenant self-service signup, trial period enforcement
This commit is contained in:
+20
-11
@@ -166,23 +166,30 @@ def create_app(config_name='default'):
|
||||
"""MT-8: push billing state into every template."""
|
||||
try:
|
||||
from flask import g
|
||||
billing_warning = getattr(g, 'billing_warning', None)
|
||||
tenant = getattr(g, 'tenant', None)
|
||||
from app.utils.time_utils import now_eastern
|
||||
billing_warning = getattr(g, 'billing_warning', None)
|
||||
tenant = getattr(g, 'tenant', None)
|
||||
subscription_status = tenant.subscription_status if tenant else None
|
||||
trial_ends_at = tenant.trial_ends_at if tenant else None
|
||||
trial_ends_at = tenant.trial_ends_at if tenant else None
|
||||
trial_days_remaining = None
|
||||
if trial_ends_at is not None:
|
||||
delta = trial_ends_at - now_eastern()
|
||||
trial_days_remaining = max(0, delta.days)
|
||||
return {
|
||||
'billing_enabled': app.config.get('BILLING_ENABLED', False),
|
||||
'billing_warning': billing_warning,
|
||||
'subscription_status': subscription_status,
|
||||
'trial_ends_at': trial_ends_at,
|
||||
'billing_enabled': app.config.get('BILLING_ENABLED', False),
|
||||
'billing_warning': billing_warning,
|
||||
'subscription_status': subscription_status,
|
||||
'trial_ends_at': trial_ends_at,
|
||||
'trial_days_remaining': trial_days_remaining,
|
||||
}
|
||||
except Exception:
|
||||
pass
|
||||
return {
|
||||
'billing_enabled': False,
|
||||
'billing_warning': None,
|
||||
'subscription_status': None,
|
||||
'trial_ends_at': None,
|
||||
'billing_enabled': False,
|
||||
'billing_warning': None,
|
||||
'subscription_status': None,
|
||||
'trial_ends_at': None,
|
||||
'trial_days_remaining': None,
|
||||
}
|
||||
|
||||
os.makedirs(app.config['UPLOAD_FOLDER'], exist_ok=True)
|
||||
@@ -198,6 +205,7 @@ def create_app(config_name='default'):
|
||||
from app.routes import broadcast # Admin broadcast messages
|
||||
from app.routes import devices # Admin device management
|
||||
from app.routes import tenant_settings # MT-7 — tenant self-service
|
||||
from app.routes import signup # MT-8+ — public self-service signup
|
||||
from app.billing import bp as billing_bp # MT-8 — Stripe billing
|
||||
|
||||
app.register_blueprint(auth.bp)
|
||||
@@ -216,6 +224,7 @@ def create_app(config_name='default'):
|
||||
app.register_blueprint(broadcast.bp)
|
||||
app.register_blueprint(devices.bp)
|
||||
app.register_blueprint(tenant_settings.bp)
|
||||
app.register_blueprint(signup.bp)
|
||||
# Billing blueprint is CSRF-exempt: /billing/webhook receives raw POST from
|
||||
# Stripe and cannot carry a CSRF token. Subscribe/portal are GET redirects
|
||||
# which Flask-WTF does not protect anyway (CSRF only applies to unsafe methods).
|
||||
|
||||
Reference in New Issue
Block a user