Skip to content

Commit

Permalink
feat: ask for registration when base product is missing
Browse files Browse the repository at this point in the history
  • Loading branch information
imobachgs committed Jan 23, 2025
1 parent 250cec6 commit 3e07fd9
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
3 changes: 1 addition & 2 deletions service/lib/agama/dbus/software/product.rb
Original file line number Diff line number Diff line change
Expand Up @@ -180,8 +180,6 @@ def register(reg_code, email: nil)
[1, "Product not selected yet"]
elsif backend.registration.reg_code
[2, "Product already registered"]
elsif !backend.product.registration
[3, "Product does not support registration"]
else
connect_result(first_error_code: 4) do
backend.registration.register(reg_code, email: email)
Expand Down Expand Up @@ -254,6 +252,7 @@ def register_callbacks
# software related issues.
backend.registration.on_change { issues_properties_changed }
backend.registration.on_change { registration_properties_changed }
backend.on_issues_change { issues_properties_changed }
end

def registration_properties_changed
Expand Down
14 changes: 13 additions & 1 deletion service/lib/agama/software/manager.rb
Original file line number Diff line number Diff line change
Expand Up @@ -589,6 +589,7 @@ def missing_product_issue
# @return [Agama::Issue]
def missing_registration_issue
Issue.new(_("Product must be registered"),
kind: :missing_registration,
source: Issue::Source::SYSTEM,
severity: Issue::Severity::ERROR)
end
Expand All @@ -597,8 +598,19 @@ def missing_registration_issue
#
# @return [Boolean]
def missing_registration?
return false unless product

registration.reg_code.nil? &&
registration.requirement == Agama::Registration::Requirement::MANDATORY
product.registration &&
missing_base_product?
end

# Whether the base product is missing
#
# @return [Boolean]
def missing_base_product?
products = Y2Packager::Resolvable.find(kind: :product, name: product.name)
products.empty?
end

def pattern_exist?(pattern_name)
Expand Down

0 comments on commit 3e07fd9

Please sign in to comment.