Class: CamaleonCms::Admin::Appearances::Widgets::MainController

Inherits:
CamaleonCms::AdminController
  • Object
show all
Defined in:
app/controllers/camaleon_cms/admin/appearances/widgets/main_controller.rb

Overview

Camaleon CMS is a content management system

Copyright (C) 2015 by Owen Peredo Diaz
Email: owenperedo@gmail.com
This program is free software: you can redistribute it and/or modify   it under the terms of the GNU Affero General Public License as  published by the Free Software Foundation, either version 3 of the  License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,  but WITHOUT ANY WARRANTY; without even the implied warranty of  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
See the  GNU Affero General Public License (GPLv3) for more details.

Instance Method Summary collapse

Instance Method Details

#createObject


28
29
30
31
32
33
34
35
36
37
# File 'app/controllers/camaleon_cms/admin/appearances/widgets/main_controller.rb', line 28

def create
  params[:widget_main][:status] = "simple"
  @widget = current_site.widgets.new(params[:widget_main])
  if @widget.save!
    flash[:notice] = t('camaleon_cms.admin.widgets.message.created')
  else
    flash[:error] = t('camaleon_cms.admin.widgets.message.error_created')
  end
  redirect_to action: :index
end

#destroyObject


48
49
50
51
52
# File 'app/controllers/camaleon_cms/admin/appearances/widgets/main_controller.rb', line 48

def destroy
  @widget = @widget.destroy!
  flash[:notice] = t('camaleon_cms.admin.widgets.message.deleted')
  redirect_to action: :index
end

#editObject


24
25
26
# File 'app/controllers/camaleon_cms/admin/appearances/widgets/main_controller.rb', line 24

def edit
  new
end

#indexObject


15
16
17
# File 'app/controllers/camaleon_cms/admin/appearances/widgets/main_controller.rb', line 15

def index
  @widgets = current_site.widgets
end

#newObject


19
20
21
22
# File 'app/controllers/camaleon_cms/admin/appearances/widgets/main_controller.rb', line 19

def new
  @widget ||= current_site.widgets.new
  render "form", layout: false
end

#updateObject


39
40
41
42
43
44
45
46
# File 'app/controllers/camaleon_cms/admin/appearances/widgets/main_controller.rb', line 39

def update
  if @widget.update!(params[:widget_main])
    flash[:notice] = t('camaleon_cms.admin.widgets.message.updated')
  else
    flash[:error] = t('camaleon_cms.admin.widgets.message.error_updated')
  end
  redirect_to action: :index
end