Class: CamaleonCms::Admin::Settings::SitesController

Inherits:
CamaleonCms::Admin::SettingsController
  • Object
show all
Defined in:
app/controllers/camaleon_cms/admin/settings/sites_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



51
52
53
54
55
56
57
58
59
60
61
62
# File 'app/controllers/camaleon_cms/admin/settings/sites_controller.rb', line 51

def create
  site_data = params[:site]
  @site = CamaleonCms::Site.new(site_data)
  if @site.save
    save_metas(@site)
    site_after_install(@site, @site.get_theme_slug)
    flash[:notice] = t('camaleon_cms.admin.sites.message.created')
    redirect_to action: :index
  else
    new
  end
end

#destroyObject



64
65
66
67
# File 'app/controllers/camaleon_cms/admin/settings/sites_controller.rb', line 64

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

#editObject



25
26
27
28
# File 'app/controllers/camaleon_cms/admin/settings/sites_controller.rb', line 25

def edit
  add_breadcrumb I18n.t("camaleon_cms.admin.button.edit")
  render 'form'
end

#indexObject



14
15
16
17
18
19
20
# File 'app/controllers/camaleon_cms/admin/settings/sites_controller.rb', line 14

def index
  @sites = CamaleonCms::Site.all.order(:term_group)
  @sites = @sites.paginate(:page => params[:page], :per_page => current_site.admin_per_page)
  r = { sites: @sites, render: "index" }
  hooks_run("list_site", r)
  render r[:render]
end

#newObject



45
46
47
48
49
# File 'app/controllers/camaleon_cms/admin/settings/sites_controller.rb', line 45

def new
  add_breadcrumb I18n.t("camaleon_cms.admin.button.new")
  @site ||= CamaleonCms::Site.new.decorate
  render 'form'
end

#showObject



22
23
# File 'app/controllers/camaleon_cms/admin/settings/sites_controller.rb', line 22

def show
end

#updateObject



30
31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'app/controllers/camaleon_cms/admin/settings/sites_controller.rb', line 30

def update
  tmp = @site.slug
  if @site.update(params[:site])
    save_metas(@site)
    flash[:notice] = t('camaleon_cms.admin.sites.message.updated')
    if @site.id == Cama::Site.main_site.id && tmp != @site.slug
      redirect_to @site.the_admin_url
    else
      redirect_to action: :index
    end
  else
    edit
  end
end