06/15 Phase 4 + 5 codes

This commit is contained in:
2026-06-15 17:43:47 -04:00
parent f57a95013c
commit a9efd15a76
36 changed files with 1677 additions and 57 deletions
+33 -1
View File
@@ -53,11 +53,15 @@ def _register_blueprints(app):
from app.blueprints.i18n.routes import i18n_bp
from app.blueprints.listings.routes import listings_bp
from app.blueprints.messaging.routes import messaging_bp
from app.blueprints.payments.routes import payments_bp
from app.blueprints.ads.routes import ads_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)
app.register_blueprint(payments_bp)
app.register_blueprint(ads_bp)
def _register_errorhandlers(app):
@@ -78,6 +82,7 @@ def _register_context(app):
from flask_babel import get_locale
from flask import request
from flask_login import current_user
from app.blueprints.ads.routes import inject_ads
def merge_query(**overrides):
merged = request.args.to_dict()
@@ -93,19 +98,46 @@ def _register_context(app):
unread = total_unread(current_user)
except Exception:
pass
ad_context = {}
try:
ad_context = inject_ads()
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,
**ad_context,
}
def _register_cli(app):
@app.cli.command("expire-listings")
def expire_listings():
def expire_listings_cmd():
"""Sweep: flip past-due active listings to expired."""
from app.services.listings import expire_due_listings
n = expire_due_listings()
print(f"Expired {n} listing(s).")
@app.cli.command("expire-boosts")
def expire_boosts_cmd():
"""Sweep: clear expired boosts, revert listing effects."""
from app.services.billing import expire_boosts
n = expire_boosts()
print(f"Cleared {n} expired boost(s).")
@app.cli.command("expire-promoted-keywords")
def expire_promoted_cmd():
"""Sweep: remove expired promoted keyword rows."""
from app.services.ads import expire_promoted_keywords
n = expire_promoted_keywords()
print(f"Removed {n} expired promoted keyword(s).")
@app.cli.command("reconcile-subscriptions")
def reconcile_cmd():
"""Nightly: sync local subscription status vs Stripe."""
from app.services.billing import reconcile_subscriptions
checked, fixed = reconcile_subscriptions()
print(f"Reconciled {checked} subscription(s), fixed {fixed}.")