Class: DmCms::Admin::CmsContentitemsController

Inherits:
AdminController
  • Object
show all
Includes:
PermittedParams, DmCore::LiquidHelper
Defined in:
app/controllers/dm_cms/admin/cms_contentitems_controller.rb

Instance Method Summary collapse

Methods included from PermittedParams

#cms_blog_params, #cms_contentitem_params, #cms_page_params, #cms_post_params, #cms_snippet_params, #media_file_params

Instance Method Details

#create_contentObject




17
18
19
20
21
22
23
24
25
# File 'app/controllers/dm_cms/admin/cms_contentitems_controller.rb', line 17

def create_content
  authorize! :manage_content, @current_page
  @cms_contentitem = @current_page.cms_contentitems.new(cms_contentitem_params)
  if @cms_contentitem.save
    redirect_to admin_cms_page_url(@current_page), notice: 'Content successfully created.'
  else
    render action: "new_content", notice: 'Content successfully created.'
  end
end

#destroyObject




43
44
45
46
47
# File 'app/controllers/dm_cms/admin/cms_contentitems_controller.rb', line 43

def destroy
  authorize! :manage_content, @current_page
  @cms_contentitem.destroy
  redirect_to(:controller => 'dm_cms/admin/cms_pages', :action => :show, :id => @cms_contentitem.cms_page_id)
end

#editObject




28
29
30
# File 'app/controllers/dm_cms/admin/cms_contentitems_controller.rb', line 28

def edit
  authorize! :manage_content, @current_page
end

#markdownObject




75
76
77
78
79
80
# File 'app/controllers/dm_cms/admin/cms_contentitems_controller.rb', line 75

def markdown
  @text = ''
  if put_or_post?
    @text = params[:sample_text][:markdown]
  end
end

#move_downObject




68
69
70
71
72
# File 'app/controllers/dm_cms/admin/cms_contentitems_controller.rb', line 68

def move_down
  authorize! :manage_content, @current_page
  @cms_contentitem.update_attributes(row_order_position: :down)
  redirect_to(:controller => 'dm_cms/admin/cms_pages', :action => :show, :id => @cms_contentitem.cms_page_id)
end

#move_upObject




61
62
63
64
65
# File 'app/controllers/dm_cms/admin/cms_contentitems_controller.rb', line 61

def move_up
  authorize! :manage_content, @current_page
  @cms_contentitem.update_attributes(row_order_position: :up)
  redirect_to(:controller => 'dm_cms/admin/cms_pages', :action => :show, :id => @cms_contentitem.cms_page_id)
end

#new_contentObject




10
11
12
13
14
# File 'app/controllers/dm_cms/admin/cms_contentitems_controller.rb', line 10

def new_content
  authorize! :manage_content, @current_page
  @cms_contentitem        = CmsContentitem.new
  @cms_contentitem.container  = 'body'
end

#updateObject




33
34
35
36
37
38
39
40
# File 'app/controllers/dm_cms/admin/cms_contentitems_controller.rb', line 33

def update
  authorize! :manage_content, @current_page
  if @cms_contentitem.update_attributes(cms_contentitem_params)
    redirect_to edit_admin_cms_contentitem_url(@cms_contentitem), notice: 'Content updated'
   else
    render :action => :edit, alert: 'An error of some kind occurred'
   end
end

#update_fragmentObject




50
51
52
53
54
55
56
57
58
# File 'app/controllers/dm_cms/admin/cms_contentitems_controller.rb', line 50

def update_fragment
  authorize! :manage_content, @current_page
  if @cms_contentitem.update_attributes(cms_contentitem_params)
    #@cms_page.merge!(@item.cms_page.get_page_render_values)
    #respond_to do |format| 
    #  format.js { render :action => :update_fragment } 
    #end
  end
end