Class: Locomotive::ContentEntriesController

Inherits:
BaseController
  • Object
show all
Defined in:
app/controllers/locomotive/content_entries_controller.rb

Instance Method Summary collapse

Methods included from ActionController::Ssl

#require_ssl

Methods included from ActionController::UrlHelpers

#current_site_public_url, #public_page_url, #switch_to_site_url

Methods included from ActionController::SectionHelpers

#sections

Methods included from ActionController::LocaleHelpers

#back_to_default_site_locale, #current_content_locale, #localized?, #set_back_office_locale, #set_current_content_locale, #setup_i18n_fallbacks

Instance Method Details

#createObject



50
51
52
53
# File 'app/controllers/locomotive/content_entries_controller.rb', line 50

def create
  @content_entry = @content_type.entries.create(params[:content_entry])
  respond_with @content_entry, location: edit_content_entry_path(@content_type.slug, @content_entry._id)
end

#destroyObject



71
72
73
74
75
# File 'app/controllers/locomotive/content_entries_controller.rb', line 71

def destroy
  @content_entry = @content_type.entries.find(params[:id])
  @content_entry.destroy
  respond_with @content_entry, location: content_entries_path(@content_type.slug)
end

#editObject



55
56
57
58
# File 'app/controllers/locomotive/content_entries_controller.rb', line 55

def edit
  @content_entry = @content_type.entries.find(params[:id])
  respond_with @content_entry
end

#exportObject



30
31
32
33
34
35
36
37
38
# File 'app/controllers/locomotive/content_entries_controller.rb', line 30

def export
  @content_entries = @content_type.ordered_entries
  respond_with @content_entries, {
    filename:     @content_type.slug,
    col_sep:      ';',
    content_type: @content_type,
    host:         request.host_with_port
  }
end

#indexObject



20
21
22
23
24
25
26
27
28
# File 'app/controllers/locomotive/content_entries_controller.rb', line 20

def index
  options = { page: params[:page] || 1, per_page: Locomotive.config.ui[:per_page] }
  @content_entries = if params[:q]
    @content_type.ordered_entries(options.merge(q: params[:q]))
  else
    @content_type.list_or_group_entries(options)
  end
  respond_with @content_entries
end

#newObject



45
46
47
48
# File 'app/controllers/locomotive/content_entries_controller.rb', line 45

def new
  @content_entry = @content_type.entries.build
  respond_with @content_entry
end

#showObject



40
41
42
43
# File 'app/controllers/locomotive/content_entries_controller.rb', line 40

def show
  @content_entry = @content_type.entries.find(params[:id])
  respond_with @content_entry
end

#sortObject



66
67
68
69
# File 'app/controllers/locomotive/content_entries_controller.rb', line 66

def sort
  @content_type.klass_with_custom_fields(:entries).sort_entries!(params[:entries], @content_type.sortable_column)
  respond_with @content_type
end

#updateObject



60
61
62
63
64
# File 'app/controllers/locomotive/content_entries_controller.rb', line 60

def update
  @content_entry = @content_type.entries.find(params[:id])
  @content_entry.update_attributes(params[:content_entry])
  respond_with @content_entry, location: edit_content_entry_path(@content_type.slug, @content_entry._id)
end