Sha256: 5d79b5c76d81490685c3bdb4c19f4ba863afaf248c501f2cb93c761f3febdfe9

Contents?: true

Size: 1.03 KB

Versions: 16

Compression:

Stored size: 1.03 KB

Contents

module Sufia
  module ProxyDeposit
    extend ActiveSupport::Concern

    included do
      property :proxy_depositor, predicate: ::RDF::URI.new('http://scholarsphere.psu.edu/ns#proxyDepositor'), multiple: false do |index|
        index.as :symbol
      end

      # This value is set when a user indicates they are depositing this for someone else
      property :on_behalf_of, predicate: ::RDF::URI.new('http://scholarsphere.psu.edu/ns#onBehalfOf'), multiple: false do |index|
        index.as :symbol
      end

      after_create :create_transfer_request
    end

    def create_transfer_request
      ContentDepositorChangeEventJob.perform_later(self,
                                                   ::User.find_by_user_key(on_behalf_of)) if on_behalf_of.present?
    end

    def request_transfer_to(target)
      raise ArgumentError, "Must provide a target" unless target
      deposit_user = ::User.find_by_user_key(depositor)
      ProxyDepositRequest.create!(work_id: id, receiving_user: target, sending_user: deposit_user)
    end
  end
end

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
sufia-7.4.1 app/models/concerns/sufia/proxy_deposit.rb
sufia-7.4.0 app/models/concerns/sufia/proxy_deposit.rb
sufia-7.3.1 app/models/concerns/sufia/proxy_deposit.rb
sufia-7.3.0 app/models/concerns/sufia/proxy_deposit.rb
sufia-7.3.0.rc3 app/models/concerns/sufia/proxy_deposit.rb
sufia-7.3.0.rc2 app/models/concerns/sufia/proxy_deposit.rb
sufia-7.3.0.rc1 app/models/concerns/sufia/proxy_deposit.rb
sufia-7.2.0 app/models/concerns/sufia/proxy_deposit.rb
sufia-7.1.0 app/models/concerns/sufia/proxy_deposit.rb
sufia-7.0.0 app/models/concerns/sufia/proxy_deposit.rb
sufia-7.0.0.rc2 app/models/concerns/sufia/proxy_deposit.rb
sufia-7.0.0.rc1 app/models/concerns/sufia/proxy_deposit.rb
sufia-7.0.0.beta4 app/models/concerns/sufia/proxy_deposit.rb
sufia-7.0.0.beta3 app/models/concerns/sufia/proxy_deposit.rb
sufia-7.0.0.beta2 app/models/concerns/sufia/proxy_deposit.rb
sufia-7.0.0.beta1 app/models/concerns/sufia/proxy_deposit.rb