Sha256: 780f33be24cfb2f4b6c8e27f42a3cbecbb68857f5706aa66b7d23d7f524a765b

Contents?: true

Size: 1.21 KB

Versions: 5

Compression:

Stored size: 1.21 KB

Contents

# encoding: utf-8

module ConstructorPages
  class TemplatesController < ConstructorCore::ApplicationController
    include MoveHelper

    before_filter {@roots = Template.roots}

    def new
      @template = Template.new

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

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

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

      if @template.save
        redirect_to templates_url, notice: t(:template_success_added, name: @template.name)
      else
        render action: :new
      end
    end

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

      if @template.update_attributes params[:template]
        redirect_to templates_url, notice: t(:template_success_updated, name: @template.name)
      else
        render action: :edit
      end
    end

    def destroy
      @template = Template.find(params[:id])
      name = @template.name
      @template.destroy
      redirect_to templates_url, notice: t(:template_success_removed, name: name)
    end

    %w{up down}.each {|m| define_method "move_#{m}" do move_to :template, m.to_sym end}
  end
end

Version data entries

5 entries across 5 versions & 2 rubygems

Version Path
constructor-pages-0.5.8 app/controllers/constructor_pages/templates_controller.rb
constructor-cms-0.5.8 pages/app/controllers/constructor_pages/templates_controller.rb
constructor-pages-0.5.7 app/controllers/constructor_pages/templates_controller.rb
constructor-pages-0.5.6 app/controllers/constructor_pages/templates_controller.rb
constructor-pages-0.5.5 app/controllers/constructor_pages/templates_controller.rb