Class: CamaleonCms::Admin::PostTagsController

Inherits:
CamaleonCms::AdminController
  • Object
show all
Defined in:
app/controllers/camaleon_cms/admin/post_tags_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

render post tag create form


42
43
44
45
46
47
48
49
50
51
52
53
# File 'app/controllers/camaleon_cms/admin/post_tags_controller.rb', line 42

def create
  data_term = params[:post_tag]
  @post_tag = @post_type..new(data_term)
  if @post_tag.save
    @post_tag.set_options_from_form(params[:meta]) if params[:meta].present?
    @post_tag.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

destroy a post tag


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

def destroy
  flash[:notice] = t('camaleon_cms.admin.post_type.message.deleted') if @post_tag.destroy
  redirect_to action: :index
end

#editObject

render post tag edit form


25
26
27
# File 'app/controllers/camaleon_cms/admin/post_tags_controller.rb', line 25

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

#indexObject


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

def index
  @post_tags = @post_type.

  @post_tags = @post_tags.paginate(:page => params[:page], :per_page => current_site.admin_per_page)
end

#listObject

render a json of post tags of a post type


62
63
64
65
# File 'app/controllers/camaleon_cms/admin/post_tags_controller.rb', line 62

def list
  @post_tags = @post_type..pluck("name")
  render json: @post_tags
end

#showObject

render post tag view


21
22
# File 'app/controllers/camaleon_cms/admin/post_tags_controller.rb', line 21

def show
end

#updateObject

save changes of a post tag


30
31
32
33
34
35
36
37
38
39
# File 'app/controllers/camaleon_cms/admin/post_tags_controller.rb', line 30

def update
  if @post_tag.update(params[:post_tag])
    @post_tag.set_options_from_form(params[:meta]) if params[:meta].present?
    @post_tag.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