Class: Admin::PagesController

Inherits:
AdminController show all
Includes:
PagesCore::Admin::NewsPageController
Defined in:
app/controllers/admin/pages_controller.rb

Instance Attribute Summary

Attributes included from PagesCore::Authentication

#current_user

Instance Method Summary collapse

Methods included from PagesCore::Admin::NewsPageController

#new_news, #news

Methods inherited from PagesCore::AdminController

#redirect, underscore

Methods included from PagesCore::PoliciesHelper

#policy, #verify_policy, #verify_policy_with_proc

Methods included from PagesCore::ProcessTitler

inc_number_of_requests, original_title

Methods included from PagesCore::ErrorRenderer

#render_error

Methods included from PagesCore::Authentication

#authenticate!, #deauthenticate!, #logged_in?

Instance Method Details

#createObject


32
33
34
35
36
37
38
39
40
41
42
# File 'app/controllers/admin/pages_controller.rb', line 32

def create
  @page = build_page(@locale, page_params, param_categories)
  if @page.valid?
    @page.save
    respond_with_page(@page) do
      redirect_to(edit_admin_page_url(@locale, @page))
    end
  else
    render action: :new
  end
end

#delete_meta_imageObject


69
70
71
72
73
# File 'app/controllers/admin/pages_controller.rb', line 69

def delete_meta_image
  @page.meta_image.destroy
  flash[:notice] = "The image was deleted"
  redirect_to edit_admin_page_url(@locale, @page, anchor: "metadata")
end

#deletedObject


15
16
17
# File 'app/controllers/admin/pages_controller.rb', line 15

def deleted
  @pages = Page.deleted.by_updated_at.in_locale(@locale)
end

#destroyObject


64
65
66
67
# File 'app/controllers/admin/pages_controller.rb', line 64

def destroy
  Page.find(params[:id]).flag_as_deleted!
  redirect_to admin_pages_url(@locale)
end

#editObject


44
# File 'app/controllers/admin/pages_controller.rb', line 44

def edit; end

#indexObject


11
12
13
# File 'app/controllers/admin/pages_controller.rb', line 11

def index
  @root_pages = Page.roots.in_locale(@locale).visible
end

#moveObject


58
59
60
61
62
# File 'app/controllers/admin/pages_controller.rb', line 58

def move
  parent = params[:parent_id] ? Page.find(params[:parent_id]) : nil
  @page.update(parent: parent, position: params[:position])
  respond_with_page(@page) { redirect_to admin_pages_url(@locale) }
end

#newObject


23
24
25
26
27
28
29
30
# File 'app/controllers/admin/pages_controller.rb', line 23

def new
  @page = build_page(@locale)
  @page.parent = if params[:parent]
                   Page.find(params[:parent])
                 elsif @news_pages
                   @news_pages.first
                 end
end

#showObject


19
20
21
# File 'app/controllers/admin/pages_controller.rb', line 19

def show
  redirect_to edit_admin_page_url(@locale, @page)
end

#updateObject


46
47
48
49
50
51
52
53
54
55
56
# File 'app/controllers/admin/pages_controller.rb', line 46

def update
  if @page.update(page_params)
    @page.categories = param_categories
    respond_with_page(@page) do
      flash[:notice] = "Your changes were saved"
      redirect_to edit_admin_page_url(@locale, @page)
    end
  else
    render action: :edit
  end
end