Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Merge pull request #10 from jlsherrill/bz810378

810378 - adding search for repos on promotion page
  • Loading branch information...
commit 89a5f45385ab74a530f285494eeaa14fac4b8a3f 2 parents 1bf3167 + cabc7d6
@ehelms ehelms authored
View
15 src/app/controllers/promotions_controller.rb
@@ -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|
@@ -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
View
2  src/app/helpers/breadcrumb_helper.rb
@@ -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)),
View
10 src/app/models/repository.rb
@@ -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
@@ -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
View
2  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}
View
17 src/spec/controllers/promotions_controller_spec.rb
@@ -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
Please sign in to comment.
Something went wrong with that request. Please try again.