Class: WorksWizardPolicyController

Inherits:
ApplicationController show all
Defined in:
app/controllers/works_wizard_policy_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](github.com/pulibrary/pdc_describe/blob/main/docs/wizard_flow.md).

Instance Method Summary collapse

Methods inherited from ApplicationController

#new_session_path

Instance Method Details

#showObject

get /works/policy



12
# File 'app/controllers/works_wizard_policy_controller.rb', line 12

def show; end

#updateObject

post /works/policy



15
16
17
18
19
20
21
22
23
24
# File 'app/controllers/works_wizard_policy_controller.rb', line 15

def update
  group = Group.find_by(code: params[:group_code]) || current_user.default_group
  if params[:agreement] == "1"
    work = Work.create!(created_by_user_id: current_user.id, group:)
    work.add_provenance_note(DateTime.now, "User agreed to the Data Acceptance and Retention policy", current_user.id)
    redirect_to work_create_new_submission_path(work)
  else
    redirect_to root_path, notice: "You must agree to the policy to deposit"
  end
end