Class: WorksWizardNewSubmissionController

Inherits:
ApplicationController show all
Defined in:
app/controllers/works_wizard_new_submission_controller.rb

Overview

Controller to handle the policy agreement acknowlegdement before the wizard is started

The wizard flow is shown in the mermaid diagram here.

Instance Method Summary collapse

Methods inherited from ApplicationController

#new_session_path

Instance Method Details

#new_submissionObject

get Renders the "step 0" information page before creating a new dataset GET /works/1/new_submission



17
18
19
20
# File 'app/controllers/works_wizard_new_submission_controller.rb', line 17

def new_submission
  @work = WorkMetadataService.new(params:, current_user:).work_for_new_submission
  prepare_decorators_for_work_form(@work)
end

#new_submission_deleteObject

GET /works/1/new-submission-delete



36
37
38
39
40
41
# File 'app/controllers/works_wizard_new_submission_controller.rb', line 36

def new_submission_delete
  if @work.editable_by?(current_user) && @work.none?
    @work.destroy
  end
  redirect_to user_path(current_user)
end

#new_submission_saveObject

Creates the new dataset or update the dataset is save only was done previously POST /works/new_submission or POST /works/1/new_submission



24
25
26
27
28
29
30
31
32
33
# File 'app/controllers/works_wizard_new_submission_controller.rb', line 24

def new_submission_save
  @work = WorkMetadataService.new(params:, current_user:).new_submission
  @errors = @work.errors.to_a
  if @errors.count.positive?
    prepare_decorators_for_work_form(@work)
    render :new_submission
  else
    redirect_to edit_work_wizard_path(@work)
  end
end