Class: Admin::BlocksController

Inherits:
AdminController
  • Object
show all
Defined in:
app/controllers/admin/blocks_controller.rb

Instance Method Summary collapse

Instance Method Details

#createObject



20
21
22
23
24
25
26
27
28
29
# File 'app/controllers/admin/blocks_controller.rb', line 20

def create
  params[:block][:system_id] = _sid
  @block = Block.new(params[:block])
  @block.user_id = current_user.id
  if @block.save
    redirect_to [:admin, @block], :notice => "Successfully created block"
  else
    render :action => 'new'
  end
end

#destroyObject



54
55
56
57
58
59
# File 'app/controllers/admin/blocks_controller.rb', line 54

def destroy
  Activity.add(_sid, "Deleted block '#{@block.name}'", current_user.id, "Block")
  @block = Block.find_sys_id(_sid, params[:id])
  @block.destroy
  redirect_to admin_blocks_url, :notice => "Successfully destroyed block"
end

#editObject



31
32
33
# File 'app/controllers/admin/blocks_controller.rb', line 31

def edit
  @block = Block.find_sys_id(_sid,params[:id])
end

#indexObject



4
5
6
7
8
9
# File 'app/controllers/admin/blocks_controller.rb', line 4

def index
  logger.debug "*****************************************" * 5
  @blocks = Block.sys(_sid).order(:name)
  @blocks = @blocks.where('name like "%' + params[:for] + '%" or body like "%' + params[:for] + '%" or description like "%' + params[:for] + '%"') if params[:for].not_blank?
  @blocks = @blocks.page(params[:page]).per(25)
end

#newObject



16
17
18
# File 'app/controllers/admin/blocks_controller.rb', line 16

def new
  @block = Block.new
end

#showObject



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

def show
  @block = Block.find_sys_id(_sid,params[:id])
end

#updateObject



35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# File 'app/controllers/admin/blocks_controller.rb', line 35

def update
  @block = Block.find_sys_id(_sid,params[:id])
  @block.user_id = current_user.id

  if @block.update_attributes(params[:block])
    Activity.add(_sid, "Update block '#{@block.name}'", current_user.id, "Block")

    if params[:submit_button]=="save-and-edit-again"
      redirect_to "/admin/blocks/#{@block.id}/edit#editor"
    else
      redirect_to "/admin/blocks/#{@block.id}"
    end
    
    return
  else
    render :action => 'edit'
  end
end