Sha256: 6c04e224867a764ea6a93d2203eb0b3bccc8ffdde922f248b5df44ac851e8b72

Contents?: true

Size: 930 Bytes

Versions: 8

Compression:

Stored size: 930 Bytes

Contents

module Sufia
  module GenericFile
    module Batches
      extend ActiveSupport::Concern
      included do
        belongs_to :batch, predicate: ActiveFedora::RDF::Fcrepo::RelsExt.isPartOf
      end

      # Get the files with a sibling relationship (belongs_to :batch)
      # The batch id is minted when visiting the upload screen and attached
      # to each file when it is done uploading.  The Batch object is not created
      # until all objects are done uploading and the user is redirected to
      # BatchController#edit.  Therefore, we must handle the case where
      # batch_id is set but batch returns nil.
      def related_files
        return [] unless batch
        batch.generic_files.reject { |sibling| sibling.id == id }
      end

      # Is this file in the middle of being processed by a batch?
      def processing?
         try(:batch).try(:status) == ['processing'.freeze]
      end

    end
  end
end

Version data entries

8 entries across 8 versions & 2 rubygems

Version Path
sufia-models-6.2.0 app/models/concerns/sufia/generic_file/batches.rb
sufia-models-6.1.0 app/models/concerns/sufia/generic_file/batches.rb
sufia-models-6.0.0 app/models/concerns/sufia/generic_file/batches.rb
sufia-6.0.0 sufia-models/app/models/concerns/sufia/generic_file/batches.rb
sufia-6.0.0.rc4 sufia-models/app/models/concerns/sufia/generic_file/batches.rb
sufia-models-6.0.0.rc4 app/models/concerns/sufia/generic_file/batches.rb
sufia-6.0.0.rc3 sufia-models/app/models/concerns/sufia/generic_file/batches.rb
sufia-models-6.0.0.rc3 app/models/concerns/sufia/generic_file/batches.rb