Class: Qbrick::Cms::PagesController

Inherits:
BackendController show all
Defined in:
app/controllers/qbrick/cms/pages_controller.rb

Instance Method Summary collapse

Methods inherited from BackendController

#default_url_options, #reset_remembered_locale, #set_content_locale

Instance Method Details

#createObject



22
23
24
25
26
27
28
29
30
31
# File 'app/controllers/qbrick/cms/pages_controller.rb', line 22

def create
  @page = Qbrick::Page.create(page_params)

  if @page.valid?
    flash[:success] = t('layouts.qbrick.cms.flash.success', subject: Qbrick::Page.model_name.human)
    respond_with @page, location: qbrick.edit_cms_page_path(@page)
  else
    render 'new'
  end
end

#destroyObject



50
51
52
53
# File 'app/controllers/qbrick/cms/pages_controller.rb', line 50

def destroy
  @page = Qbrick::Page.find(params[:id])
  @page.destroy
end

#editObject



33
34
35
36
37
38
# File 'app/controllers/qbrick/cms/pages_controller.rb', line 33

def edit
  @page = Qbrick::Page.find(params[:id])
  @page.published ||= Qbrick::PublishState::UNPUBLISHED
  @page.bricks.each(&:valid?)
  respond_with @page
end

#indexObject



6
7
8
9
# File 'app/controllers/qbrick/cms/pages_controller.rb', line 6

def index
  @pages = Qbrick::Page.roots
  respond_with @pages
end

#mirrorObject



59
60
61
62
63
# File 'app/controllers/qbrick/cms/pages_controller.rb', line 59

def mirror
  @page = Qbrick::Page.find(params[:page_id])
  mirror_page if page_can_be_mirrored?
  respond_to :js, :html
end

#newObject



16
17
18
19
20
# File 'app/controllers/qbrick/cms/pages_controller.rb', line 16

def new
  @page = Qbrick::Page.new
  @page.published ||= Qbrick::PublishState::UNPUBLISHED
  respond_with @page
end

#showObject



11
12
13
14
# File 'app/controllers/qbrick/cms/pages_controller.rb', line 11

def show
  @page = Qbrick::Page.find(params[:id])
  respond_with @page
end

#sortObject



55
56
57
# File 'app/controllers/qbrick/cms/pages_controller.rb', line 55

def sort
  Qbrick::PageTree.update(params[:page_tree])
end

#updateObject



40
41
42
43
44
45
46
47
48
# File 'app/controllers/qbrick/cms/pages_controller.rb', line 40

def update
  @page = Qbrick::Page.find(params[:id])
  if @page.update_attributes(page_params)
    flash[:success] = t('layouts.qbrick.cms.flash.success', subject: Qbrick::Page.model_name.human)
    respond_with @page, location: qbrick.edit_cms_page_path(@page)
  else
    render 'edit'
  end
end