06/15 Phase 3 codes
This commit is contained in:
@@ -52,10 +52,12 @@ def _register_blueprints(app):
|
||||
from app.blueprints.auth.routes import auth_bp
|
||||
from app.blueprints.i18n.routes import i18n_bp
|
||||
from app.blueprints.listings.routes import listings_bp
|
||||
from app.blueprints.messaging.routes import messaging_bp
|
||||
app.register_blueprint(main_bp)
|
||||
app.register_blueprint(auth_bp)
|
||||
app.register_blueprint(i18n_bp)
|
||||
app.register_blueprint(listings_bp)
|
||||
app.register_blueprint(messaging_bp)
|
||||
|
||||
|
||||
def _register_errorhandlers(app):
|
||||
@@ -75,6 +77,7 @@ def _register_errorhandlers(app):
|
||||
def _register_context(app):
|
||||
from flask_babel import get_locale
|
||||
from flask import request
|
||||
from flask_login import current_user
|
||||
|
||||
def merge_query(**overrides):
|
||||
merged = request.args.to_dict()
|
||||
@@ -83,11 +86,19 @@ def _register_context(app):
|
||||
|
||||
@app.context_processor
|
||||
def inject_globals():
|
||||
unread = 0
|
||||
if current_user.is_authenticated:
|
||||
try:
|
||||
from app.services.messaging import total_unread
|
||||
unread = total_unread(current_user)
|
||||
except Exception:
|
||||
pass
|
||||
return {
|
||||
"get_locale": get_locale,
|
||||
"merge_query": merge_query,
|
||||
"SUPPORTED_LOCALES": app.config["SUPPORTED_LOCALES"],
|
||||
"TURNSTILE_SITE_KEY": app.config.get("TURNSTILE_SITE_KEY", ""),
|
||||
"unread_count": unread,
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user