Skip to content

Commit 3e2e2e7

Browse files
authored
Merge pull request #3135 from DMPRoadmap/dcc_bug_711-Creating_plans_using_V0_Rest_API
DCC Bug 711 - Fix for broken creation of a Plan using the V0 API.
2 parents 030831f + 9302d3d commit 3e2e2e7

File tree

3 files changed

+8
-2
lines changed

3 files changed

+8
-2
lines changed

app/controllers/api/v0/base_controller.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,10 @@ def page_params
7474
params.permit(:page, :per_page)
7575
end
7676

77+
def plan_params
78+
params.permit(:template_id, :plan[:title], :plan[:email])
79+
end
80+
7781
# The resource class based on the controller
7882
#
7983
# Returns Object

app/controllers/api/v0/plans_controller.rb

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ def create
2929

3030
# initialize the plan
3131
@plan = Plan.new
32+
@plan.org = @user.org
3233

3334
# Attach the user as the PI and Data Contact
3435
@plan.contributors << Contributor.new(
@@ -48,8 +49,9 @@ def create
4849
end
4950
@plan.template = @template
5051
@plan.title = params[:plan][:title]
52+
5153
if @plan.save
52-
@plan.assign_creator(plan_user)
54+
@plan.add_user!(plan_user.id, :creator)
5355
respond_with @plan
5456
else
5557
# the plan did not save

spec/services/api/v1/deserialization/plan_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@
5353
],
5454
dmp_id: { type: 'doi', identifier: @identifier.value },
5555
extension: [
56-
"#{@app_name}": {
56+
dmproadmap: {
5757
template: { id: @template.id, title: @template.title }
5858
}
5959
]

0 commit comments

Comments
 (0)