Class: ConstructorPages::TemplatesController

Inherits:
ConstructorCore::AdminController
  • Object
show all
Includes:
ConstructorCore::DeviseHelper
Defined in:
app/controllers/constructor_pages/templates_controller.rb

Instance Method Summary collapse

Instance Method Details

#createObject



24
25
26
27
28
29
30
31
32
# File 'app/controllers/constructor_pages/templates_controller.rb', line 24

def create
  @template = Template.new params[:template]

  if @template.save
    redirect_to templates_url, :notice => "Шаблон «#{@template.name}» успешно добавлен."
  else
    render :action => "new"
  end
end

#destroyObject



44
45
46
47
48
49
# File 'app/controllers/constructor_pages/templates_controller.rb', line 44

def destroy
  @template = Template.find(params[:id])
  name = @template.name
  @template.destroy
  redirect_to templates_url, :notice => "Шаблон «#{name}» успешно удален."
end

#editObject



20
21
22
# File 'app/controllers/constructor_pages/templates_controller.rb', line 20

def edit
  @template = Template.find(params[:id])
end

#move_downObject



61
62
63
64
65
66
67
68
69
# File 'app/controllers/constructor_pages/templates_controller.rb', line 61

def move_down
  from = Template.find(params[:id])
  rs = from.right_sibling
  if not rs.nil? and from.move_possible?(rs)
    from.move_right
  end

  redirect_to :back
end

#move_upObject



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

def move_up
  from = Template.find(params[:id])
  ls = from.left_sibling
  if not ls.nil? and from.move_possible?(ls)
    from.move_left
  end

  redirect_to :back
end

#newObject



11
12
13
14
15
16
17
18
# File 'app/controllers/constructor_pages/templates_controller.rb', line 11

def new
  @template = Template.new

  if params[:template]
    @parent = Template.find(params[:template])
    @template.parent_id = @parent.id
  end
end

#updateObject



34
35
36
37
38
39
40
41
42
# File 'app/controllers/constructor_pages/templates_controller.rb', line 34

def update
  @template = Template.find params[:id]

  if @template.update_attributes params[:template]
    redirect_to templates_url, :notice => "Шаблон «#{@template.name}» успешно обновлен."
  else
    render :action => "edit"
  end
end