Sha256: 8a4d90a324b3593e7a83b1ae7f05ab92c704181cbf0d96185b00b89fec11a2af

Contents?: true

Size: 991 Bytes

Versions: 62

Compression:

Stored size: 991 Bytes

Contents

module Sufia
  module ModelMethods
    extend ActiveSupport::Concern

    included do
      include Hydra::ModelMethods
    end

    # OVERRIDE to support Hydra::Datastream::Properties which does not
    #   respond to :depositor_values but :depositor
    # Adds metadata about the depositor to the asset
    # Most important behavior: if the asset has a rightsMetadata datastream, this method will add +depositor_id+ to its individual edit permissions.

    def apply_depositor_metadata(depositor)
      rights_ds = self.datastreams["rightsMetadata"]
      prop_ds = self.datastreams["properties"]
      depositor_id = depositor.respond_to?(:user_key) ? depositor.user_key : depositor

      rights_ds.update_indexed_attributes([:edit_access, :person]=>depositor_id) unless rights_ds.nil?
      prop_ds.depositor = depositor_id unless prop_ds.nil?

      return true
    end

    def to_s
      return Array(title).join(" | ") if title.present?
      label || "No Title"
    end

  end
end

Version data entries

62 entries across 62 versions & 2 rubygems

Version Path
sufia-5.0.0 sufia-models/app/models/concerns/sufia/model_methods.rb
sufia-models-5.0.0 app/models/concerns/sufia/model_methods.rb
sufia-5.0.0.rc1 sufia-models/app/models/concerns/sufia/model_methods.rb
sufia-models-5.0.0.rc1 app/models/concerns/sufia/model_methods.rb
sufia-4.3.1 sufia-models/app/models/concerns/sufia/model_methods.rb
sufia-models-4.3.1 app/models/concerns/sufia/model_methods.rb
sufia-4.2.0 sufia-models/app/models/concerns/sufia/model_methods.rb
sufia-models-4.2.0 app/models/concerns/sufia/model_methods.rb
sufia-4.1.0 sufia-models/app/models/concerns/sufia/model_methods.rb
sufia-models-4.1.0 app/models/concerns/sufia/model_methods.rb
sufia-4.0.1 sufia-models/app/models/concerns/sufia/model_methods.rb
sufia-models-4.0.1 app/models/concerns/sufia/model_methods.rb
sufia-models-4.0.0 app/models/concerns/sufia/model_methods.rb
sufia-4.0.0 sufia-models/app/models/concerns/sufia/model_methods.rb
sufia-4.0.0.rc2 sufia-models/app/models/concerns/sufia/model_methods.rb
sufia-models-4.0.0.rc2 app/models/concerns/sufia/model_methods.rb
sufia-4.0.0.rc1 sufia-models/lib/sufia/models/model_methods.rb
sufia-models-4.0.0.rc1 lib/sufia/models/model_methods.rb
sufia-4.0.0.beta4 sufia-models/lib/sufia/models/model_methods.rb
sufia-models-4.0.0.beta4 lib/sufia/models/model_methods.rb