Skip to content

Commit

Permalink
Merge pull request #10 from jlsherrill/bz810378
Browse files Browse the repository at this point in the history
810378 - adding search for repos on promotion page
  • Loading branch information
ehelms committed Apr 17, 2012
2 parents 1bf3167 + cabc7d6 commit 89a5f45
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 16 deletions.
15 changes: 4 additions & 11 deletions src/app/controllers/promotions_controller.rb
Expand Up @@ -122,9 +122,6 @@ def packages


def repos
@repos = @product.repos(@environment)
@repos.sort! {|a,b| a.name <=> b.name}

@next_env_repos = []
if @next_environment
@product.repos(@next_environment).each{|repo|
Expand All @@ -133,15 +130,11 @@ def repos
end

offset = params[:offset]
if offset
render :text=>"" and return if @repos.empty?

options = {:list_partial => 'promotions/repo_items'}
render_panel_items(@repos, options, nil, offset)
else
render :partial=>"repos", :locals=>{:collection => @repos}
end
partial = offset.to_i > 0 ? 'promotions/repo_items' : 'repos'

filters = [{:product_id=>[@product.id]}, {:enabled=>[true]}, {:environment_id=>[@environment.id]}]
render_panel_direct(Repository, {:list_partial=>partial}, params[:search],
offset, [:name_sort, :ASC], {:default_field => :name, :filter=>filters})
end

def errata
Expand Down
2 changes: 1 addition & 1 deletion src/app/helpers/breadcrumb_helper.rb
Expand Up @@ -166,7 +166,7 @@ def generate_content_breadcrumb

#product_repos
add_crumb_node!(bc, repo_bc_id(prod), repos_promotion_path(@environment.name, :product_id=>prod.id, :changeset_id=>changeset_id(@changeset)),
_("Repos"), [content_crumb_id,products_crumb_id, product_id], {:scrollable=>true, :product_id => prod.id})
_("Repos"), [content_crumb_id,products_crumb_id, product_id], {:scrollable=>true, :searchable=>true, :product_id => prod.id})

#product_distributions
add_crumb_node!(bc, distribution_bc_id(prod), distributions_promotion_path(@environment.name, :product_id=>prod.id, :changeset_id=>changeset_id(@changeset)),
Expand Down
10 changes: 8 additions & 2 deletions src/app/models/repository.rb
Expand Up @@ -30,7 +30,13 @@ class Repository < ActiveRecord::Base
include Katello::Notices

index_options :extended_json=>:extended_index_attrs,
:json=>{:except=>[:pulp_repo_facts, :groupid, :environment_product_id]}
:json=>{:except=>[:pulp_repo_facts, :groupid, :feed_cert, :environment_product_id]}

mapping do
indexes :name, :type => 'string', :analyzer => :kt_name_analyzer
indexes :name_sort, :type => 'string', :index => :not_analyzed
end


after_save :update_related_index

Expand Down Expand Up @@ -105,7 +111,7 @@ def self.any_readable_in_org? org, skip_library = false

def extended_index_attrs
{:environment=>self.environment.name, :environment_id=>self.environment.id,
:product=>self.product.name, :product_id=> self.product.id}
:product=>self.product.name, :product_id=> self.product.id, :name_sort=>self.name}
end

def update_related_index
Expand Down
2 changes: 1 addition & 1 deletion src/lib/tasks/reindex.rake
@@ -1,7 +1,7 @@
task :reindex=>["environment", "clear_search_indices"] do
User.current = User.first #set a user for orchestration

ignore_list = ["CpConsumerUser", "PulpSyncStatus", "PulpTaskStatus", "Repository", "Hypervisor"]
ignore_list = ["CpConsumerUser", "PulpSyncStatus", "PulpTaskStatus", "Hypervisor"]

Dir.glob(RAILS_ROOT + '/app/models/*.rb').each { |file| require file }
models = ActiveRecord::Base.subclasses.sort{|a,b| a.name <=> b.name}
Expand Down
17 changes: 16 additions & 1 deletion src/spec/controllers/promotions_controller_spec.rb
Expand Up @@ -98,10 +98,25 @@
end

it "should be successful when requesting repos" do
controller.should_receive(:render_panel_direct) { |obj_class, options, search, start, sort, search_options|
filter = search_options[:filter]
found_product_id = false
found_enabled = false
found_environment_id = false
filter.each{|f|
found_product_id = true if f.keys.include?(:product_id)
found_enabled = true if f.keys.include?(:enabled)
found_environment_id = true if f.keys.include?(:environment_id)
}

found_product_id.should == true
found_enabled.should == true
found_environment_id.should == true
controller.stub(:render)
}
get 'repos', :id=>@env.name, :product_id => @product.id
response.should be_success
assigns(:environment).should == @env
assigns(:repos).size.should == 1
end

it "should be successful when requesting distributions" do
Expand Down

0 comments on commit 89a5f45

Please sign in to comment.