Skip to content

Commit

Permalink
Extract create agreements
Browse files Browse the repository at this point in the history
  • Loading branch information
onk committed May 3, 2024
1 parent ddaf419 commit daa1014
Showing 1 changed file with 14 additions and 10 deletions.
24 changes: 14 additions & 10 deletions app/controllers/profiles_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,16 +27,7 @@ def create
@profile.email = current_user[:info][:email]

if @profile.save
Agreement.create!(profile_id: @profile.id, form_item_id: 1, value: 1) if agreement_params['require_email']
Agreement.create!(profile_id: @profile.id, form_item_id: 2, value: 1) if agreement_params['require_tel']
Agreement.create!(profile_id: @profile.id, form_item_id: 3, value: 1) if agreement_params['require_posting']
Agreement.create!(profile_id: @profile.id, form_item_id: 4, value: 1) if agreement_params['agree_ms']
Agreement.create!(profile_id: @profile.id, form_item_id: 5, value: 1) if agreement_params['agree_ms_cndo2021']

Agreement.create!(profile_id: @profile.id, form_item_id: 6, value: 1) if agreement_params['ibm_require_email_cndt2022']
Agreement.create!(profile_id: @profile.id, form_item_id: 7, value: 1) if agreement_params['ibm_require_tel_cndt2022']
Agreement.create!(profile_id: @profile.id, form_item_id: 8, value: 1) if agreement_params['redhat_require_email_cndt2022']
Agreement.create!(profile_id: @profile.id, form_item_id: 9, value: 1) if agreement_params['redhat_require_tel_cndt2022']
create_agreement(@profile)

ProfileMailer.registered(@profile, @conference).deliver_later
if @profile.public_profile.present?
Expand Down Expand Up @@ -175,4 +166,17 @@ def agreement_params
:redhat_require_tel_cndt2022
)
end

def create_agreement(profile)
Agreement.create!(profile_id: profile.id, form_item_id: 1, value: 1) if agreement_params['require_email']
Agreement.create!(profile_id: profile.id, form_item_id: 2, value: 1) if agreement_params['require_tel']
Agreement.create!(profile_id: profile.id, form_item_id: 3, value: 1) if agreement_params['require_posting']
Agreement.create!(profile_id: profile.id, form_item_id: 4, value: 1) if agreement_params['agree_ms']
Agreement.create!(profile_id: profile.id, form_item_id: 5, value: 1) if agreement_params['agree_ms_cndo2021']

Agreement.create!(profile_id: profile.id, form_item_id: 6, value: 1) if agreement_params['ibm_require_email_cndt2022']
Agreement.create!(profile_id: profile.id, form_item_id: 7, value: 1) if agreement_params['ibm_require_tel_cndt2022']
Agreement.create!(profile_id: profile.id, form_item_id: 8, value: 1) if agreement_params['redhat_require_email_cndt2022']
Agreement.create!(profile_id: profile.id, form_item_id: 9, value: 1) if agreement_params['redhat_require_tel_cndt2022']
end
end

0 comments on commit daa1014

Please sign in to comment.