Class: CamaleonCms::Admin::CategoriesController

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

Overview

Camaleon CMS is a content management system

Copyright (C) 2015 by Owen Peredo Diaz
Email: [email protected]
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



38
39
40
41
42
43
44
45
46
47
48
49
# File 'app/controllers/camaleon_cms/admin/categories_controller.rb', line 38

def create
  data_term = params[:category]
  @category = @post_type.categories.new(data_term)
  if @category.save
    @category.set_options_from_form(params[:meta])
    @category.set_field_values(params[:field_options])
    flash[:notice] = t('camaleon_cms.admin.post_type.message.created')
    redirect_to action: :index
  else
    render 'edit'
  end
end

#destroyObject



56
57
58
59
60
# File 'app/controllers/camaleon_cms/admin/categories_controller.rb', line 56

def destroy
  flash[:notice] = t('camaleon_cms.admin.post_type.message.deleted') if @category.destroy

  redirect_to action: :index
end

#editObject



23
24
25
# File 'app/controllers/camaleon_cms/admin/categories_controller.rb', line 23

def edit
  add_breadcrumb t("camaleon_cms.admin.button.edit")
end

#indexObject



14
15
16
17
18
# File 'app/controllers/camaleon_cms/admin/categories_controller.rb', line 14

def index
  @categories = @post_type.categories
  @categories = @categories.paginate(:page => params[:page], :per_page => current_site.admin_per_page)
  hooks_run("list_category", {categories: @categories, post_type: @post_type})
end

#listObject

return html category list used to reload categories list in post editor form



52
53
54
# File 'app/controllers/camaleon_cms/admin/categories_controller.rb', line 52

def list
  render inline: post_type_html_inputs(@post_type, "categories", "categories" , "checkbox" , params[:categories] || [], "categorychecklist", true )
end

#showObject



20
21
# File 'app/controllers/camaleon_cms/admin/categories_controller.rb', line 20

def show
end

#updateObject



27
28
29
30
31
32
33
34
35
36
# File 'app/controllers/camaleon_cms/admin/categories_controller.rb', line 27

def update
  if @category.update(params[:category])
    @category.set_options_from_form(params[:meta])
    @category.set_field_values(params[:field_options])
    flash[:notice] = t('camaleon_cms.admin.post_type.message.updated')
    redirect_to action: :index
  else
    render 'edit'
  end
end