Files
rose-ash/events/bp/markets/routes.py
giles f42042ccb7
All checks were successful
Build and Deploy / build-and-deploy (push) Successful in 1m5s
Monorepo: consolidate 7 repos into one
Combines shared, blog, market, cart, events, federation, and account
into a single repository. Eliminates submodule sync, sibling model
copying at build time, and per-app CI orchestration.

Changes:
- Remove per-app .git, .gitmodules, .gitea, submodule shared/ dirs
- Remove stale sibling model copies from each app
- Update all 6 Dockerfiles for monorepo build context (root = .)
- Add build directives to docker-compose.yml
- Add single .gitea/workflows/ci.yml with change detection
- Add .dockerignore for monorepo build context
- Create __init__.py for federation and account (cross-app imports)
2026-02-24 19:44:17 +00:00

66 lines
2.0 KiB
Python

from __future__ import annotations
from quart import (
request, render_template, make_response, Blueprint, g
)
from .services.markets import (
create_market as svc_create_market,
soft_delete as svc_soft_delete,
)
from shared.browser.app.redis_cacher import cache_page, clear_cache
from shared.browser.app.authz import require_admin
from shared.browser.app.utils.htmx import is_htmx_request
def register():
bp = Blueprint("markets", __name__, url_prefix='/markets')
@bp.context_processor
async def inject_root():
return {}
@bp.get("/")
async def home(**kwargs):
if not is_htmx_request():
html = await render_template("_types/markets/index.html")
else:
html = await render_template("_types/markets/_oob_elements.html")
return await make_response(html)
@bp.post("/new/")
@require_admin
async def create_market(**kwargs):
form = await request.form
name = (form.get("name") or "").strip()
post_data = getattr(g, "post_data", None)
post_id = (post_data.get("post") or {}).get("id") if post_data else None
if not post_id:
post_id = form.get("post_id")
if post_id:
post_id = int(post_id)
try:
await svc_create_market(g.s, post_id, name)
except Exception as e:
return await make_response(f'<div class="text-red-600 text-sm">{e}</div>', 422)
html = await render_template("_types/markets/index.html")
return await make_response(html)
@bp.delete("/<market_slug>/")
@require_admin
async def delete_market(market_slug: str, **kwargs):
post_slug = getattr(g, "post_slug", None)
deleted = await svc_soft_delete(g.s, post_slug, market_slug)
if not deleted:
return await make_response("Market not found", 404)
html = await render_template("_types/markets/index.html")
return await make_response(html)
return bp