Class: Cms::SectionsController

Inherits:
BaseController show all
Defined in:
app/controllers/cms/sections_controller.rb

Instance Method Summary collapse

Methods included from PageHelper

#able_to?, #cms_content_editor, #cms_toolbar, #container, #container_has_block?, #current_page, #page_title, #render_breadcrumbs, #render_portlet

Methods included from PathHelper

#attachment_path_for, #cms_connectable_path, #cms_index_path_for, #cms_index_url_for, #cms_new_path_for, #cms_new_url_for, #cms_sortable_column_path, #edit_cms_connectable_path, #engine_for, #link_to_usages, #path_elements_for

Methods included from ErrorHandling

#handle_access_denied, #handle_server_error, #with_format

Instance Method Details

#createObject



24
25
26
27
28
29
30
31
32
33
34
# File 'app/controllers/cms/sections_controller.rb', line 24

def create
  @section = Cms::Section.new(params[:section])
  @section.parent = @parent
  @section.groups = @section.parent.groups unless current_user.able_to?(:administrate)
  if @section.save
    flash[:notice] = "Section '#{@section.name}' was created"
    redirect_to @section
  else
    render :action => 'new'
  end
end

#destroyObject



50
51
52
53
54
55
56
57
58
59
60
61
62
# File 'app/controllers/cms/sections_controller.rb', line 50

def destroy
  respond_to do |format|
    if @section.deletable? && @section.destroy
      message = "Section '#{@section.name}' was deleted."
      format.html { flash[:notice] = message; redirect_to(sitemap_url) }
      format.json { render :json => {:success => true, :message => message} }
    else
      message = "Section '#{@section.name}' could not be deleted"
      format.html { flash[:error] = message; redirect_to(sitemap_url) }
      format.json { render :json => {:success => false, :message => message} }
    end
  end
end

#editObject



36
37
# File 'app/controllers/cms/sections_controller.rb', line 36

def edit
end

#indexObject



11
12
13
# File 'app/controllers/cms/sections_controller.rb', line 11

def index
  redirect_to cms.sitemap_path
end

#moveObject



64
65
66
67
68
69
70
# File 'app/controllers/cms/sections_controller.rb', line 64

def move
  if params[:section_id]
    @move_to = Section.find(params[:section_id])
  else
    @move_to = Section.root.first
  end
end

#newObject



19
20
21
22
# File 'app/controllers/cms/sections_controller.rb', line 19

def new
  @section = @parent.build_section
  @section.groups = @parent.groups
end

#showObject



15
16
17
# File 'app/controllers/cms/sections_controller.rb', line 15

def show
  redirect_to cms.sitemap_path
end

#updateObject



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

def update
  params[:section].delete('group_ids') if params[:section] && !current_user.able_to?(:administrate)
  @section.attributes = params[:section]
  if @section.save
    flash[:notice] = "Section '#{@section.name}' was updated"
    redirect_to @section
  else
    render :action => 'edit'
  end
end