Sha256: 499cc1945223cf1bd8ffc34f54bb437c55d1c5275bbae181c5bcd6228fcb5e40

Contents?: true

Size: 1.5 KB

Versions: 2

Compression:

Stored size: 1.5 KB

Contents

module CurationConcerns
  module UploadSetsControllerBehavior
    extend ActiveSupport::Concern
    include Hydra::Controller::ControllerBehavior

    included do
      include CurationConcerns::ThemedLayoutController
      with_themed_layout '1_column'

      class_attribute :edit_form_class
      self.edit_form_class = CurationConcerns::Forms::FileSetEditForm
    end

    def edit
      @upload_set = UploadSet.find_or_create(params[:id])
      @form = edit_form
    end

    def update
      authenticate_user!
      @upload_set = UploadSet.find_or_create(params[:id])
      @upload_set.status = ["processing"]
      @upload_set.save
      file_attributes = edit_form_class.model_attributes(params[:file_set])
      UploadSetUpdateJob.perform_later(current_user.user_key, params[:id], params[:title], file_attributes, params[:visibility])
      flash[:notice] = 'Your files are being processed by ' + t('curation_concerns.product_name') + ' in the background. The metadata and access controls you specified are being applied. Files will be marked <span class="label label-danger" title="Private">Private</span> until this process is complete (shouldn\'t take too long, hang in there!). You may need to refresh your dashboard to see these updates.'

      redirect_to main_app.curation_concerns_generic_works_path
    end

    protected

      def edit_form
        file_set = ::FileSet.new(creator: [current_user.user_key], title: @upload_set.file_sets.map(&:label))
        edit_form_class.new(file_set)
      end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
curation_concerns-0.3.0 app/controllers/concerns/curation_concerns/upload_sets_controller_behavior.rb
curation_concerns-0.2.0 app/controllers/concerns/curation_concerns/upload_sets_controller_behavior.rb