From 9cba422aa9c072db4bbb2662315d66ea011bd19e Mon Sep 17 00:00:00 2001 From: giles Date: Thu, 19 Feb 2026 05:04:53 +0000 Subject: [PATCH] Fix DTO compatibility: replace ORM relationship traversals with DTO fields Templates were accessing entry.calendar.name/slug/post via ORM relationships, but these entries are now CalendarEntryDTOs. Use flat fields instead (calendar_name, calendar_slug, etc.). Co-Authored-By: Claude Opus 4.6 --- browser/templates/_types/blog/_card.html | 2 +- browser/templates/_types/cart/_cart.html | 2 +- browser/templates/_types/post/_entry_items.html | 8 ++++---- contracts/dtos.py | 2 ++ services/calendar_impl.py | 2 ++ 5 files changed, 10 insertions(+), 6 deletions(-) diff --git a/browser/templates/_types/blog/_card.html b/browser/templates/_types/blog/_card.html index d5b1347..fd3743a 100644 --- a/browser/templates/_types/blog/_card.html +++ b/browser/templates/_types/blog/_card.html @@ -76,7 +76,7 @@
{% for entry in post.associated_entries %} - {% set _entry_path = '/' + post.slug + '/calendars/' + entry.calendar.slug + '/' + entry.start_at.year|string + '/' + entry.start_at.month|string + '/' + entry.start_at.day|string + '/entries/' + entry.id|string + '/' %} + {% set _entry_path = '/' + post.slug + '/calendars/' + entry.calendar_slug + '/' + entry.start_at.year|string + '/' + entry.start_at.month|string + '/' + entry.start_at.day|string + '/entries/' + entry.id|string + '/' %} diff --git a/browser/templates/_types/cart/_cart.html b/browser/templates/_types/cart/_cart.html index 3ebe37c..30a08b2 100644 --- a/browser/templates/_types/cart/_cart.html +++ b/browser/templates/_types/cart/_cart.html @@ -43,7 +43,7 @@
  • - {{ entry.name or entry.calendar.name }} + {{ entry.name or entry.calendar_name }}
    {{ entry.start_at }} diff --git a/browser/templates/_types/post/_entry_items.html b/browser/templates/_types/post/_entry_items.html index 3a7b04f..d221e85 100644 --- a/browser/templates/_types/post/_entry_items.html +++ b/browser/templates/_types/post/_entry_items.html @@ -4,14 +4,14 @@ {% set has_more_entries = has_more if has_more is defined else (associated_entries.has_more if associated_entries is defined else False) %} {% for entry in entry_list %} - {% set _entry_path = '/' + post.slug + '/calendars/' + entry.calendar.slug + '/' + entry.start_at.year|string + '/' + entry.start_at.month|string + '/' + entry.start_at.day|string + '/entries/' + entry.id|string + '/' %} + {% set _entry_path = '/' + post.slug + '/calendars/' + entry.calendar_slug + '/' + entry.start_at.year|string + '/' + entry.start_at.month|string + '/' + entry.start_at.day|string + '/entries/' + entry.id|string + '/' %} - {% if entry.calendar.post.feature_image %} - {{ entry.calendar.post.title }} {% else %}
    diff --git a/contracts/dtos.py b/contracts/dtos.py index f0f8c4f..fd1916f 100644 --- a/contracts/dtos.py +++ b/contracts/dtos.py @@ -60,6 +60,8 @@ class CalendarEntryDTO: ticket_count: int | None = None calendar_name: str | None = None calendar_slug: str | None = None + calendar_container_id: int | None = None + calendar_container_type: str | None = None # --------------------------------------------------------------------------- diff --git a/services/calendar_impl.py b/services/calendar_impl.py index 809ff3a..d78531b 100644 --- a/services/calendar_impl.py +++ b/services/calendar_impl.py @@ -42,6 +42,8 @@ def _entry_to_dto(entry: CalendarEntry) -> CalendarEntryDTO: ticket_count=entry.ticket_count, calendar_name=cal.name if cal else None, calendar_slug=cal.slug if cal else None, + calendar_container_id=cal.container_id if cal else None, + calendar_container_type=cal.container_type if cal else None, )