Replace fragment render functions with .sx defcomps

- Snippets list: render_snippets_list → render_to_sx("blog-snippets-content")
- Menu items list: render_menu_items_list → _render_menu_items_list helper
- Features panel: render_features_panel → render_to_sx("blog-features-panel-content")
- Markets panel: render_markets_panel → render_to_sx("blog-markets-panel-content")

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-03-04 09:20:47 +00:00
parent e75c8d16d1
commit f2910ad767
4 changed files with 119 additions and 54 deletions

View File

@@ -1,30 +1,20 @@
from __future__ import annotations
from quart import Blueprint, request, g, abort
from sqlalchemy import select, or_
from shared.browser.app.authz import require_login
from shared.sx.helpers import sx_response
from shared.sx.helpers import sx_response, render_to_sx
from models import Snippet
VALID_VISIBILITY = frozenset({"private", "shared", "admin"})
async def _visible_snippets(session):
"""Return snippets visible to the current user (own + shared + admin-if-admin)."""
uid = g.user.id
is_admin = g.rights.get("admin")
filters = [Snippet.user_id == uid, Snippet.visibility == "shared"]
if is_admin:
filters.append(Snippet.visibility == "admin")
rows = (await session.execute(
select(Snippet).where(or_(*filters)).order_by(Snippet.name)
)).scalars().all()
return rows
async def _render_snippets():
"""Render snippets list via service data + .sx defcomp."""
from shared.services.registry import services
data = await services.get("blog_page").snippets_data(g.s)
return await render_to_sx("blog-snippets-content", **data)
def register():
@@ -45,9 +35,7 @@ def register():
await g.s.delete(snippet)
await g.s.flush()
snippets = await _visible_snippets(g.s)
from sx.sx_components import render_snippets_list
return sx_response(await render_snippets_list(snippets, is_admin))
return sx_response(await _render_snippets())
@bp.patch("/<int:snippet_id>/visibility/")
@require_login
@@ -69,8 +57,6 @@ def register():
snippet.visibility = visibility
await g.s.flush()
snippets = await _visible_snippets(g.s)
from sx.sx_components import render_snippets_list
return sx_response(await render_snippets_list(snippets, True))
return sx_response(await _render_snippets())
return bp