Sha256: c583cd19730057ea12c7798a82e1c0b0be412ada134c12b698b034482af5ed0e

Contents?: true

Size: 825 Bytes

Versions: 10

Compression:

Stored size: 825 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(content_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(content_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

10 entries across 10 versions & 1 rubygems

Version Path
pages_core-3.15.5 app/controllers/admin/calendars_controller.rb
pages_core-3.15.4 app/controllers/admin/calendars_controller.rb
pages_core-3.15.3 app/controllers/admin/calendars_controller.rb
pages_core-3.15.2 app/controllers/admin/calendars_controller.rb
pages_core-3.15.1 app/controllers/admin/calendars_controller.rb
pages_core-3.14.0 app/controllers/admin/calendars_controller.rb
pages_core-3.13.0 app/controllers/admin/calendars_controller.rb
pages_core-3.12.7 app/controllers/admin/calendars_controller.rb
pages_core-3.12.6 app/controllers/admin/calendars_controller.rb
pages_core-3.12.5 app/controllers/admin/calendars_controller.rb