Improve calendar event display
This commit is contained in:
		
							parent
							
								
									3acad3649d
								
							
						
					
					
						commit
						ab83956558
					
				| 
						 | 
				
			
			@ -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,
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -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
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in a new issue