Class: Admin::LayoutsController

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

Instance Method Summary collapse

Instance Method Details

#createObject



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'app/controllers/admin/layouts_controller.rb', line 9

def create
  @layout = Layout.new(params[:layout])
  @layout.locale = 'en'
  @layout.handler = 'haml'
  @layout.format = 'html'
  @layout.path = '.'
  @layout.partial = 0
  @layout.system_id = _sid
  @layout.body = <<DOC
!!!
/ Layout: #{@layout.name}
%html
%head
  = render :partial=>"layouts/kit_header"
  %style(type="text/css")
    div#edit_link { top:30px; }
%body
  = yield
DOC
  @layout.user_id = current_user.id
  @layout.save
  Activity.add(_sid, "Created layout '#{@layout.name}'", current_user.id, "Layout")
  redirect_to "/admin/layouts"
end

#destroyObject



48
49
50
51
52
53
# File 'app/controllers/admin/layouts_controller.rb', line 48

def destroy
  @layout = Layout.find_sys_id(_sid, params[:id])
  Activity.add(_sid, "Deleted layout '#{@layout.name}'", current_user.id, "Layout")
  Layout.destroy(params[:id])
  redirect_to "/admin/layouts"
end

#indexObject



3
4
5
6
7
# File 'app/controllers/admin/layouts_controller.rb', line 3

def index
  @layouts = Layout.sys(_sid).order(:name).page(params[:page]).per(50)

  @layout = Layout.new
end

#showObject



34
35
36
# File 'app/controllers/admin/layouts_controller.rb', line 34

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

#updateObject



38
39
40
41
42
43
44
45
46
# File 'app/controllers/admin/layouts_controller.rb', line 38

def update 
  @layout = Layout.find_sys_id(_sid, params[:id])
  if @layout.update_attributes(params[:layout])
    Activity.add(_sid, "Updated layout '#{@layout.name}'", current_user.id, "Layout")
    redirect_to "/admin/layouts"
  else
    render "show"
  end
end