6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
|
# File 'app/lib/actions/katello/product/destroy.rb', line 6
def plan(product, options = {})
organization_destroy = options.fetch(:organization_destroy, false)
unless organization_destroy || product.user_deletable?
fail _("Cannot delete a Red Hat Products or Products with Repositories published in a Content View")
end
action_subject(product)
sequence do
unless organization_destroy
concurrence do
product.repositories.in_default_view.each do |repo|
repo_options = options.clone
repo_options[:planned_destroy] = true
plan_action(Katello::Repository::Destroy, repo, repo_options)
end
end
concurrence do
plan_action(Candlepin::Product::DeletePools,
cp_id: product.cp_id, organization_label: product.organization.label)
plan_action(Candlepin::Product::DeleteSubscriptions,
cp_id: product.cp_id, organization_label: product.organization.label)
end
end
if !product.used_by_another_org? && !organization_destroy
concurrence do
product.productContent.each do |pc|
plan_action(Candlepin::Product::ContentRemove,
product_id: product.cp_id,
content_id: pc.content.id)
end
end
plan_action(Candlepin::Product::Destroy, cp_id: product.cp_id)
end
plan_self(:product_id => product.id)
end
end
|