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

Inherits:
CamaleonCms::Admin::SettingsController show all
Defined in:
app/controllers/camaleon_cms/admin/settings/sites_controller.rb

Instance Method Summary collapse

Methods inherited from CamaleonCms::Admin::SettingsController

#languages, #save_languages, #save_theme, #shortcodes, #site, #site_saved, #test_email, #theme

Methods inherited from CamaleonCms::AdminController

#ajax, #cama_get_i18n_frontend, #dashboard, #search

Instance Method Details

#createObject



45
46
47
48
49
50
51
52
53
54
55
# File 'app/controllers/camaleon_cms/admin/settings/sites_controller.rb', line 45

def create
  @site = CamaleonCms::Site.new(site_params)
  if @site.save
    save_metas(@site)
    site_after_install(@site, @site.get_theme_slug)
    flash[:notice] = site_created_notice(@site)
    redirect_to action: :index
  else
    new
  end
end

#destroyObject



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

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

#editObject



19
20
21
22
# File 'app/controllers/camaleon_cms/admin/settings/sites_controller.rb', line 19

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

#indexObject



9
10
11
12
13
14
15
# File 'app/controllers/camaleon_cms/admin/settings/sites_controller.rb', line 9

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



39
40
41
42
43
# File 'app/controllers/camaleon_cms/admin/settings/sites_controller.rb', line 39

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

#showObject



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

def show; end

#updateObject



24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'app/controllers/camaleon_cms/admin/settings/sites_controller.rb', line 24

def update
  tmp = @site.slug
  if @site.update(site_params)
    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(cama_admin_path)
    else
      redirect_to action: :index
    end
  else
    edit
  end
end