Move calendar blueprint to app level for correct URL routing
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
The calendar blueprint was nested under calendars (admin), making URLs
/{slug}/admin/{calendar_slug}/ instead of /{slug}/{calendar_slug}/.
Register calendar blueprint directly on the app and update all endpoint
references from calendars.calendar.* to calendar.* (37 in Python,
~50 in templates).
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -77,7 +77,7 @@ def _post_nav_html(ctx: dict) -> str:
|
||||
for cal in calendars:
|
||||
cal_slug = getattr(cal, "slug", "") if hasattr(cal, "slug") else cal.get("slug", "")
|
||||
cal_name = getattr(cal, "name", "") if hasattr(cal, "name") else cal.get("name", "")
|
||||
href = url_for("calendars.calendar.get", calendar_slug=cal_slug)
|
||||
href = url_for("calendar.get", calendar_slug=cal_slug)
|
||||
is_sel = (cal_slug == current_cal_slug)
|
||||
parts.append(render("nav-link", href=href, icon="fa fa-calendar",
|
||||
label=cal_name, select_colours=select_colours,
|
||||
@@ -122,7 +122,7 @@ def _calendar_header_html(ctx: dict, *, oob: bool = False) -> str:
|
||||
cal_name = getattr(calendar, "name", "")
|
||||
cal_desc = getattr(calendar, "description", "") or ""
|
||||
|
||||
link_href = url_for("calendars.calendar.get", calendar_slug=cal_slug)
|
||||
link_href = url_for("calendar.get", calendar_slug=cal_slug)
|
||||
label_html = render("events-calendar-label",
|
||||
name=cal_name, description=cal_desc)
|
||||
|
||||
@@ -146,11 +146,11 @@ def _calendar_nav_html(ctx: dict) -> str:
|
||||
select_colours = ctx.get("select_colours", "")
|
||||
|
||||
parts = []
|
||||
slots_href = url_for("calendars.calendar.slots.get", calendar_slug=cal_slug)
|
||||
slots_href = url_for("calendar.slots.get", calendar_slug=cal_slug)
|
||||
parts.append(render("nav-link", href=slots_href, icon="fa fa-clock",
|
||||
label="Slots", select_colours=select_colours))
|
||||
if is_admin:
|
||||
admin_href = url_for("calendars.calendar.admin.admin", calendar_slug=cal_slug)
|
||||
admin_href = url_for("calendar.admin.admin", calendar_slug=cal_slug)
|
||||
parts.append(render("nav-link", href=admin_href, icon="fa fa-cog",
|
||||
select_colours=select_colours))
|
||||
return "".join(parts)
|
||||
@@ -172,7 +172,7 @@ def _day_header_html(ctx: dict, *, oob: bool = False) -> str:
|
||||
return ""
|
||||
|
||||
link_href = url_for(
|
||||
"calendars.calendar.day.show_day",
|
||||
"calendar.day.show_day",
|
||||
calendar_slug=cal_slug,
|
||||
year=day_date.year,
|
||||
month=day_date.month,
|
||||
@@ -206,7 +206,7 @@ def _day_nav_html(ctx: dict) -> str:
|
||||
entry_links = []
|
||||
for entry in confirmed_entries:
|
||||
href = url_for(
|
||||
"calendars.calendar.day.calendar_entries.calendar_entry.get",
|
||||
"calendar.day.calendar_entries.calendar_entry.get",
|
||||
calendar_slug=cal_slug,
|
||||
year=day_date.year,
|
||||
month=day_date.month,
|
||||
@@ -223,7 +223,7 @@ def _day_nav_html(ctx: dict) -> str:
|
||||
|
||||
if is_admin and day_date:
|
||||
admin_href = url_for(
|
||||
"calendars.calendar.day.admin.admin",
|
||||
"calendar.day.admin.admin",
|
||||
calendar_slug=cal_slug,
|
||||
year=day_date.year,
|
||||
month=day_date.month,
|
||||
@@ -249,7 +249,7 @@ def _day_admin_header_html(ctx: dict, *, oob: bool = False) -> str:
|
||||
return ""
|
||||
|
||||
link_href = url_for(
|
||||
"calendars.calendar.day.admin.admin",
|
||||
"calendar.day.admin.admin",
|
||||
calendar_slug=cal_slug,
|
||||
year=day_date.year,
|
||||
month=day_date.month,
|
||||
@@ -274,8 +274,8 @@ def _calendar_admin_header_html(ctx: dict, *, oob: bool = False) -> str:
|
||||
nav_parts = []
|
||||
if cal_slug:
|
||||
for endpoint, label in [
|
||||
("calendars.calendar.slots.get", "slots"),
|
||||
("calendars.calendar.admin.calendar_description_edit", "description"),
|
||||
("calendar.slots.get", "slots"),
|
||||
("calendar.admin.calendar_description_edit", "description"),
|
||||
]:
|
||||
href = url_for(endpoint, calendar_slug=cal_slug)
|
||||
nav_parts.append(render("nav-link", href=href, label=label,
|
||||
@@ -357,8 +357,8 @@ def _calendars_list_html(ctx: dict, calendars: list) -> str:
|
||||
for cal in calendars:
|
||||
cal_slug = getattr(cal, "slug", "")
|
||||
cal_name = getattr(cal, "name", "")
|
||||
href = prefix + url_for("calendars.calendar.get", calendar_slug=cal_slug)
|
||||
del_url = url_for("calendars.calendar.delete", calendar_slug=cal_slug)
|
||||
href = prefix + url_for("calendar.get", calendar_slug=cal_slug)
|
||||
del_url = url_for("calendar.delete", calendar_slug=cal_slug)
|
||||
csrf_hdr = f'{{"X-CSRFToken":"{csrf}"}}'
|
||||
parts.append(render("events-calendars-item",
|
||||
href=href, cal_name=cal_name, cal_slug=cal_slug,
|
||||
@@ -399,7 +399,7 @@ def _calendar_main_panel_html(ctx: dict) -> str:
|
||||
qs = qsession if "qsession" not in ctx else ctx["qsession"]
|
||||
|
||||
def nav_link(y, m):
|
||||
return url_for("calendars.calendar.get", calendar_slug=cal_slug, year=y, month=m)
|
||||
return url_for("calendar.get", calendar_slug=cal_slug, year=y, month=m)
|
||||
|
||||
# Month navigation arrows
|
||||
nav_arrows = []
|
||||
@@ -449,7 +449,7 @@ def _calendar_main_panel_html(ctx: dict) -> str:
|
||||
day_short_html = ""
|
||||
if day_date:
|
||||
day_href = url_for(
|
||||
"calendars.calendar.day.show_day",
|
||||
"calendar.day.show_day",
|
||||
calendar_slug=cal_slug,
|
||||
year=day_date.year, month=day_date.month, day=day_date.day,
|
||||
)
|
||||
@@ -519,7 +519,7 @@ def _day_main_panel_html(ctx: dict) -> str:
|
||||
rows_html = render("events-day-empty-row")
|
||||
|
||||
add_url = url_for(
|
||||
"calendars.calendar.day.calendar_entries.add_form",
|
||||
"calendar.day.calendar_entries.add_form",
|
||||
calendar_slug=cal_slug,
|
||||
day=day, month=month, year=year,
|
||||
)
|
||||
@@ -543,7 +543,7 @@ def _day_row_html(ctx: dict, entry) -> str:
|
||||
tr_cls = getattr(styles, "tr", "") if hasattr(styles, "tr") else styles.get("tr", "")
|
||||
|
||||
entry_href = url_for(
|
||||
"calendars.calendar.day.calendar_entries.calendar_entry.get",
|
||||
"calendar.day.calendar_entries.calendar_entry.get",
|
||||
calendar_slug=cal_slug, day=day, month=month, year=year, entry_id=entry.id,
|
||||
)
|
||||
|
||||
@@ -554,7 +554,7 @@ def _day_row_html(ctx: dict, entry) -> str:
|
||||
# Slot/Time
|
||||
slot = getattr(entry, "slot", None)
|
||||
if slot:
|
||||
slot_href = url_for("calendars.calendar.slots.slot.get", calendar_slug=cal_slug, slot_id=slot.id)
|
||||
slot_href = url_for("calendar.slots.slot.get", calendar_slug=cal_slug, slot_id=slot.id)
|
||||
time_start = slot.time_start.strftime("%H:%M") if slot.time_start else ""
|
||||
time_end = f" \u2192 {slot.time_end.strftime('%H:%M')}" if slot.time_end else ""
|
||||
slot_html = render("events-day-row-slot",
|
||||
@@ -633,7 +633,7 @@ def _calendar_admin_main_panel_html(ctx: dict) -> str:
|
||||
desc = getattr(calendar, "description", "") or ""
|
||||
hx_select = ctx.get("hx_select_search", "#main-panel")
|
||||
|
||||
desc_edit_url = url_for("calendars.calendar.admin.calendar_description_edit", calendar_slug=cal_slug)
|
||||
desc_edit_url = url_for("calendar.admin.calendar_description_edit", calendar_slug=cal_slug)
|
||||
description_html = _calendar_description_display_html(calendar, desc_edit_url)
|
||||
|
||||
return render("events-calendar-admin-panel",
|
||||
@@ -1769,7 +1769,7 @@ def _entry_main_panel_html(ctx: dict) -> str:
|
||||
|
||||
# Options and Edit Button
|
||||
edit_url = url_for(
|
||||
"calendars.calendar.day.calendar_entries.calendar_entry.get_edit",
|
||||
"calendar.day.calendar_entries.calendar_entry.get_edit",
|
||||
entry_id=eid, calendar_slug=cal_slug,
|
||||
day=day, month=month, year=year,
|
||||
)
|
||||
@@ -1805,7 +1805,7 @@ def _entry_header_html(ctx: dict, *, oob: bool = False) -> str:
|
||||
year = ctx.get("year")
|
||||
|
||||
link_href = url_for(
|
||||
"calendars.calendar.day.calendar_entries.calendar_entry.get",
|
||||
"calendar.day.calendar_entries.calendar_entry.get",
|
||||
calendar_slug=cal_slug,
|
||||
year=year, month=month, day=day,
|
||||
entry_id=entry.id,
|
||||
@@ -1879,7 +1879,7 @@ def _entry_nav_html(ctx: dict) -> str:
|
||||
# Admin link
|
||||
if is_admin:
|
||||
admin_url = url_for(
|
||||
"calendars.calendar.day.calendar_entries.calendar_entry.admin.admin",
|
||||
"calendar.day.calendar_entries.calendar_entry.admin.admin",
|
||||
calendar_slug=cal_slug,
|
||||
day=day, month=month, year=year,
|
||||
entry_id=entry.id,
|
||||
@@ -1954,7 +1954,7 @@ def _entry_options_html(entry, calendar, day, month, year) -> str:
|
||||
|
||||
def _make_button(action_name, label, confirm_title, confirm_text, *, trigger_type="submit"):
|
||||
url = url_for(
|
||||
f"calendars.calendar.day.calendar_entries.calendar_entry.{action_name}",
|
||||
f"calendar.day.calendar_entries.calendar_entry.{action_name}",
|
||||
calendar_slug=cal_slug, day=day, month=month, year=year, entry_id=eid,
|
||||
)
|
||||
btn_type = "button" if trigger_type == "button" else "submit"
|
||||
@@ -2013,7 +2013,7 @@ def render_entry_tickets_config(entry, calendar, day, month, year) -> str:
|
||||
display_html = render("events-ticket-config-none", show_js=show_js)
|
||||
|
||||
update_url = url_for(
|
||||
"calendars.calendar.day.calendar_entries.calendar_entry.update_tickets",
|
||||
"calendar.day.calendar_entries.calendar_entry.update_tickets",
|
||||
entry_id=eid, calendar_slug=cal_slug, day=day, month=month, year=year,
|
||||
)
|
||||
hidden_cls = "" if tp is None else "hidden"
|
||||
@@ -2052,7 +2052,7 @@ def render_entry_posts_panel(entry_posts, entry, calendar, day, month, year) ->
|
||||
if feat else render("events-post-img-placeholder"))
|
||||
|
||||
del_url = url_for(
|
||||
"calendars.calendar.day.calendar_entries.calendar_entry.remove_post",
|
||||
"calendar.day.calendar_entries.calendar_entry.remove_post",
|
||||
calendar_slug=cal_slug, day=day, month=month, year=year,
|
||||
entry_id=eid, post_id=ep_id,
|
||||
)
|
||||
@@ -2065,7 +2065,7 @@ def render_entry_posts_panel(entry_posts, entry, calendar, day, month, year) ->
|
||||
posts_html = render("events-entry-posts-none")
|
||||
|
||||
search_url = url_for(
|
||||
"calendars.calendar.day.calendar_entries.calendar_entry.search_posts",
|
||||
"calendar.day.calendar_entries.calendar_entry.search_posts",
|
||||
calendar_slug=cal_slug, day=day, month=month, year=year, entry_id=eid,
|
||||
)
|
||||
|
||||
@@ -2121,7 +2121,7 @@ def render_day_entries_nav_oob(confirmed_entries, calendar, day_date) -> str:
|
||||
items = ""
|
||||
for entry in confirmed_entries:
|
||||
href = url_for(
|
||||
"calendars.calendar.day.calendar_entries.calendar_entry.get",
|
||||
"calendar.day.calendar_entries.calendar_entry.get",
|
||||
calendar_slug=cal_slug,
|
||||
year=day_date.year, month=day_date.month, day=day_date.day,
|
||||
entry_id=entry.id,
|
||||
@@ -2195,7 +2195,7 @@ def render_calendar_description(calendar, *, oob: bool = False) -> str:
|
||||
from quart import url_for
|
||||
|
||||
cal_slug = getattr(calendar, "slug", "")
|
||||
edit_url = url_for("calendars.calendar.admin.calendar_description_edit", calendar_slug=cal_slug)
|
||||
edit_url = url_for("calendar.admin.calendar_description_edit", calendar_slug=cal_slug)
|
||||
html = _calendar_description_display_html(calendar, edit_url)
|
||||
|
||||
if oob:
|
||||
@@ -2213,8 +2213,8 @@ def render_calendar_description_edit(calendar) -> str:
|
||||
cal_slug = getattr(calendar, "slug", "")
|
||||
desc = getattr(calendar, "description", "") or ""
|
||||
|
||||
save_url = url_for("calendars.calendar.admin.calendar_description_save", calendar_slug=cal_slug)
|
||||
cancel_url = url_for("calendars.calendar.admin.calendar_description_view", calendar_slug=cal_slug)
|
||||
save_url = url_for("calendar.admin.calendar_description_save", calendar_slug=cal_slug)
|
||||
cancel_url = url_for("calendar.admin.calendar_description_view", calendar_slug=cal_slug)
|
||||
|
||||
return render("events-calendar-description-edit-form",
|
||||
save_url=save_url, cancel_url=cancel_url,
|
||||
@@ -2270,7 +2270,7 @@ def render_slot_main_panel(slot, calendar, *, oob: bool = False) -> str:
|
||||
cost_str = f"{cost:.2f}" if cost is not None else ""
|
||||
desc = getattr(slot, "description", "") or ""
|
||||
|
||||
edit_url = url_for("calendars.calendar.slots.slot.get_edit", slot_id=slot.id, calendar_slug=cal_slug)
|
||||
edit_url = url_for("calendar.slots.slot.get_edit", slot_id=slot.id, calendar_slug=cal_slug)
|
||||
|
||||
# Days pills
|
||||
if days and days[0] != "\u2014":
|
||||
@@ -2319,8 +2319,8 @@ def render_slots_table(slots, calendar) -> str:
|
||||
rows_html = ""
|
||||
if slots:
|
||||
for s in slots:
|
||||
slot_href = url_for("calendars.calendar.slots.slot.get", calendar_slug=cal_slug, slot_id=s.id)
|
||||
del_url = url_for("calendars.calendar.slots.slot.slot_delete", calendar_slug=cal_slug, slot_id=s.id)
|
||||
slot_href = url_for("calendar.slots.slot.get", calendar_slug=cal_slug, slot_id=s.id)
|
||||
del_url = url_for("calendar.slots.slot.slot_delete", calendar_slug=cal_slug, slot_id=s.id)
|
||||
desc = getattr(s, "description", "") or ""
|
||||
|
||||
days_display = getattr(s, "days_display", "\u2014")
|
||||
@@ -2351,7 +2351,7 @@ def render_slots_table(slots, calendar) -> str:
|
||||
else:
|
||||
rows_html = render("events-slots-empty-row")
|
||||
|
||||
add_url = url_for("calendars.calendar.slots.add_form", calendar_slug=cal_slug)
|
||||
add_url = url_for("calendar.slots.add_form", calendar_slug=cal_slug)
|
||||
|
||||
return render("events-slots-table",
|
||||
list_container=list_container, rows_html=rows_html,
|
||||
@@ -2377,7 +2377,7 @@ def render_ticket_type_main_panel(ticket_type, entry, calendar, day, month, year
|
||||
tid = str(ticket_type.id)
|
||||
|
||||
edit_url = url_for(
|
||||
"calendars.calendar.day.calendar_entries.calendar_entry.ticket_types.ticket_type.get_edit",
|
||||
"calendar.day.calendar_entries.calendar_entry.ticket_types.ticket_type.get_edit",
|
||||
ticket_type_id=ticket_type.id, calendar_slug=cal_slug,
|
||||
year=year, month=month, day=day, entry_id=entry.id,
|
||||
)
|
||||
@@ -2416,12 +2416,12 @@ def render_ticket_types_table(ticket_types, entry, calendar, day, month, year) -
|
||||
if ticket_types:
|
||||
for tt in ticket_types:
|
||||
tt_href = url_for(
|
||||
"calendars.calendar.day.calendar_entries.calendar_entry.ticket_types.ticket_type.get",
|
||||
"calendar.day.calendar_entries.calendar_entry.ticket_types.ticket_type.get",
|
||||
calendar_slug=cal_slug, year=year, month=month, day=day,
|
||||
entry_id=eid, ticket_type_id=tt.id,
|
||||
)
|
||||
del_url = url_for(
|
||||
"calendars.calendar.day.calendar_entries.calendar_entry.ticket_types.ticket_type.delete",
|
||||
"calendar.day.calendar_entries.calendar_entry.ticket_types.ticket_type.delete",
|
||||
calendar_slug=cal_slug, year=year, month=month, day=day,
|
||||
entry_id=eid, ticket_type_id=tt.id,
|
||||
)
|
||||
@@ -2439,7 +2439,7 @@ def render_ticket_types_table(ticket_types, entry, calendar, day, month, year) -
|
||||
rows_html = render("events-ticket-types-empty-row")
|
||||
|
||||
add_url = url_for(
|
||||
"calendars.calendar.day.calendar_entries.calendar_entry.ticket_types.add_form",
|
||||
"calendar.day.calendar_entries.calendar_entry.ticket_types.add_form",
|
||||
calendar_slug=cal_slug, entry_id=eid, year=year, month=month, day=day,
|
||||
)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user