diff --git a/app/controllers/contacts_controller.rb b/app/controllers/contacts_controller.rb index b94c372048..13862aa0dd 100644 --- a/app/controllers/contacts_controller.rb +++ b/app/controllers/contacts_controller.rb @@ -95,8 +95,7 @@ def contact def edit_profile_action form_values = JSON.parse(params.require(:formValues), symbolize_names: true) - edited_profile_details = form_values[:editedProfileDetails] - edit_profile_reason = form_values[:editProfileReason] + edited_profile_details_from_form = form_values[:editedProfileDetails] attachment = params[:attachment] wca_id = form_values[:wcaId] person = Person.find_by(wca_id: wca_id) @@ -114,6 +113,9 @@ def edit_profile_action gender: person.gender, dob: person.dob, } + + edited_profile_details = edited_profile_details_from_form.transform_values { |v| v[:newValue] } + changes_requested = Person.fields_edit_requestable .reject { |field| profile_to_edit[field].to_s == edited_profile_details[field].to_s } .map do |field| @@ -121,6 +123,7 @@ def edit_profile_action field: field, from: profile_to_edit[field], to: edited_profile_details[field], + reason: edited_profile_details_from_form[field][:editReason], ) end @@ -129,7 +132,6 @@ def edit_profile_action name: profile_to_edit[:name], wca_id: wca_id, changes_requested: changes_requested, - edit_profile_reason: edit_profile_reason, requestor_user: current_user, document: attachment, request: request, diff --git a/app/models/contact_edit_profile.rb b/app/models/contact_edit_profile.rb index 813766f222..4769edd0c5 100644 --- a/app/models/contact_edit_profile.rb +++ b/app/models/contact_edit_profile.rb @@ -3,7 +3,6 @@ class ContactEditProfile < ContactForm attribute :wca_id attribute :changes_requested - attribute :edit_profile_reason attribute :requestor_user attribute :ticket attribute :document, attachment: true @@ -12,6 +11,7 @@ class ContactEditProfile < ContactForm :field, :from, :to, + :reason, ) def value_humanized(value, field) diff --git a/app/views/mail_form/contact_edit_profile.erb b/app/views/mail_form/contact_edit_profile.erb index d7b8839feb..41a7ea6f0a 100644 --- a/app/views/mail_form/contact_edit_profile.erb +++ b/app/views/mail_form/contact_edit_profile.erb @@ -9,13 +9,19 @@