July 3rd - Update landing page

This commit is contained in:
2026-07-03 15:38:31 -04:00
parent 4c275fc0e5
commit 4b6401be43
12 changed files with 414 additions and 19 deletions
+2
View File
@@ -206,6 +206,7 @@ def create_app(config_name='default'):
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.routes import landing # Public apex marketing/landing page
from app.billing import bp as billing_bp # MT-8 — Stripe billing
app.register_blueprint(auth.bp)
@@ -225,6 +226,7 @@ def create_app(config_name='default'):
app.register_blueprint(devices.bp)
app.register_blueprint(tenant_settings.bp)
app.register_blueprint(signup.bp)
app.register_blueprint(landing.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).
+1 -1
View File
@@ -36,7 +36,7 @@ _PLAIN_BODIES = {
'welcome': (
"Welcome to Janitorial QC!\n\n"
"Your workspace is ready at:\n {login_url}\n\n"
"Trial: {trial_days} days (expires {trial_ends_at})\n\n— The JQC Team"
"{trial_note}\n\nPlan: {plan_name}\n\n— The JQC Team"
),
'payment_failed': (
"We were unable to process your most recent payment for your JQC subscription.\n\n"
+92
View File
@@ -0,0 +1,92 @@
"""
app/routes/landing.py
----------------------
Public marketing / landing page served at the apex domain (e.g. jqc.app).
Canonical path is GET /welcome (always reachable, tenant-exempt) so the page
can be previewed directly in any environment. In multi-tenant production the
tenant middleware delegates the apex host's `/` to this view (see
app/tenancy/middleware.py) — the apex is NOT a tenant, so `/` cannot be owned
by the login-gated dashboard route.
The page introduces the product, lists plans (read live from the control DB
when available, with a static fallback), and funnels visitors to the existing
public self-service signup at /signup (plan picker, Free selectable/default).
"""
import logging
from flask import Blueprint, render_template, current_app, url_for
bp = Blueprint('landing', __name__)
logger = logging.getLogger(__name__)
# Static fallback mirrors control/seed.py PLAN_DEFS so the page still renders if
# the control DB is unreachable or multi-tenancy is disabled (dev preview).
_FALLBACK_PLANS = [
dict(code='free', name='Free', price_label='$0',
max_users=3, max_facilities=2, max_inspections_month=50, max_issues_month=50,
allow_mobile_api=False, allow_scheduled_reports=False,
allow_branding=False, allow_custom_domain=False),
dict(code='starter', name='Starter', price_label='Contact us',
max_users=15, max_facilities=10, max_inspections_month=500, max_issues_month=500,
allow_mobile_api=True, allow_scheduled_reports=False,
allow_branding=False, allow_custom_domain=False),
dict(code='pro', name='Pro', price_label='Contact us',
max_users=50, max_facilities=50, max_inspections_month=5000, max_issues_month=5000,
allow_mobile_api=True, allow_scheduled_reports=True,
allow_branding=True, allow_custom_domain=True),
dict(code='enterprise', name='Enterprise', price_label='Contact us',
max_users=None, max_facilities=None, max_inspections_month=None, max_issues_month=None,
allow_mobile_api=True, allow_scheduled_reports=True,
allow_branding=True, allow_custom_domain=True),
]
def _plan_dict(p):
"""Flatten a control Plan ORM row into a template-safe dict (read inside the
open session so no lazy attribute access happens after it closes)."""
if p.price_cents == 0:
price_label = '$0'
elif p.price_cents:
price_label = f'${p.price_cents // 100}/mo'
else:
price_label = 'Contact us'
return dict(
code=p.code, name=p.name, price_label=price_label,
max_users=p.max_users, max_facilities=p.max_facilities,
max_inspections_month=p.max_inspections_month,
max_issues_month=p.max_issues_month,
allow_mobile_api=p.allow_mobile_api,
allow_scheduled_reports=p.allow_scheduled_reports,
allow_branding=p.allow_branding,
allow_custom_domain=p.allow_custom_domain,
)
def _load_plans():
"""Return plan dicts from the control DB, ordered cheapest-first, with a
static fallback so the landing page never fails to render."""
try:
from control.base import control_session
from control.models import Plan
with control_session() as s:
plans = (s.query(Plan)
.order_by(Plan.price_cents.nullslast(), Plan.id)
.all())
if plans:
return [_plan_dict(p) for p in plans]
except Exception as exc:
logger.debug('LANDING | plan_load_failed | err=%s', exc)
return _FALLBACK_PLANS
@bp.route('/welcome')
def index():
return render_template(
'landing/index.html',
plans=_load_plans(),
signup_url=url_for('signup.index'),
base_domain=current_app.config.get('TENANT_BASE_DOMAIN', 'jqc.app'),
)
+20 -3
View File
@@ -27,16 +27,28 @@ logger = logging.getLogger(__name__)
def _send_welcome_email(to_email, login_url, tenant_name, plan_code, trial_ends_at):
"""Fire a welcome email in a background thread — never blocks the request."""
"""Fire a welcome email in a background thread — never blocks the request.
The wording adapts to the plan: the Free plan has no trial/expiry, paid
plans start a 14-day trial. `trial_note` carries the plan-appropriate line
and `trial_ends_at` is blank for Free so the template hides the trial row.
"""
try:
from app.billing.emails import send_billing_email
is_free = (plan_code == 'free')
ends_str = (trial_ends_at.strftime('%B %d, %Y')
if hasattr(trial_ends_at, 'strftime') else str(trial_ends_at or ''))
if is_free:
trial_note = "You're on the Free plan — no credit card, no expiry."
ends_str = ''
else:
trial_note = f'Your 14-day free trial runs through {ends_str}.'
send_billing_email(to_email, 'welcome', {
'tenant_name': tenant_name,
'login_url': login_url,
'trial_days': 14,
'trial_days': 0 if is_free else 14,
'trial_ends_at': ends_str,
'trial_note': trial_note,
'plan_name': plan_code.title(),
})
except Exception as exc:
@@ -115,6 +127,11 @@ def index():
plan_code = form.plan.data
password = form.password.data
# Free plan is free forever — no trial, no expiry. Paid plans start a
# 14-day trial. trial_days=0 makes create_tenant provision the tenant as
# 'active' (see control/provision.py) so the billing gate never blocks it.
trial_days = 0 if plan_code == 'free' else 14
try:
from control.provision import create_tenant
info = create_tenant(
@@ -124,7 +141,7 @@ def index():
admin_email=email,
admin_full_name=full_name,
admin_password=password,
trial_days=14,
trial_days=trial_days,
)
except ValueError as exc:
flash(str(exc), 'danger')
+2 -2
View File
@@ -2,14 +2,14 @@
{% set subject = "Welcome to JQC — your workspace is ready" %}
{% block body %}
<h2 style="margin:0 0 8px;font-size:1.2rem;color:#111827;">Welcome to Janitorial QC!</h2>
<p style="margin:0 0 20px;color:#6b7280;font-size:.9rem;">Your workspace <strong>{{ tenant_name }}</strong> is ready. You're on a free trial — no credit card needed until {{ trial_ends_at }}.</p>
<p style="margin:0 0 20px;color:#6b7280;font-size:.9rem;">Your workspace <strong>{{ tenant_name }}</strong> is ready. {{ trial_note }}</p>
<table width="100%" cellpadding="12" cellspacing="0" style="background:#f0fdf4;border-radius:6px;margin-bottom:24px;">
<tr>
<td>
<p style="margin:0;font-size:.9rem;color:#15803d;line-height:1.6;">
<strong>&#10003; Workspace:</strong> <a href="{{ login_url }}" style="color:#15803d;">{{ login_url }}</a><br>
<strong>&#10003; Free trial:</strong> {{ trial_days }} days (expires {{ trial_ends_at }})<br>
{% if trial_ends_at %}<strong>&#10003; Free trial:</strong> {{ trial_days }} days (expires {{ trial_ends_at }})<br>{% endif %}
<strong>&#10003; Plan:</strong> {{ plan_name }}
</p>
</td>
+175
View File
@@ -0,0 +1,175 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Janitorial QC — Quality control for janitorial contracts</title>
<meta name="description" content="Run inspections, track issues with SLA enforcement, and share live reports with your customers. Start free.">
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css" rel="stylesheet">
<style>
:root { --jqc-primary:#1a56db; --jqc-accent:#16a34a; }
body { font-family:-apple-system,"Segoe UI",Roboto,Helvetica,Arial,sans-serif; color:#1f2937; }
.navbar-brand { font-weight:700; letter-spacing:-.02em; }
.hero { background:linear-gradient(160deg,#eff4ff 0%,#f8fafc 60%,#f0fdf4 100%); padding:5rem 0 4.5rem; }
.hero h1 { font-size:2.6rem; font-weight:800; letter-spacing:-.03em; line-height:1.1; }
.hero .lead { color:#4b5563; font-size:1.15rem; max-width:34rem; }
.btn-jqc { background:var(--jqc-primary); border-color:var(--jqc-primary); color:#fff; }
.btn-jqc:hover { background:#1544b0; border-color:#1544b0; color:#fff; }
.feature-icon { width:44px;height:44px;border-radius:10px;display:flex;align-items:center;justify-content:center;
background:#eff4ff;color:var(--jqc-primary);font-size:1.35rem;font-weight:700; }
.section { padding:4.5rem 0; }
.price-card { border:1px solid #e5e7eb;border-radius:14px;height:100%; transition:box-shadow .15s,transform .15s; }
.price-card:hover { box-shadow:0 10px 30px rgba(0,0,0,.07); transform:translateY(-2px); }
.price-card.popular { border-color:var(--jqc-primary); box-shadow:0 10px 30px rgba(26,86,219,.12); }
.price-amt { font-size:2rem;font-weight:800;letter-spacing:-.02em; }
.plan-feat { font-size:.9rem;color:#374151; }
.plan-feat .yes { color:var(--jqc-accent);font-weight:700; }
.plan-feat .no { color:#cbd5e1; }
footer { background:#0f172a;color:#94a3b8;padding:2.5rem 0; }
footer a { color:#cbd5e1;text-decoration:none; }
</style>
</head>
<body>
<!-- Nav -->
<nav class="navbar navbar-expand-md navbar-light bg-white border-bottom sticky-top">
<div class="container">
<a class="navbar-brand text-primary" href="#top">Janitorial<span style="color:var(--jqc-accent)">QC</span></a>
<div class="ms-auto d-flex align-items-center gap-2">
<a class="nav-link d-none d-sm-inline text-secondary" href="#features">Features</a>
<a class="nav-link d-none d-sm-inline text-secondary" href="#pricing">Pricing</a>
<a class="btn btn-jqc btn-sm px-3" href="{{ signup_url }}">Start free</a>
</div>
</div>
</nav>
<!-- Hero -->
<header class="hero" id="top">
<div class="container">
<div class="row align-items-center g-5">
<div class="col-lg-7">
<span class="badge rounded-pill text-bg-success-subtle text-success mb-3">No credit card required</span>
<h1 class="mb-3">Quality control for janitorial contracts.</h1>
<p class="lead mb-4">
Run structured inspections, track issues with automatic SLA enforcement,
and give your customers a live window into every facility — all in one place.
</p>
<div class="d-flex flex-wrap gap-2">
<a class="btn btn-jqc btn-lg px-4" href="{{ signup_url }}">Register free</a>
<a class="btn btn-outline-secondary btn-lg px-4" href="#pricing">See plans</a>
</div>
</div>
<div class="col-lg-5">
<div class="bg-white rounded-4 shadow-sm p-4 border">
<div class="d-flex justify-content-between align-items-center mb-3">
<strong>Facility scorecard</strong>
<span class="badge text-bg-success">96%</span>
</div>
<div class="progress mb-2" role="progressbar" aria-label="score"><div class="progress-bar bg-success" style="width:96%"></div></div>
<small class="text-muted">Restrooms</small>
<div class="progress mb-2 mt-1"><div class="progress-bar bg-success" style="width:92%"></div></div>
<small class="text-muted">Lobby &amp; entrances</small>
<div class="progress mb-2 mt-1"><div class="progress-bar" style="width:78%;background:#f59e0b"></div></div>
<small class="text-muted">Open issues</small>
<div class="d-flex gap-2 mt-2">
<span class="badge text-bg-danger">1 critical</span>
<span class="badge text-bg-warning">2 high</span>
<span class="badge text-bg-secondary">3 open</span>
</div>
</div>
</div>
</div>
</div>
</header>
<!-- Features -->
<section class="section" id="features">
<div class="container">
<div class="text-center mb-5">
<h2 class="fw-bold">Everything you need to prove clean.</h2>
<p class="text-muted">From the inspector's tablet to the customer's inbox.</p>
</div>
<div class="row g-4">
<div class="col-md-6 col-lg-3">
<div class="feature-icon mb-3">&#10003;</div>
<h5 class="fw-semibold">Custom inspections</h5>
<p class="text-muted small mb-0">Build templates with a drag-and-drop form editor. Score areas, attach photos, and capture GPS at submit time.</p>
</div>
<div class="col-md-6 col-lg-3">
<div class="feature-icon mb-3">&#9200;</div>
<h5 class="fw-semibold">Issues with SLA</h5>
<p class="text-muted small mb-0">Flag problems by severity. The SLA engine escalates automatically and alerts the right people before deadlines slip.</p>
</div>
<div class="col-md-6 col-lg-3">
<div class="feature-icon mb-3">&#128202;</div>
<h5 class="fw-semibold">Live reports</h5>
<p class="text-muted small mb-0">Score trends, aging, SLA compliance, and per-facility PDF summaries — on demand or on a schedule.</p>
</div>
<div class="col-md-6 col-lg-3">
<div class="feature-icon mb-3">&#128241;</div>
<h5 class="fw-semibold">Offline iPad app</h5>
<p class="text-muted small mb-0">Inspectors work anywhere. Records sync automatically when a connection returns — no lost data in the field.</p>
</div>
</div>
</div>
</section>
<!-- Pricing -->
<section class="section bg-light" id="pricing">
<div class="container">
<div class="text-center mb-5">
<h2 class="fw-bold">Simple plans that grow with you.</h2>
<p class="text-muted">Start on the Free plan — upgrade any time.</p>
</div>
<div class="row g-4 align-items-stretch">
{% for p in plans %}
<div class="col-md-6 col-lg-3">
<div class="price-card p-4 {% if p.code == 'pro' %}popular{% endif %}">
{% if p.code == 'pro' %}<span class="badge text-bg-primary mb-2">Most popular</span>{% endif %}
<h5 class="fw-bold mb-1">{{ p.name }}</h5>
<div class="price-amt mb-3">{{ p.price_label }}</div>
<ul class="list-unstyled plan-feat mb-4">
<li class="mb-2"><span class="yes">&#10003;</span> {{ p.max_users or 'Unlimited' }} users</li>
<li class="mb-2"><span class="yes">&#10003;</span> {{ p.max_facilities or 'Unlimited' }} facilities</li>
<li class="mb-2"><span class="yes">&#10003;</span> {{ p.max_inspections_month or 'Unlimited' }} inspections/mo</li>
<li class="mb-2">{% if p.allow_mobile_api %}<span class="yes">&#10003;</span>{% else %}<span class="no">&#10007;</span>{% endif %} Mobile iPad app</li>
<li class="mb-2">{% if p.allow_scheduled_reports %}<span class="yes">&#10003;</span>{% else %}<span class="no">&#10007;</span>{% endif %} Scheduled reports</li>
<li class="mb-2">{% if p.allow_branding %}<span class="yes">&#10003;</span>{% else %}<span class="no">&#10007;</span>{% endif %} Custom branding</li>
<li class="mb-2">{% if p.allow_custom_domain %}<span class="yes">&#10003;</span>{% else %}<span class="no">&#10007;</span>{% endif %} Custom domain</li>
</ul>
<a href="{{ signup_url }}" class="btn w-100 {% if p.code == 'pro' %}btn-jqc{% else %}btn-outline-secondary{% endif %}">
{% if p.code == 'free' %}Get started{% else %}Choose {{ p.name }}{% endif %}
</a>
</div>
</div>
{% endfor %}
</div>
<p class="text-center text-muted small mt-4 mb-0">
Every workspace gets its own secure database and a <strong>your-name.{{ base_domain }}</strong> address.
</p>
</div>
</section>
<!-- CTA -->
<section class="section text-center">
<div class="container">
<h2 class="fw-bold mb-3">Ready to see cleaner results?</h2>
<p class="text-muted mb-4">Set up your workspace in under two minutes.</p>
<a class="btn btn-jqc btn-lg px-5" href="{{ signup_url }}">Register for free</a>
</div>
</section>
<footer>
<div class="container d-flex flex-column flex-md-row justify-content-between align-items-center gap-2">
<span>&copy; Janitorial QC</span>
<span class="d-flex gap-3">
<a href="#features">Features</a>
<a href="#pricing">Pricing</a>
<a href="{{ signup_url }}">Register</a>
</span>
</div>
</footer>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/js/bootstrap.bundle.min.js"></script>
</body>
</html>
+17 -1
View File
@@ -57,6 +57,8 @@ def _is_exempt(path):
return True
if path.startswith('/signup'):
return True # public self-service signup has no tenant context
if path.startswith('/welcome'):
return True # public marketing/landing page has no tenant context
if path.startswith('/notifications/trial-reminders'):
return True # cross-tenant cron — iterates all tenants from control DB
if path.startswith('/notifications/dunning-reminders'):
@@ -74,6 +76,7 @@ def init_tenancy(app):
g.tenant = None
g.tenant_engine = None
g.billing_warning = None # MT-8: set to 'past_due' by _billing_gate when needed
g.is_apex = False # True when serving the public apex/landing host
if not current_app.config.get('MULTI_TENANT_ENABLED', False):
return # inert: default database serves everything (single-tenant)
@@ -124,8 +127,21 @@ def init_tenancy(app):
session.pop('impersonating_tenant_id', None)
session.pop('impersonating_superadmin_id', None)
# ── Normal Host → tenant resolution ──────────────────────────────
# ── Apex (marketing) host → public landing page ──────────────────
# The apex domain (jqc.app) and its www. variant are NOT tenants. Serve
# the public landing page for '/' and send any other non-exempt apex
# path back to it. /signup, /static, /welcome are already exempt above.
host = (request.host or '').split(':')[0].strip().lower()
base = (current_app.config.get('TENANT_BASE_DOMAIN') or '').strip().lower()
if base and host in (base, f'www.{base}'):
g.is_apex = True
if request.path == '/':
# Serve the landing view without a redirect (dashboard owns '/'
# on tenant hosts, so we can't register a second '/' route).
return current_app.view_functions['landing.index']()
return redirect('/')
# ── Normal Host → tenant resolution ──────────────────────────────
tenant = resolve_tenant(host)
if tenant is None:
return Response(_UNKNOWN_TENANT_PAGE, status=404, mimetype='text/html')