def show_list_view(context, request): year, month, day = _date_requested(context, request) focus_datetime = datetime.datetime(year, month, day) now_datetime = _now() page = int(request.GET.get('page', 1)) per_page = int(request.GET.get('per_page', 20)) # make the calendar presenter for this view url_for = _make_calendar_presenter_url_func(context, request) calendar = ListViewPresenter(focus_datetime, now_datetime, url_for) # find events and paint them on the calendar selected_layer = _calendar_filter(context, request) events, has_more = _paginate_catalog_events(context, request, first_moment=now_datetime, last_moment=None, layer_name=selected_layer, per_page=per_page, page=page) calendar.paint_paginated_events(events, has_more, per_page, page) layers = _get_calendar_layers(context) setup_url = _calendar_setup_url(context, request) # render api = TemplateAPI(context, request, calendar.title) response = render_template_to_response( calendar.template_filename, api=api, setup_url=setup_url, calendar=calendar, selected_layer = selected_layer, layers = layers, quote = quote, may_create = has_permission(CREATE, context, request), ) response.set_cookie(KARL_CALENDAR_VIEW_COOKIE, 'list') response.set_cookie(KARL_CALENDAR_DATE_COOKIE, '%04d-%02d-%02d' % (year, month, day)) if selected_layer: response.set_cookie(KARL_CALENDAR_FILTER_COOKIE, selected_layer) return response
def show_list_view(context, request): selection = _get_calendar_cookies(context, request) selection['viewtype'] = 'list' # Check if we are in /offices/calendar. calendar_layout = _select_calendar_layout(context, request) year, month, day = selection['year'], selection['month'], selection['day'] focus_datetime = datetime.datetime(year, month, day) now_datetime = _now() page = int(request.GET.get('page', 1)) per_page = int(request.GET.get('per_page', 20)) # make the calendar presenter for this view url_for = _make_calendar_presenter_url_func(context, request) calendar = ListViewPresenter(focus_datetime, now_datetime, url_for) # Also make an event horizon for the selected term # (day, week or month) if not selection['term']: selection['term'] = 'day' event_horizon = { 'day': DayEventHorizon, 'week': WeekEventHorizon, 'month': MonthEventHorizon, }[selection['term']](focus_datetime, now_datetime, url_for) # find events and paint them on the calendar selected_layer = _calendar_filter(context, request) events, has_more = _paginate_catalog_events(context, request, first_moment=event_horizon.first_moment, last_moment=event_horizon.last_moment, layer_name=selected_layer, per_page=per_page, page=page) calendar.paint_paginated_events(events, has_more, per_page, page) layers = _get_calendar_layers(context) setup_url = _calendar_setup_url(context, request) # render api = TemplateAPI(context, request, calendar.title) api.karl_client_data['calendar_selection'] = selection response = render_to_response( calendar.template_filename, dict( calendar_format_class = calendar_layout['calendar_format_class'], calendar_layout_template = calendar_layout['calendar_layout_template'], api=api, setup_url=setup_url, calendar=calendar, selected_layer = selected_layer, layers = layers, quote = quote, may_create = has_permission(CREATE, context, request)), request=request, ) _set_calendar_cookies(response, selection) return response