Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DCC Bug 711 - Fix for broken creation of a Plan using the V0 API. #3135

Merged
merged 4 commits into from
Mar 31, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions app/controllers/api/v0/base_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,10 @@ def page_params
params.permit(:page, :per_page)
end

def plan_params
params.permit(:template_id, :plan[:title], :plan[:email])
end

# The resource class based on the controller
#
# Returns Object
Expand Down
4 changes: 3 additions & 1 deletion app/controllers/api/v0/plans_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ def create

# initialize the plan
@plan = Plan.new
@plan.org = @user.org

# Attach the user as the PI and Data Contact
@plan.contributors << Contributor.new(
Expand All @@ -48,8 +49,9 @@ def create
end
@plan.template = @template
@plan.title = params[:plan][:title]

if @plan.save
@plan.assign_creator(plan_user)
@plan.add_user!(plan_user.id, :creator)
respond_with @plan
else
# the plan did not save
Expand Down
2 changes: 1 addition & 1 deletion spec/services/api/v1/deserialization/plan_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
],
dmp_id: { type: 'doi', identifier: @identifier.value },
extension: [
"#{@app_name}": {
dmproadmap: {
template: { id: @template.id, title: @template.title }
}
]
Expand Down