Class: Content::ContentViewsController

Inherits:
ApplicationController
  • Object
show all
Includes:
Foreman::Controller::AutoCompleteSearch
Defined in:
app/controllers/content/content_views_controller.rb

Instance Method Summary collapse

Instance Method Details

#createObject



33
34
35
36
37
38
39
40
# File 'app/controllers/content/content_views_controller.rb', line 33

def create
  @content_view = ContentView.new(params[:content_content_view])
  if @content_view.save
    process_success
  else
    process_error
  end
end

#destroyObject



53
54
55
56
57
58
59
# File 'app/controllers/content/content_views_controller.rb', line 53

def destroy
  if @content_view.destroy
    process_success
  else
    process_error
  end
end

#editObject



42
43
# File 'app/controllers/content/content_views_controller.rb', line 42

def edit
end

#indexObject



6
7
8
9
10
11
# File 'app/controllers/content/content_views_controller.rb', line 6

def index
  @content_views = ContentView.search_for(params[:search], :order => params[:order]).
    paginate(:page => params[:page])
  @counter       = ContentViewRepositoryClone.where(:content_view_id => @content_views.map(&:id)).group(:content_view_id).count

end

#newObject



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'app/controllers/content/content_views_controller.rb', line 16

def new
  options = if params[:product]
              {:originator_id => params[:product], :originator_type => 'Content::Product'}
            elsif params[:operatingsystem]
              {:originator_id => params[:operatingsystem], :originator_type => 'Operatingsystem'}
            elsif params[:hostgroup]
              @hostgroup = Hostgroup.find_by_id(params[:hostgroup])
              {:originator_id => params[:hostgroup], :originator_type => 'Hostgroup'}
            elsif params[:content_content_view_factory]
              params[:content_content_view_factory]
            elsif params[:type].blank?
              process_error(:error_msg => _('Must provide a type'))
            end
  @factory = ContentViewFactory.new(options || {})
  @content_view = @factory.try(:content_view) if @factory.originator_id
end

#showObject



13
14
# File 'app/controllers/content/content_views_controller.rb', line 13

def show
end

#updateObject



45
46
47
48
49
50
51
# File 'app/controllers/content/content_views_controller.rb', line 45

def update
  if @content_view.update_attributes(params[:content_content_view])
    process_success
  else
    process_error
  end
end