app/models/katello/task_status.rb in katello-3.1.0.1 vs app/models/katello/task_status.rb in katello-3.2.0.rc1
- old
+ new
@@ -18,12 +18,10 @@
belongs_to :organization, :inverse_of => :task_statuses, :class_name => "Organization"
belongs_to :user, :inverse_of => :task_statuses, :class_name => "::User"
belongs_to :task_owner, :polymorphic => true
- # adding belongs_to :system allows us to perform joins with the owning system, if there is one
- belongs_to :system, :foreign_key => :task_owner_id, :class_name => "Katello::System", :inverse_of => :task_statuses
# needed to delete providers w/ task status
has_one :provider, :class_name => "Katello::Provider", :dependent => :nullify
validates_lengths_from_database
@@ -107,38 +105,20 @@
def refresh_pulp
PulpTaskStatus.refresh(self)
end
- def as_json(_options = {})
- json = super :methods => :pending?
-
- if ('Katello::System' == task_owner_type)
- methods = [:description, :result_description, :overall_status]
- json.merge!(super(:only => methods, :methods => methods))
- json[:system_name] = task_owner.name
- end
-
- json
- end
-
def human_readable_message
task_template = TaskStatus::TYPES[self.task_type]
return '' if task_template.nil?
if task_template[:user_message]
task_template[:user_message] % self.user.login
else
task_template[:english_name]
end
end
- # used by search to filter tasks by systems :)
- def system_filter_clause
- system_id = task_owner_id if (task_owner_type == 'Katello::System')
- {:system_id => system_id}
- end
-
def pending_message
# Retrieve a text message that may be rendered for a 'pending' task's status. This is used in various places,
# such as System Event history.
details = TaskStatus::TYPES[self.task_type]
case details[:type]
@@ -218,17 +198,17 @@
TaskStatus::TYPES[self.task_type][:name]
end
def humanize_parameters
humanized_parameters = []
- if packages = self.parameters[:packages]
+ if (packages = self.parameters[:packages])
humanized_parameters.concat(packages)
end
- if groups = self.parameters[:groups]
+ if (groups = self.parameters[:groups])
humanized_parameters.concat(groups.map { |g| g =~ /^@/ ? g : "@#{g}" })
end
- if errata = self.parameters[:errata_ids]
+ if (errata = self.parameters[:errata_ids])
humanized_parameters.concat(errata)
end
humanized_parameters.join(", ")
end
@@ -304,22 +284,9 @@
ret = Katello.pulp_server.resources.task.poll_all(uuids)
ret.each do |pulp_task|
PulpTaskStatus.dump_state(pulp_task, TaskStatus.find_by(:uuid => pulp_task[:task_id]))
end
end
- end
-
- def self.make(system, pulp_task, task_type, parameters)
- task_status = PulpTaskStatus.new(
- :organization => system.organization,
- :task_owner => system,
- :task_type => task_type,
- :parameters => parameters,
- :systems => [system]
- )
- task_status.merge_pulp_task!(pulp_task)
- task_status.save!
- task_status
end
protected
def setup_task_type