Aug 7 - Update new design as default
This commit is contained in:
+11
-5
@@ -167,22 +167,28 @@ def create_app(config_name='default'):
|
||||
# The mobile API renders no templates and authenticates by JWT — skip it
|
||||
# so this never touches the Flask-Login session loader on API traffic.
|
||||
if request.path.startswith('/api/'):
|
||||
# The API renders no templates; 'classic' here only means "never
|
||||
# rewrite a template name" (see ThemedEnvironment.get_template).
|
||||
g.jqc_theme = 'classic'
|
||||
return
|
||||
from flask_login import current_user as _cu
|
||||
theme = 'classic'
|
||||
# phase50 — the fallback is configurable and now defaults to 'modern'.
|
||||
# A stored users.ui_theme still wins, so an explicit choice is kept.
|
||||
default = app.config.get('DEFAULT_UI_THEME', 'modern')
|
||||
theme = default
|
||||
try:
|
||||
if _cu.is_authenticated:
|
||||
theme = _cu.ui_theme or 'classic'
|
||||
theme = _cu.ui_theme or default
|
||||
except Exception: # DB column missing (migration not yet run)
|
||||
theme = 'classic'
|
||||
g.jqc_theme = theme if theme in ('classic', 'modern') else 'classic'
|
||||
theme = default
|
||||
g.jqc_theme = theme if theme in ('classic', 'modern') else default
|
||||
|
||||
@app.context_processor
|
||||
def inject_ui_theme():
|
||||
"""Give base.html the shell to extend."""
|
||||
from app.utils.time_utils import now_eastern
|
||||
theme = getattr(g, 'jqc_theme', 'classic')
|
||||
theme = getattr(g, 'jqc_theme',
|
||||
app.config.get('DEFAULT_UI_THEME', 'modern'))
|
||||
_now = now_eastern()
|
||||
return {
|
||||
'jqc_theme': theme,
|
||||
|
||||
+3
-1
@@ -59,8 +59,10 @@ class User(UserMixin, db.Model):
|
||||
# Drives base.html's layout dispatch via the inject_ui_theme() context
|
||||
# processor. Persisted per user so the choice survives logout and can be
|
||||
# tallied as a vote (see /ui/theme-votes).
|
||||
# phase50 — 'modern' is the default for new accounts. Existing rows were
|
||||
# migrated in phase50; anyone who switches keeps their own choice.
|
||||
ui_theme = db.Column(db.String(16), nullable=False,
|
||||
server_default='classic', default='classic')
|
||||
server_default='modern', default='modern')
|
||||
|
||||
# ── Customer password-setup workflow ──────────────────────────────────
|
||||
# password_set: False for newly created customer accounts until they
|
||||
|
||||
+3
-2
@@ -16,7 +16,7 @@ layout shell base.html extends.
|
||||
import logging
|
||||
|
||||
from flask import (Blueprint, render_template, redirect, request,
|
||||
url_for, flash)
|
||||
url_for, flash, current_app)
|
||||
from flask_login import login_required, current_user
|
||||
from sqlalchemy import func
|
||||
|
||||
@@ -51,7 +51,8 @@ def switch_theme():
|
||||
flash('Unknown design option.', 'warning')
|
||||
return redirect(_safe_next(request.form.get('next')))
|
||||
|
||||
previous = current_user.ui_theme or 'classic'
|
||||
previous = current_user.ui_theme or current_app.config.get(
|
||||
'DEFAULT_UI_THEME', 'modern')
|
||||
if previous != theme:
|
||||
current_user.ui_theme = theme
|
||||
db.session.commit()
|
||||
|
||||
Reference in New Issue
Block a user