Sha256: a5200c7f3ccb20731ef77a02729527d3b77d2820ad16878b3de9aa8c8421700d

Contents?: true

Size: 1.29 KB

Versions: 9

Compression:

Stored size: 1.29 KB

Contents

module Actions
  module Pulp
    module Repository
      module Presenters
        class AbstractSyncPresenter < Helpers::Presenter::Base
          # TODO: in Rails 4.0, the logic is possible to use from ActiveSupport
          include ActionView::Helpers::NumberHelper

          def humanized_output
            if action.external_task
              humanized_details
            end
          end

          private

          def humanized_details
            fail NotImplementedError
          end

          def sync_task
            tasks = action.external_task.select do |task|
              if task.key? 'tags'
                task['tags'].include?("pulp:action:sync")
              else
                # workaround for https://bugzilla.redhat.com/show_bug.cgi?id=1131537
                # as the sync plan tasks don't have tags in pulp
                task['result'] &&
                    task['result']['importer_type_id'].to_s =~ /_importer$/
              end
            end
            tasks.first
          end

          def cancelled?
            sync_task['state'] == 'canceled'
          end

          def task_result
            sync_task['result']
          end

          def task_result_details
            task_result && task_result['details']
          end
        end
      end
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
katello-2.4.5 app/lib/actions/pulp/repository/presenters/abstract_sync_presenter.rb
katello-2.4.4 app/lib/actions/pulp/repository/presenters/abstract_sync_presenter.rb
katello-2.4.3 app/lib/actions/pulp/repository/presenters/abstract_sync_presenter.rb
katello-2.4.2 app/lib/actions/pulp/repository/presenters/abstract_sync_presenter.rb
katello-2.4.1 app/lib/actions/pulp/repository/presenters/abstract_sync_presenter.rb
katello-2.4.0 app/lib/actions/pulp/repository/presenters/abstract_sync_presenter.rb
katello-2.4.0.rc3 app/lib/actions/pulp/repository/presenters/abstract_sync_presenter.rb
katello-2.4.0.rc2 app/lib/actions/pulp/repository/presenters/abstract_sync_presenter.rb
katello-2.4.0.rc1 app/lib/actions/pulp/repository/presenters/abstract_sync_presenter.rb