Skip to content

Commit

Permalink
fix submission default values with 2+ submitters
Browse files Browse the repository at this point in the history
  • Loading branch information
omohokcoj committed Jan 25, 2024
1 parent cba1963 commit 5c69b96
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion app/controllers/api/submitters_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ def update

Submissions::CreateFromSubmitters.maybe_set_template_fields(@submitter.submission,
[normalized_params],
submitter_uuid: @submitter.uuid)
default_submitter_uuid: @submitter.uuid)

assign_submitter_attrs(@submitter, normalized_params)

Expand Down
4 changes: 2 additions & 2 deletions lib/submissions/create_from_submitters.rb
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,11 @@ def call(template:, user:, submissions_attrs:, source:, submitters_order:, mark_
end
end

def maybe_set_template_fields(submission, submitters_attrs, submitter_uuid: nil)
def maybe_set_template_fields(submission, submitters_attrs, default_submitter_uuid: nil)
template_fields = (submission.template_fields || submission.template.fields).deep_dup

submitters_attrs.each_with_index do |submitter_attrs, index|
submitter_uuid ||= find_submitter_uuid(submission.template, submitter_attrs, index)
submitter_uuid = default_submitter_uuid || find_submitter_uuid(submission.template, submitter_attrs, index)

process_readonly_fields_param(submitter_attrs[:readonly_fields], template_fields, submitter_uuid)
process_field_values_param(submitter_attrs[:values], template_fields, submitter_uuid)
Expand Down

0 comments on commit 5c69b96

Please sign in to comment.