Class: Admin::StaticContentBlocksController

Inherits:
BaseController
  • Object
show all
Defined in:
app/controllers/admin/static_content_blocks_controller.rb

Instance Method Summary collapse

Instance Method Details

#createObject



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

def create
  if @static_content_block.save
    flash[:notice] = I18n.t('block.create.success').capitalize
    redirect_to([forgeos_cms, :edit, :admin, @static_content_block])
  else
    flash[:error] = I18n.t('static_content_block.create.failed').capitalize
    render :action => "new"
  end
end

#destroyObject



51
52
53
54
55
56
57
58
59
# File 'app/controllers/admin/static_content_blocks_controller.rb', line 51

def destroy
  if @static_content_block.destroy
    flash[:notice] = I18n.t('static_content_block.destroy.success').capitalize
  else
    flash[:error] = @static_content_block.errors if @static_content_block
    flash[:error] = I18n.t('static_content_block.destroy.failed').capitalize
  end
  redirect_to([forgeos_cms, :admin, :static_content_blocks])
end

#duplicateObject



24
25
26
27
# File 'app/controllers/admin/static_content_blocks_controller.rb', line 24

def duplicate
  @static_content_block = @static_content_block.clone
  render :action => 'new'
end

#editObject



29
30
# File 'app/controllers/admin/static_content_blocks_controller.rb', line 29

def edit
end

#indexObject



8
9
10
11
12
13
14
15
16
# File 'app/controllers/admin/static_content_blocks_controller.rb', line 8

def index
  respond_to do |format|
    format.html
    format.json do
      sort
      render :layout => false
    end
  end
end


61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
# File 'app/controllers/admin/static_content_blocks_controller.rb', line 61

def link
  unless @static_content_block.linked_with? @page
    if @static_content_block.link_with @page
      flash[:notice] = I18n.t('static_content_block.link.create.success').capitalize
    else
      flash[:error] = I18n.t('static_content_block.link.create.failed').capitalize
    end
  else
    if @static_content_block.unlink_with @page
      flash[:notice] = I18n.t('static_content_block.link.destroy.success').capitalize
    else
      flash[:error] = I18n.t('static_content_block.link.destroy.success').capitalize
    end
  end

  if request.xhr?
    return render :text => true
  else
    return redirect_to(:back)
  end
end

#newObject



21
22
# File 'app/controllers/admin/static_content_blocks_controller.rb', line 21

def new
end

#showObject



18
19
# File 'app/controllers/admin/static_content_blocks_controller.rb', line 18

def show
end


83
84
85
86
87
88
89
90
91
92
# File 'app/controllers/admin/static_content_blocks_controller.rb', line 83

def unlink
  if @page.blocks.delete(@static_content_block)
    @page.blocks.reset_positions
    flash[:notice] = I18n.t('static_content_block.link.destroy.success').capitalize
  else
    flash[:notice] = I18n.t('static_content_block.link.destroy.success').capitalize
  end

  render :nothing => true
end

#updateObject



42
43
44
45
46
47
48
49
# File 'app/controllers/admin/static_content_blocks_controller.rb', line 42

def update
  if @static_content_block.update_attributes(params[:static_content_block])
    flash[:notice] = I18n.t('static_content_block.update.success').capitalize
  else
    flash[:error] = I18n.t('static_content_block.update.failed').capitalize
  end
  render :action => "edit"
end