Improve calendar event display

This commit is contained in:
Edward Betts 2023-11-03 15:22:53 +00:00
parent 3acad3649d
commit ab83956558
2 changed files with 32 additions and 2 deletions

View file

@ -657,11 +657,41 @@ def build_events_for_calendar(events: list[Event]) -> list[dict[str, typing.Any]
"""Build list of events for FullCalendar."""
items: list[dict[str, typing.Any]] = []
one_day = timedelta(days=1)
for e in events:
if e.name == "accommodation":
assert e.title and e.end_date
item = {
"allDay": True,
"title": e.display_title,
"start": e.as_date.isoformat(),
"end": (e.end_as_date + one_day).isoformat(),
"url": e.url,
}
items.append(item)
item = {
"allDay": False,
"title": "checkin: " + e.title,
"start": e.date.isoformat(),
"url": e.url,
}
items.append(item)
item = {
"allDay": False,
"title": "checkout: " + e.title,
"start": e.end_date.isoformat(),
"url": e.url,
}
items.append(item)
continue
if e.has_time:
end = e.end_date or e.date + timedelta(hours=1)
else:
end = (e.end_as_date if e.end_date else e.as_date) + timedelta(days=1)
end = (e.end_as_date if e.end_date else e.as_date) + one_day
item = {
"allDay": not e.has_time,
"title": e.display_title,

View file

@ -88,4 +88,4 @@ class Event:
@property
def display_title(self) -> str:
"""Name for display."""
return self.name + ": " + self.title if self.title else self.name
return self.title or self.name