Sha256: 9e5db18d354c1decf3fced024d0f4c8088c143c5414f03e7839dabd924c0a67a

Contents?: true

Size: 1.37 KB

Versions: 1

Compression:

Stored size: 1.37 KB

Contents

module CurationConcerns
  class UploadSetForm
    include HydraEditor::Form

    self.terms = CurationConcerns::GenericWorkForm.terms

    delegate :creator, :human_readable_type, :open_access?, :authenticated_only_access?,
             :open_access_with_embargo_release_date?, :private_access?,
             :embargo_release_date, :lease_expiration_date, :member_ids, to: :exemplar_work

    def initialize(upload_set, current_ability)
      @current_ability = current_ability
      super(upload_set)
      # TODO: instead of using GenericWorkForm, this should be an UploadSetForm
      # work = ::GenericWork.new(creator: [creator_display], title: titles)
    end

    def exemplar_work
      @exemplar_work ||= GenericWork.new(creator: [creator_display])
    end

    # @return [Array] a list of the first titles for each of the works.
    def works
      @works ||= model.works.sort { |w1, w2| w1.title.first.downcase <=> w2.title.first.downcase }
    end

    def self.model_attributes(attrs)
      CurationConcerns::GenericWorkForm.model_attributes(attrs)
    end

    def self.multiple?(attrs)
      CurationConcerns::GenericWorkForm.multiple?(attrs)
    end

    private

      # Override this method if you want the creator to display something other than
      # the user_key, e.g. "current_user.name"
      def creator_display
        @current_ability.current_user.user_key
      end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
curation_concerns-0.4.0 app/forms/curation_concerns/upload_set_form.rb