Class: Content::RepositoriesController

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

Instance Method Summary collapse

Instance Method Details

#createObject



22
23
24
25
26
27
28
29
# File 'app/controllers/content/repositories_controller.rb', line 22

def create
  @repository = Repository.new(params[:content_repository])
  if @repository.save
    process_success
  else
    process_error
  end
end

#destroyObject



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

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

#editObject



31
32
# File 'app/controllers/content/repositories_controller.rb', line 31

def edit
end

#indexObject



6
7
8
9
# File 'app/controllers/content/repositories_controller.rb', line 6

def index
  @repositories = Repository.search_for(params[:search], :order => params[:order]).
    paginate(:page => params[:page])
end

#newObject



11
12
13
14
15
16
17
18
19
20
# File 'app/controllers/content/repositories_controller.rb', line 11

def new
  @repository = case params[:type]
                when "operatingsystem"
                  Repository::OperatingSystem.new(:unprotected => true)
                when "product"
                  Repository::Product.new(:originator_id => params[:product_id])
                else
                  not_found
                end
end

#showObject



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

def show
end

#syncObject



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

def sync
  @repository.sync
  process_success(:success_msg => _("Successfully started sync for %s") % @repository.to_label)
rescue => e
  process_error(:error_msg => _("Failed to start sync for %s") % @repository.to_label)
end

#updateObject



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

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