Sha256: c96a2350d761ee3273f95db9894bebd00cb0f30dc537cd00936e305d826716dc

Contents?: true

Size: 811 Bytes

Versions: 5

Compression:

Stored size: 811 Bytes

Contents

# frozen_string_literal: true

module Admin
  class CalendarsController < Admin::AdminController
    before_action :find_year_and_month

    require_authorization object: Page

    def show
      unless @year
        redirect_to(admin_calendar_path(@locale, Time.zone.now.year))
        return
      end
      @pages = if @month
                 calendar_items.in_year_and_month(@year, @month)
               else
                 calendar_items.in_year(@year)
               end
    end

    private

    def calendar_items
      Page.with_dates
          .order("starts_at DESC")
          .in_locale(@locale)
          .visible
          .paginate(per_page: 50, page: params[:page])
    end

    def find_year_and_month
      @year = params[:year]&.to_i
      @month = params[:month]&.to_i
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
pages_core-3.12.4 app/controllers/admin/calendars_controller.rb
pages_core-3.12.3 app/controllers/admin/calendars_controller.rb
pages_core-3.12.2 app/controllers/admin/calendars_controller.rb
pages_core-3.12.1 app/controllers/admin/calendars_controller.rb
pages_core-3.12.0 app/controllers/admin/calendars_controller.rb