Module: PagesCore::Admin::NewsPageController

Extended by:
ActiveSupport::Concern
Included in:
Admin::PagesController
Defined in:
app/controllers/concerns/pages_core/admin/news_page_controller.rb

Instance Method Summary collapse

Instance Method Details

#new_newsObject


31
32
33
34
# File 'app/controllers/concerns/pages_core/admin/news_page_controller.rb', line 31

def new_news
  new
  render action: :new
end

#newsObject


11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'app/controllers/concerns/pages_core/admin/news_page_controller.rb', line 11

def news
  @archive_finder = archive_finder(@news_pages, @locale)

  unless params[:year]
    redirect_to(news_admin_pages_path(@locale,
                                      (@archive_finder.latest_year ||
                                       Time.zone.now.year)))
    return
  end

  @year = params[:year]&.to_i
  @month = params[:month]&.to_i

  @pages = (if @month
              @archive_finder.by_year_and_month(@year, @month)
            else
              @archive_finder.by_year(@year)
            end).paginate(per_page: 50, page: params[:page])
end