Sha256: 1d55bef77f75abe1abbb23aacd08d6780c8b7b389e8a05889a25a2bea03977c3

Contents?: true

Size: 1.04 KB

Versions: 4

Compression:

Stored size: 1.04 KB

Contents

module Sufia
  module GenericFile
    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
        Sufia.queue.push(ContentDepositorChangeEventJob.new(id, 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!(generic_file_id: id, receiving_user: target, sending_user: deposit_user)
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 2 rubygems

Version Path
sufia-models-6.2.0 app/models/concerns/sufia/generic_file/proxy_deposit.rb
sufia-models-6.1.0 app/models/concerns/sufia/generic_file/proxy_deposit.rb
sufia-models-6.0.0 app/models/concerns/sufia/generic_file/proxy_deposit.rb
sufia-6.0.0 sufia-models/app/models/concerns/sufia/generic_file/proxy_deposit.rb