Move calendar management to /{slug}/admin/ and reserve slug
All checks were successful
Build and Deploy / build-and-deploy (push) Successful in 1m3s
All checks were successful
Build and Deploy / build-and-deploy (push) Successful in 1m3s
- Change calendars blueprint prefix from /calendars to /admin
- Simplify routes from /calendars/ to / within blueprint
- Reserve admin, markets, payments, entries as calendar slugs
- Update blog admin nav link to /{slug}/admin/
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -90,8 +90,8 @@ def create_app() -> "Quart":
|
||||
url_prefix="/<slug>",
|
||||
)
|
||||
|
||||
# Calendars nested under post slug: /<slug>/<calendar_slug>/...
|
||||
# Listing stays at /<slug>/calendars/, individual at /<slug>/<calendar_slug>/
|
||||
# Calendar admin under post slug: /<slug>/admin/
|
||||
# Individual calendars at /<slug>/<calendar_slug>/
|
||||
app.register_blueprint(
|
||||
register_calendars(),
|
||||
url_prefix="/<slug>",
|
||||
|
||||
@@ -21,7 +21,7 @@ from shared.browser.app.utils.htmx import is_htmx_request
|
||||
|
||||
|
||||
def register():
|
||||
bp = Blueprint("calendars", __name__, url_prefix='/calendars')
|
||||
bp = Blueprint("calendars", __name__, url_prefix='/admin')
|
||||
bp.register_blueprint(
|
||||
register_calendar(),
|
||||
)
|
||||
@@ -32,7 +32,7 @@ def register():
|
||||
|
||||
# ---------- Pages ----------
|
||||
|
||||
@bp.get("/calendars/")
|
||||
@bp.get("/")
|
||||
@cache_page(tag="calendars")
|
||||
async def home(**kwargs):
|
||||
from shared.sexp.page import get_template_context
|
||||
@@ -46,7 +46,7 @@ def register():
|
||||
return await make_response(html)
|
||||
|
||||
|
||||
@bp.post("/calendars/new/")
|
||||
@bp.post("/new/")
|
||||
@require_admin
|
||||
@clear_cache(tag="calendars", tag_scope="all")
|
||||
async def create_calendar(**kwargs):
|
||||
|
||||
@@ -86,7 +86,9 @@ async def create_calendar(sess: AsyncSession, post_id: int, name: str) -> Calend
|
||||
name = (name or "").strip()
|
||||
if not name:
|
||||
raise CalendarError("Calendar name must not be empty.")
|
||||
slug=slugify(name)
|
||||
slug = slugify(name)
|
||||
if slug in ("admin", "markets", "payments", "entries"):
|
||||
raise CalendarError(f'"{slug}" is a reserved name and cannot be used as a calendar name.')
|
||||
|
||||
# Ensure post exists (avoid silent FK errors in some DBs)
|
||||
raw = await fetch_data("blog", "post-by-id", params={"id": post_id}, required=False)
|
||||
|
||||
Reference in New Issue
Block a user