Skip to content

Commit

Permalink
Promotion Search - Adds proper checks when there is no next environment
Browse files Browse the repository at this point in the history
for listing promotable packages.
  • Loading branch information
ehelms committed Jan 30, 2012
1 parent f556b01 commit 880e5a2
Showing 1 changed file with 22 additions and 19 deletions.
41 changes: 22 additions & 19 deletions src/app/controllers/promotions_controller.rb
Expand Up @@ -73,38 +73,41 @@ def new_packages

@promotable_packages = []
@not_promotable = []
next_env_repos = Product.find(product_id).repos(@next_environment)

search = params[:search]
search = "*" if search.nil? || search == ''
offset = params[:offset] || 0
@packages = Glue::Pulp::Package.search(search, params[:offset], current_user.page_size, repo_ids)
render :text=>"" and return if @packages.empty?

@packages.each{ |pack|
promoted = true
promotable = false
repos.each{ |repo|
if pack.repoids.include? repo.pulp_id
if repo.is_cloned_in? @next_environment
if pack.repoids.include? repo.clone_id(@next_environment)
promoted = promoted && true
if not @next_environment.nil?
@packages.each{ |pack|
promoted = true
promotable = false
repos.each{ |repo|
if pack.repoids.include? repo.pulp_id
if repo.is_cloned_in? @next_environment
if pack.repoids.include? repo.clone_id(@next_environment)
promoted = promoted && true
else
promotable = true
promoted = false
end
else
promotable = true
promoted = false
promotable = promotable || false
end
else
promoted = false
promotable = promotable || false
end
}
if promotable && !promoted
@promotable_packages << pack.id
elsif !promoted && !promotable
@not_promotable << pack.id
end
}
if promotable && !promoted
@promotable_packages << pack.id
elsif !promoted && !promotable
@not_promotable << pack.id
end
}
else
@not_promotable = @packages.collect{ |pack| pack.id }
end

options = {:list_partial => 'promotions/package_items'}

Expand Down

0 comments on commit 880e5a2

Please sign in to comment.