def events_this_week(context):
    """
    Displays a week's worth of events.   Starts week with Monday, unless today is Sunday.
    """
    request = context['request']
    home = request.site.root_page
    cal = CalendarPage.objects.live().descendant_of(home).first()
    calUrl = cal.get_url(request) if cal else None
    calName = cal.title if cal else None
    today = dt.date.today()
    beginOrd = today.toordinal()
    if today.weekday() != 6:
        # Start week with Monday, unless today is Sunday
        beginOrd -= today.weekday()
    endOrd = beginOrd + 6
    dateFrom = dt.date.fromordinal(beginOrd)
    dateTo   = dt.date.fromordinal(endOrd)
    if cal:
        events = cal._getEventsByDay(request, dateFrom, dateTo)
    else:
        events = getAllEventsByDay(request, dateFrom, dateTo)
    return {'request':      request,
            'today':        today,
            'calendarUrl':  calUrl,
            'calendarName': calName,
            'events':       events }
def events_this_week ( context ) : request = context [ 'request' ] home = request . site . root_page cal = CalendarPage . objects . live ( ) . descendant_of ( home ) . first ( ) calUrl = cal . get_url ( request ) if cal else None calName = cal . title if cal else None today = dt . date . today ( ) beginOrd = today . toordinal ( ) if today . weekday ( ) != 6 : beginOrd -= today . weekday ( ) endOrd = beginOrd + 6 dateFrom = dt . date . fromordinal ( beginOrd ) dateTo = dt . date . fromordinal ( endOrd ) if cal : events = cal . _getEventsByDay ( request , dateFrom , dateTo ) else : events = getAllEventsByDay ( request , dateFrom , dateTo ) return { 'request' : request , 'today' : today , 'calendarUrl' : calUrl , 'calendarName' : calName , 'events' : events }
Displays a week's worth of events.   Starts week with Monday, unless today is Sunday.