From c3fcbba6fdeb5b4b0561144a0bb69203b324c9b1 Mon Sep 17 00:00:00 2001 From: bilal Date: Mon, 22 Jun 2020 19:02:40 +0200 Subject: [PATCH 1/5] add guardian fields to the medical releases --- .../public/medical_releases_controller.rb | 57 ++++- app/models/medical_release.rb | 14 +- app/views/contract_templates/_form.html.erb | 2 +- .../public/medical_releases/new.html.erb | 102 ++++++++ config/locales/en.yml | 56 ++++- config/locales/es.yml | 37 +++ ...dd_guardians_fields_to_medical_releases.rb | 25 ++ spec/factories/projects.rb | 1 + .../user_manages_contract_templates_spec.rb | 12 + .../user_managing_medical_releases_spec.rb | 226 ++++++++++++++++++ 10 files changed, 514 insertions(+), 18 deletions(-) create mode 100644 db/migrate/20200622180507_add_guardians_fields_to_medical_releases.rb diff --git a/app/controllers/public/medical_releases_controller.rb b/app/controllers/public/medical_releases_controller.rb index 097a607..084298c 100644 --- a/app/controllers/public/medical_releases_controller.rb +++ b/app/controllers/public/medical_releases_controller.rb @@ -45,6 +45,9 @@ class Public::MedicalReleasesController < Public::BaseController .require(:medical_release) .permit( person_params, + guardian_params, + second_guardian_params, + :minor, :signature_base64, :locale, :contract_template, @@ -60,17 +63,49 @@ class Public::MedicalReleasesController < Public::BaseController end def person_params - [ - :person_first_name, - :person_last_name, - :person_phone, - :person_email, - :person_address_street1, - :person_address_street2, - :person_address_city, - :person_address_state, - :person_address_zip, - :person_address_country, + %i[ + person_first_name + person_last_name + person_phone + person_email + person_address_street1 + person_address_street2 + person_address_city + person_address_state + person_address_zip + person_address_country + ] + end + + def guardian_params + %i[ + guardian_first_name + guardian_last_name + guardian_phone + guardian_email + guardian_photo + guardian_address_street1 + guardian_address_street2 + guardian_address_city + guardian_address_state + guardian_address_zip + guardian_address_country + ] + end + + def second_guardian_params + %i[ + guardian_2_first_name + guardian_2_last_name + guardian_2_phone + guardian_2_email + guardian_2_photo + guardian_2_address_street1 + guardian_2_address_street2 + guardian_2_address_city + guardian_2_address_state + guardian_2_address_zip + guardian_2_address_country ] end diff --git a/app/models/medical_release.rb b/app/models/medical_release.rb index 4967ef9..62f08b9 100644 --- a/app/models/medical_release.rb +++ b/app/models/medical_release.rb @@ -7,6 +7,10 @@ class MedicalRelease < ApplicationRecord include Signable include Syncable include PersonName + include GuardianPhotoable + include SecondGuardianPhotoable + include GuardianName + include SecondGuardianName NUMBER_OF_CUSTOM_FIELDS = 15 @@ -31,6 +35,12 @@ class MedicalRelease < ApplicationRecord acts_as_taggable_on :internal_tags, :tags + # These validations apply to releases being signed by a minor + with_options if: :minor? do + validates :guardian_email, email: true, allow_blank: true + validates :guardian_2_email, email: true, allow_blank: true + end + # These validations apply to releases created natively by the system (i.e. not imported from elsewhere) with_options on: :native do validates :signature, attached: true @@ -63,10 +73,6 @@ class MedicalRelease < ApplicationRecord false end - def minor? - false - end - def contract_file_name "#{project.name.parameterize}_#{contract_template.release_type}_#{(signed_at || created_at).strftime("%Y.%m.%d")}_#{release_number}_#{filename_suffix.parameterize}" end diff --git a/app/views/contract_templates/_form.html.erb b/app/views/contract_templates/_form.html.erb index 18bdc7e..0e0740c 100644 --- a/app/views/contract_templates/_form.html.erb +++ b/app/views/contract_templates/_form.html.erb @@ -2,7 +2,7 @@ <%= field_set_tag content_tag(:span, t(".release_info.heading"), class: "h6 text-muted text-uppercase") do %>
<%= form.text_field :name, wrapper_class: "col-sm-6" %> - <%= form.select :release_type, options_for_release_type_select(project, @release_type), { wrapper_class: "col-sm-6" }, data: { toggle: "collapse-select", target_show_values_mapping: { "#guardian_clause": %w(appearance talent misc), "#fee_field": %w(appearance talent location material acquired_media), "#exploitable_rights_fields": %w(appearance talent location material acquired_media), "#custom_fields": %w(medical) } }, class: "form-control custom-select" %> + <%= form.select :release_type, options_for_release_type_select(project, @release_type), { wrapper_class: "col-sm-6" }, data: { toggle: "collapse-select", target_show_values_mapping: { "#guardian_clause": %w(appearance talent misc medical), "#fee_field": %w(appearance talent location material acquired_media), "#exploitable_rights_fields": %w(appearance talent location material acquired_media), "#custom_fields": %w(medical) } }, class: "form-control custom-select" %>
<%= form.number_field :fee, min:"0", max:"99999999", step: "0.01", prepend: "$", help: "Leave at $0.00 for no-fee", wrapper_class: "col-sm-6" %> diff --git a/app/views/public/medical_releases/new.html.erb b/app/views/public/medical_releases/new.html.erb index bebb04b..7f4dd2f 100644 --- a/app/views/public/medical_releases/new.html.erb +++ b/app/views/public/medical_releases/new.html.erb @@ -13,6 +13,17 @@ <% end %>
+ + <% unless @contract_template.guardian_clause.blank? %> + <%= form.form_group :minor do %> + <%= form.check_box :minor, label: t("helpers.label.medical_release.minor"), data: { target: "[data-ujs-target=guardian-fields]", toggle: "collapse" } %> + <% end %> + + <%= card_field_set_tag t(".guardian_clause.heading") do %> +

<%= @contract_template.guardian_clause %>

+ <% end %> +
+ <% end %> <% if (1..MedicalRelease::NUMBER_OF_CUSTOM_FIELDS).map {|n| @contract_template.public_send("question_#{n}_text").presence }.compact.any? %> <%= card_field_set_tag t(".questionnaire.heading") do %> @@ -44,6 +55,97 @@ <%= render "shared/photos_dropzone_fields", form: form, release: @medical_release %> <% end %> + <% unless @contract_template.guardian_clause.blank? %> +
!@medical_release.minor?) %>" data-ujs-target="guardian-fields"> + <%= card_field_set_tag t(".guardian_info.heading") do %> +
+ <%= form.text_field :guardian_first_name, required: @medical_release.minor?, wrapper_class: "col-sm-3" %> + <%= form.text_field :guardian_last_name, required: @medical_release.minor?, wrapper_class: "col-sm-3" %> + <%= form.phone_field :guardian_phone, required: @medical_release.minor?, wrapper_class: "col-sm-6" %> +
+
+ <%= form.text_field :guardian_email, required: @medical_release.minor?, wrapper_class: "col-sm-6" %> +
+ <%= render "shared/address_fields", form: form, subject: "guardian", required: @medical_release.minor? %> + <% end %> + +
+ + <%= card_field_set_tag t(".guardian_photo.heading") do %> +
<%= t ".guardian_photo.instructions" %>
+
+
+
+ <%= t ".photo.no_photo" %> +
+
+
+ <% if @medical_release.guardian_photo.attached? %> + <%= javascript_tag nonce: true do %> + App.PhotoPreview.set("[data-behavior=guardian-photo-preview]", "<%= url_for(@medical_release.guardian_photo.variant(auto_orient: true, resize: '200x200')) %>"); + <% end %> + <% end %> +
+ <%= form.hidden_field :guardian_photo, value: form.object.guardian_photo.signed_id if @medical_release.guardian_photo.attached? %> + <%= form.file_field :guardian_photo, required: @medical_release.minor?, hide_label: true, data: { ujs_target: "guardian-photo-input" }, accept: @medical_release.class.face_photo_acceptable_content_types.join(","), direct_upload: true %> +
+ <%= button_tag t(".photo.take_photo"), type: "button", class: "btn btn-lg btn-primary take-photo-button", data: { behavior: "take-guardian-photo" } %> +
+

+ <%= fa_icon "arrow-up", text: t(".photo.camera_instructions_html") %>
+ <%= t ".photo.warning" %> +

+
+ <% end %> + +
+ + <%= card_field_set_tag t(".guardian_2_info.heading") do %> +
+ <%= form.text_field :guardian_2_first_name, wrapper_class: "col-sm-3" %> + <%= form.text_field :guardian_2_last_name, wrapper_class: "col-sm-3" %> + <%= form.phone_field :guardian_2_phone, wrapper_class: "col-sm-6" %> +
+
+ <%= form.text_field :guardian_2_email, wrapper_class: "col-sm-6" %> +
+ <%= render "shared/address_fields", form: form, subject: "guardian_2" %> + <% end %> + +
+ + <%= card_field_set_tag t(".guardian_2_photo.heading") do %> +
<%= t ".guardian_2_photo.instructions" %>
+
+
+
+ <%= t ".photo.no_photo" %> +
+
+
+ <% if @medical_release.guardian_2_photo.attached? %> + <%= javascript_tag nonce: true do %> + App.PhotoPreview.set("[data-behavior=guardian-photo-preview]", "<%= url_for(@medical_release.guardian_2_photo.variant(auto_orient: true, resize: '200x200')) %>"); + <% end %> + <% end %> +
+ <%= form.hidden_field :guardian_2_photo, value: form.object.guardian_2_photo.signed_id if @medical_release.guardian_2_photo.attached? %> + <%= form.file_field :guardian_2_photo, hide_label: true, data: { ujs_target: "guardian-2-photo-input" }, accept: @medical_release.class.face_photo_acceptable_content_types.join(","), direct_upload: true %> +
+ <%= button_tag t(".photo.take_photo"), type: "button", class: "btn btn-lg btn-primary take-photo-button", data: { behavior: "take-guardian-2-photo" } %> +
+

+ <%= fa_icon "arrow-up", text: t(".photo.camera_instructions_html") %>
+ <%= t ".photo.warning" %> +

+
+ <% end %> + +
+ +
+ <% end %> + <%= card_field_set_tag t(".signature.heading") do %> <%= render "shared/signature_fields", form: form %> <% end %> diff --git a/config/locales/en.yml b/config/locales/en.yml index 13104a0..e944cb4 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -437,6 +437,40 @@ en: file: Video file name: Episode name number: Episode number + medical_release: + person_address_city: City + person_address_country: Country + person_address_state: State + person_address_street1: Address + person_address_street2: Address (Line 2) + person_address_zip: Zip code + person_date_of_birth: Date of birth + person_email: Email address + person_first_name: First name + person_last_name: Last name + person_name: Name + person_phone: Phone number + guardian_2_address_city: Second guardian city + guardian_2_address_country: Second guardian country + guardian_2_address_state: Second guardian state + guardian_2_address_street1: Second guardian address + guardian_2_address_street2: Second guardian address (Line 2) + guardian_2_address_zip: Second guardian zip code + guardian_2_email: Second guardian email + guardian_2_first_name: Second guardian first name + guardian_2_last_name: Second guardian last name + guardian_2_phone: Second guardian phone + guardian_address_city: Guardian city + guardian_address_country: Guardian country + guardian_address_state: Guardian state + guardian_address_street1: Guardian address + guardian_address_street2: Guardian address (Line 2) + guardian_address_zip: Guardian zip code + guardian_first_name: Guardian first name + guardian_last_name: Guardian last name + guardian_email: Guardian email + guardian_phone: Guardian phone + minor: Is the person a minor? placeholder: acquired_media_release: name: Collection Name @@ -664,7 +698,7 @@ en: destroy: alert: The misc release has been deleted index: - actions: + actions: search: Search empty: Misc Releases will appear here table_headers: @@ -911,12 +945,16 @@ en: instructions: Now, enter your personal information. photo: heading: Photos + no_photo: No photo yet + take_photo: Take Photo + camera_instructions_html: Click Take Photo to Turn ON Camera + warning: If your photo appears sideways, it will be autocorrected when you submit your release. questionnaire: heading: Questionnaire signature: heading: Signature misc_releases: - create: + create: notice: Your release has been signed. Thank you! new: cancel: Cancel @@ -943,6 +981,20 @@ en: heading: Photos signature: heading: Signature + guardian_clause: + heading: Guardian Clause + guardian_info: + heading: Guardian Information + guardian_photo: + heading: Guardian Photo + instructions: > + Lastly, it's time for guardian to take a selfie photo! Please remove your hat and sunglasses (regular eyewear is ok), make sure that you are the only person in the photo, look straight into the camera, and say Cheese! + guardian_2_info: + heading: Second Guardian Information + guardian_2_photo: + heading: Second Guardian Photo + instructions: > + Lastly, it's time for second guardian to take a selfie photo! Please remove your hat and sunglasses (regular eyewear is ok), make sure that you are the only person in the photo, look straight into the camera, and say Cheese! talent_releases: create: notice: Your release has been signed. Thank you! diff --git a/config/locales/es.yml b/config/locales/es.yml index 6ce2858..113541d 100644 --- a/config/locales/es.yml +++ b/config/locales/es.yml @@ -150,6 +150,22 @@ es: name: Nómbre del proyecto de vídeo producer_address: Dirección del productor producer_name: Nómbre del productor + medical_release: + minor: El firmante es un menor + guardian_address_zip: Guardian ZIP (ES) + guardian_address_state: Guardian State (ES) + guardian_address_city: Guardian City (ES) + guardian_address_street1: Guardian address (ES) + guardian_address_street2: Guardian address (line 2) (ES) + guardian_email: Guardian email (ES) + guardian_last_name: Guardian Last name (ES) + guardian_phone: Guardian Phone (ES) + guardian_first_name: Guardian First name (ES) + person_address_zip: Person ZIP (ES) + person_address_state: Person State (ES) + person_address_city: Person City (ES) + person_address_street1: Person Address (ES) + person_address_street2: Person Address (line 2) (ES) placeholder: appearance_release: person_address: Calle, Número de apartamento, Ciudad, Estado, Código Postal @@ -229,6 +245,27 @@ es: show: choose_project: ¿Qué proyecto de la lista de abajo asistirá? welcome_html: Bienvenidos a la plataforma de firma autorizaciónes de %{name} + medical_releases: + new: + guardian_clause: + heading: Guardian Clause (ES) + guardian_info: + heading: Gurdian Information (ES) + guardian_photo: + heading: Guardian Photo (ES) + instructions: > + (ES) Lastly, it's time for guardian to take a selfie photo! Please remove your hat and sunglasses (regular eyewear is ok), make sure that you are the only person in the photo, look straight into the camera, and say Cheese! (ES) + photo: + no_photo: No hay foto todavía + take_photo: Take Photo (ES) + camera_instructions_html: Haga clic en Take Photo para encender la cámara + warning: Si su foto aparece de lado, se corregirá automáticamente cuando actualizar la autorización + guardian_2_info: + heading: Second Guardian Information (ES) + guardian_2_photo: + heading: Second Guardian Photo (ES) + instructions: > + (ES) Lastly, it's time for second guardian to take a selfie photo! Please remove your hat and sunglasses (regular eyewear is ok), make sure that you are the only person in the photo, look straight into the camera, and say Cheese! (ES) shared: print: Print (ES) talent_releases: diff --git a/db/migrate/20200622180507_add_guardians_fields_to_medical_releases.rb b/db/migrate/20200622180507_add_guardians_fields_to_medical_releases.rb new file mode 100644 index 0000000..a4d3314 --- /dev/null +++ b/db/migrate/20200622180507_add_guardians_fields_to_medical_releases.rb @@ -0,0 +1,25 @@ +class AddGuardiansFieldsToMedicalReleases < ActiveRecord::Migration[6.0] + def change + add_column :medical_releases, :minor, :boolean, default: false + add_column :medical_releases, :guardian_first_name, :string + add_column :medical_releases, :guardian_last_name, :string + add_column :medical_releases, :guardian_email, :string + add_column :medical_releases, :guardian_phone, :string + add_column :medical_releases, :guardian_address_street1, :string + add_column :medical_releases, :guardian_address_street2, :string + add_column :medical_releases, :guardian_address_city, :string + add_column :medical_releases, :guardian_address_state, :string + add_column :medical_releases, :guardian_address_zip, :string + add_column :medical_releases, :guardian_address_country, :string + add_column :medical_releases, :guardian_2_first_name, :string + add_column :medical_releases, :guardian_2_last_name, :string + add_column :medical_releases, :guardian_2_email, :string + add_column :medical_releases, :guardian_2_phone, :string + add_column :medical_releases, :guardian_2_address_street1, :string + add_column :medical_releases, :guardian_2_address_street2, :string + add_column :medical_releases, :guardian_2_address_city, :string + add_column :medical_releases, :guardian_2_address_state, :string + add_column :medical_releases, :guardian_2_address_zip, :string + add_column :medical_releases, :guardian_2_address_country, :string + end +end diff --git a/spec/factories/projects.rb b/spec/factories/projects.rb index c720785..dcbe930 100644 --- a/spec/factories/projects.rb +++ b/spec/factories/projects.rb @@ -16,6 +16,7 @@ FactoryBot.define do appearance_release: true, location_release: true, material_release: true, + medical_release: true, music_release: true, talent_release: true, video_analysis: true, diff --git a/spec/features/user_manages_contract_templates_spec.rb b/spec/features/user_manages_contract_templates_spec.rb index a81b0a4..094c8bd 100644 --- a/spec/features/user_manages_contract_templates_spec.rb +++ b/spec/features/user_manages_contract_templates_spec.rb @@ -28,6 +28,18 @@ RSpec.feature 'User manages contract templates', type: :feature do expect(page).to have_content('The release template has been created') end + scenario 'medical release template has a guardian clause field' do + visit new_project_contract_template_path(project) + + fill_in 'Name', with: 'My Release Template' + select 'Medical Release', from: 'Release type' + fill_hidden guardian_clause_field, with: 'Guardian clause text' + click_on 'Create Release Template' + + expect(page).to have_content('The release template has been created') + expect(ContractTemplate.last.guardian_clause.body.to_s).to match /Guardian clause text/ + end + scenario 'preview new talent release template without guardian clause' do visit new_project_contract_template_path(project) select 'Talent Release', from: 'Release type' diff --git a/spec/features/user_managing_medical_releases_spec.rb b/spec/features/user_managing_medical_releases_spec.rb index a42a1d6..842001e 100644 --- a/spec/features/user_managing_medical_releases_spec.rb +++ b/spec/features/user_managing_medical_releases_spec.rb @@ -4,6 +4,125 @@ feature "User managing medical releases" do let(:current_user) { create(:user) } let(:project) { create(:project, members: current_user, account: current_user.primary_account) } + context "when signed out" do + scenario 'creating a release for an adult', js: true do + allow(BrayniacAI::Validation).to receive(:create).and_return(double(:validation, valid: true)) + + project = create(:project, members: current_user, account: current_user.primary_account) + contract_template = create(:contract_template, project: project) + + visit new_account_project_contract_template_medical_release_path(project.account, project, contract_template) + + fill_in person_first_name_field, with: 'Jane' + fill_in person_last_name_field, with: 'Doe' + fill_in_person_address_fields + fill_in person_phone_field, with: '555-555-5555' + fill_in person_email_field, with: 'jane.doe@test.com' + drop_file Rails.root.join(file_fixture("person_photo.png")), type: :dropzone + draw_signature file_fixture("signature.png"), "medical_release_signature_base64" + + expect do + click_button submit_release_button + end.to change(MedicalRelease, :count).by(1) + + expect(page).to have_content(successful_submission_message) + end + + scenario 'creating a release for a minor', js: true do + allow(BrayniacAI::Validation).to receive(:create).and_return(double(:validation, valid: true)) + + project = create(:project, members: current_user, account: current_user.primary_account) + contract_template = create(:contract_template, project: project) + + visit new_account_project_contract_template_medical_release_path(project.account, project, contract_template) + + expect(page).not_to have_content('GUARDIAN INFORMATION') + expect(page).not_to have_content('GUARDIAN PHOTO') + + page.check person_is_minor_checkbox + expect(page).to have_content('GUARDIAN INFORMATION') + expect(page).to have_content('GUARDIAN PHOTO') + expect(page).to have_content 'Guardian Email' + + fill_in guardian_first_name_field, with: 'Guardian' + fill_in guardian_last_name_field, with: 'Name' + fill_in guardian_phone_field, with: '001101' + fill_in person_first_name_field, with: 'Jane' + fill_in person_last_name_field, with: 'Doe' + fill_in_person_address_fields + fill_in person_phone_field, with: '555-555-5555' + fill_in person_email_field, with: 'jane.doe@test.com' + drop_file Rails.root.join(file_fixture("person_photo.png")), type: :dropzone + attach_file guardian_photo_field, file_fixture('hemsworth.jpeg'), visible: :all + draw_signature file_fixture('signature.png'), 'medical_release_signature_base64' + + fill_in guardian_email_field, with: 'invalid@email' + click_button submit_release_button + expect(page).to have_content('Guardian email is not an email') + + fill_in guardian_email_field, with: 'valid@email.com' + fill_in_guardian_address_fields + attach_file guardian_photo_field, file_fixture('hemsworth.jpeg'), visible: :all + draw_signature file_fixture('signature.png'), 'medical_release_signature_base64' + click_button submit_release_button + + expect(page).to have_content(successful_submission_message) + end + + scenario 'creating a release for a minor with two guardians', js: true do + allow(BrayniacAI::Validation).to receive(:create).and_return(double(:validation, valid: true)) + + project = create(:project, members: current_user, account: current_user.primary_account) + contract_template = create(:contract_template, project: project) + + visit new_account_project_contract_template_medical_release_path(project.account, project, contract_template) + + expect(page).not_to have_content('SECOND GUARDIAN INFORMATION') + expect(page).not_to have_content('SECOND GUARDIAN PHOTO') + + page.check person_is_minor_checkbox + expect(page).to have_content('GUARDIAN INFORMATION') + expect(page).to have_content('GUARDIAN PHOTO') + expect(page).to have_content 'Guardian Email' + + expect(page).to have_content 'SECOND GUARDIAN INFORMATION' + expect(page).to have_content 'SECOND GUARDIAN PHOTO' + expect(page).to have_content 'Second Guardian Email' + expect(page).to have_content 'Second Guardian Phone' + expect(page).to have_content 'Second Guardian Address' + + fill_in guardian_first_name_field, with: 'Guardian' + fill_in guardian_last_name_field, with: 'Name' + fill_in guardian_phone_field, with: '001101' + fill_in person_first_name_field, with: 'Jane' + fill_in person_last_name_field, with: 'Doe' + fill_in_person_address_fields + fill_in person_phone_field, with: '555-555-5555' + fill_in person_email_field, with: 'jane.doe@test.com' + drop_file Rails.root.join(file_fixture("person_photo.png")), type: :dropzone + attach_file guardian_photo_field, file_fixture('hemsworth.jpeg'), visible: :all + draw_signature file_fixture('signature.png'), 'medical_release_signature_base64' + + fill_in guardian_email_field, with: 'invalid@email' + click_button submit_release_button + expect(page).to have_content('Guardian email is not an email') + + fill_in guardian_email_field, with: 'valid@email.com' + fill_in_guardian_address_fields + attach_file guardian_photo_field, file_fixture('hemsworth.jpeg'), visible: :all + draw_signature file_fixture('signature.png'), 'medical_release_signature_base64' + + fill_in guardian_2_first_name_field, with: 'Second' + fill_in guardian_2_last_name_field, with: 'Guardian' + fill_in guardian_2_phone_field, with: '999' + + click_button submit_release_button + + expect(page).to have_content(successful_submission_message) + expect(MedicalRelease.last.guardian_2_first_name).to eq 'Second' + end + end + context "when signed in as account manager" do before do sign_in current_user @@ -142,4 +261,111 @@ feature "User managing medical releases" do def view_release_pdf_link_for(release) ['Download', href: medical_release_contracts_path(release, format: 'pdf')] end + + def person_first_name_field + "medical_release[person_first_name]" + end + + def person_last_name_field + "medical_release[person_last_name]" + end + + def person_email_field + "medical_release[person_email]" + end + + def person_phone_field + "medical_release[person_phone]" + end + + def submit_release_button + t 'shared.submit_release_short' + end + + def successful_submission_message + "Your release was successfully submitted. Thank you." + end + + def fill_in_person_address_fields + fill_in person_address_street1_field, with: "123 Test Lane" + fill_in person_address_city_field, with: "New York" + fill_in person_address_state_field, with: "NY" + fill_in person_address_zip_field, with: '1000' + end + + def fill_in_guardian_address_fields + fill_in guardian_address_street1_field, with: "124 Test Lane" + fill_in guardian_address_city_field, with: "New York" + fill_in guardian_address_state_field, with: "NY" + fill_in guardian_address_zip_field, with: '1000' + end + + def person_address_street1_field + t('helpers.label.medical_release.person_address_street1') + end + + def person_address_city_field + t('helpers.label.medical_release.person_address_city') + end + + def person_address_state_field + t('helpers.label.medical_release.person_address_state') + end + + def person_address_zip_field + t('helpers.label.medical_release.person_address_zip') + end + + + def guardian_first_name_field + t('helpers.label.medical_release.guardian_first_name') + end + + def guardian_last_name_field + t('helpers.label.medical_release.guardian_last_name') + end + + def guardian_phone_field + t('helpers.label.medical_release.guardian_phone') + end + + def guardian_email_field + t('helpers.label.medical_release.guardian_email') + end + + def guardian_address_street1_field + t('helpers.label.medical_release.guardian_address_street1') + end + + def guardian_address_city_field + t('helpers.label.medical_release.guardian_address_city') + end + + def guardian_address_state_field + t('helpers.label.medical_release.guardian_address_state') + end + + def guardian_address_zip_field + t('helpers.label.medical_release.guardian_address_zip') + end + + def guardian_photo_field + 'medical_release[guardian_photo]' + end + + def person_is_minor_checkbox + 'medical_release_minor' + end + + def guardian_2_first_name_field + 'Second guardian first name' + end + + def guardian_2_last_name_field + 'Second guardian last name' + end + + def guardian_2_phone_field + 'Second guardian phone' + end end -- 2.47.3 From d7990f185756778dbd376cffd0acfd49aed485a3 Mon Sep 17 00:00:00 2001 From: bilal Date: Tue, 23 Jun 2020 17:27:07 +0200 Subject: [PATCH 2/5] sort --- config/locales/en.yml | 98 +++++++++++++++++++++---------------------- config/locales/es.yml | 74 ++++++++++++++++---------------- 2 files changed, 86 insertions(+), 86 deletions(-) diff --git a/config/locales/en.yml b/config/locales/en.yml index e944cb4..48883b1 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -397,6 +397,40 @@ en: person_name: Name person_phone: Phone number person_title: Title + medical_release: + guardian_2_address_city: Second guardian city + guardian_2_address_country: Second guardian country + guardian_2_address_state: Second guardian state + guardian_2_address_street1: Second guardian address + guardian_2_address_street2: Second guardian address (Line 2) + guardian_2_address_zip: Second guardian zip code + guardian_2_email: Second guardian email + guardian_2_first_name: Second guardian first name + guardian_2_last_name: Second guardian last name + guardian_2_phone: Second guardian phone + guardian_address_city: Guardian city + guardian_address_country: Guardian country + guardian_address_state: Guardian state + guardian_address_street1: Guardian address + guardian_address_street2: Guardian address (Line 2) + guardian_address_zip: Guardian zip code + guardian_email: Guardian email + guardian_first_name: Guardian first name + guardian_last_name: Guardian last name + guardian_phone: Guardian phone + minor: Is the person a minor? + person_address_city: City + person_address_country: Country + person_address_state: State + person_address_street1: Address + person_address_street2: Address (Line 2) + person_address_zip: Zip code + person_date_of_birth: Date of birth + person_email: Email address + person_first_name: First name + person_last_name: Last name + person_name: Name + person_phone: Phone number music_release: person_address: Address person_address_city: City @@ -437,40 +471,6 @@ en: file: Video file name: Episode name number: Episode number - medical_release: - person_address_city: City - person_address_country: Country - person_address_state: State - person_address_street1: Address - person_address_street2: Address (Line 2) - person_address_zip: Zip code - person_date_of_birth: Date of birth - person_email: Email address - person_first_name: First name - person_last_name: Last name - person_name: Name - person_phone: Phone number - guardian_2_address_city: Second guardian city - guardian_2_address_country: Second guardian country - guardian_2_address_state: Second guardian state - guardian_2_address_street1: Second guardian address - guardian_2_address_street2: Second guardian address (Line 2) - guardian_2_address_zip: Second guardian zip code - guardian_2_email: Second guardian email - guardian_2_first_name: Second guardian first name - guardian_2_last_name: Second guardian last name - guardian_2_phone: Second guardian phone - guardian_address_city: Guardian city - guardian_address_country: Guardian country - guardian_address_state: Guardian state - guardian_address_street1: Guardian address - guardian_address_street2: Guardian address (Line 2) - guardian_address_zip: Guardian zip code - guardian_first_name: Guardian first name - guardian_last_name: Guardian last name - guardian_email: Guardian email - guardian_phone: Guardian phone - minor: Is the person a minor? placeholder: acquired_media_release: name: Collection Name @@ -936,6 +936,20 @@ en: notice: Your release has been signed. Thank you! new: cancel: Cancel + guardian_2_info: + heading: Second Guardian Information + guardian_2_photo: + heading: Second Guardian Photo + instructions: > + Lastly, it's time for second guardian to take a selfie photo! Please remove your hat and sunglasses (regular eyewear is ok), make sure that you are the only person in the photo, look straight into the camera, and say Cheese! + guardian_clause: + heading: Guardian Clause + guardian_info: + heading: Guardian Information + guardian_photo: + heading: Guardian Photo + instructions: > + Lastly, it's time for guardian to take a selfie photo! Please remove your hat and sunglasses (regular eyewear is ok), make sure that you are the only person in the photo, look straight into the camera, and say Cheese! instructions_html: > Below is the medical release form. After scrolling down and reading the medical release form, please enter your personal information, take a photo, and press the "Submit Release" button. legal: @@ -944,10 +958,10 @@ en: heading: Personal Information instructions: Now, enter your personal information. photo: + camera_instructions_html: Click Take Photo to Turn ON Camera heading: Photos no_photo: No photo yet take_photo: Take Photo - camera_instructions_html: Click Take Photo to Turn ON Camera warning: If your photo appears sideways, it will be autocorrected when you submit your release. questionnaire: heading: Questionnaire @@ -981,20 +995,6 @@ en: heading: Photos signature: heading: Signature - guardian_clause: - heading: Guardian Clause - guardian_info: - heading: Guardian Information - guardian_photo: - heading: Guardian Photo - instructions: > - Lastly, it's time for guardian to take a selfie photo! Please remove your hat and sunglasses (regular eyewear is ok), make sure that you are the only person in the photo, look straight into the camera, and say Cheese! - guardian_2_info: - heading: Second Guardian Information - guardian_2_photo: - heading: Second Guardian Photo - instructions: > - Lastly, it's time for second guardian to take a selfie photo! Please remove your hat and sunglasses (regular eyewear is ok), make sure that you are the only person in the photo, look straight into the camera, and say Cheese! talent_releases: create: notice: Your release has been signed. Thank you! diff --git a/config/locales/es.yml b/config/locales/es.yml index 113541d..dd922cb 100644 --- a/config/locales/es.yml +++ b/config/locales/es.yml @@ -143,6 +143,22 @@ es: person_email: Dirección de correo electrónico person_name: Nómbre person_phone: Número de teléfono + medical_release: + guardian_address_city: Guardian City (ES) + guardian_address_state: Guardian State (ES) + guardian_address_street1: Guardian address (ES) + guardian_address_street2: Guardian address (line 2) (ES) + guardian_address_zip: Guardian ZIP (ES) + guardian_email: Guardian email (ES) + guardian_first_name: Guardian First name (ES) + guardian_last_name: Guardian Last name (ES) + guardian_phone: Guardian Phone (ES) + minor: El firmante es un menor + person_address_city: Person City (ES) + person_address_state: Person State (ES) + person_address_street1: Person Address (ES) + person_address_street2: Person Address (line 2) (ES) + person_address_zip: Person ZIP (ES) project: client_name: Nómbre del cliente del proyecto description: Descripción del proyecto @@ -150,22 +166,6 @@ es: name: Nómbre del proyecto de vídeo producer_address: Dirección del productor producer_name: Nómbre del productor - medical_release: - minor: El firmante es un menor - guardian_address_zip: Guardian ZIP (ES) - guardian_address_state: Guardian State (ES) - guardian_address_city: Guardian City (ES) - guardian_address_street1: Guardian address (ES) - guardian_address_street2: Guardian address (line 2) (ES) - guardian_email: Guardian email (ES) - guardian_last_name: Guardian Last name (ES) - guardian_phone: Guardian Phone (ES) - guardian_first_name: Guardian First name (ES) - person_address_zip: Person ZIP (ES) - person_address_state: Person State (ES) - person_address_city: Person City (ES) - person_address_street1: Person Address (ES) - person_address_street2: Person Address (line 2) (ES) placeholder: appearance_release: person_address: Calle, Número de apartamento, Ciudad, Estado, Código Postal @@ -230,6 +230,27 @@ es: new: photo: heading: Photos (ES) + medical_releases: + new: + guardian_2_info: + heading: Second Guardian Information (ES) + guardian_2_photo: + heading: Second Guardian Photo (ES) + instructions: > + (ES) Lastly, it's time for second guardian to take a selfie photo! Please remove your hat and sunglasses (regular eyewear is ok), make sure that you are the only person in the photo, look straight into the camera, and say Cheese! (ES) + guardian_clause: + heading: Guardian Clause (ES) + guardian_info: + heading: Gurdian Information (ES) + guardian_photo: + heading: Guardian Photo (ES) + instructions: > + (ES) Lastly, it's time for guardian to take a selfie photo! Please remove your hat and sunglasses (regular eyewear is ok), make sure that you are the only person in the photo, look straight into the camera, and say Cheese! (ES) + photo: + camera_instructions_html: Haga clic en Take Photo para encender la cámara + no_photo: No hay foto todavía + take_photo: Take Photo (ES) + warning: Si su foto aparece de lado, se corregirá automáticamente cuando actualizar la autorización talent_releases: new: guardian_clause: @@ -245,27 +266,6 @@ es: show: choose_project: ¿Qué proyecto de la lista de abajo asistirá? welcome_html: Bienvenidos a la plataforma de firma autorizaciónes de %{name} - medical_releases: - new: - guardian_clause: - heading: Guardian Clause (ES) - guardian_info: - heading: Gurdian Information (ES) - guardian_photo: - heading: Guardian Photo (ES) - instructions: > - (ES) Lastly, it's time for guardian to take a selfie photo! Please remove your hat and sunglasses (regular eyewear is ok), make sure that you are the only person in the photo, look straight into the camera, and say Cheese! (ES) - photo: - no_photo: No hay foto todavía - take_photo: Take Photo (ES) - camera_instructions_html: Haga clic en Take Photo para encender la cámara - warning: Si su foto aparece de lado, se corregirá automáticamente cuando actualizar la autorización - guardian_2_info: - heading: Second Guardian Information (ES) - guardian_2_photo: - heading: Second Guardian Photo (ES) - instructions: > - (ES) Lastly, it's time for second guardian to take a selfie photo! Please remove your hat and sunglasses (regular eyewear is ok), make sure that you are the only person in the photo, look straight into the camera, and say Cheese! (ES) shared: print: Print (ES) talent_releases: -- 2.47.3 From d28d76b8771a466dd3efd7ba24e3c6b11384c37a Mon Sep 17 00:00:00 2001 From: Bilal Date: Wed, 24 Jun 2020 11:11:17 +0200 Subject: [PATCH 3/5] rebase --- db/structure.sql | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) diff --git a/db/structure.sql b/db/structure.sql index 051cc35..0a9c5d0 100644 --- a/db/structure.sql +++ b/db/structure.sql @@ -1024,7 +1024,28 @@ CREATE TABLE public.medical_releases ( question_12_answer text, question_13_answer text, question_14_answer text, - question_15_answer text + question_15_answer text, + minor boolean DEFAULT false, + guardian_first_name character varying, + guardian_last_name character varying, + guardian_email character varying, + guardian_phone character varying, + guardian_address_street1 character varying, + guardian_address_street2 character varying, + guardian_address_city character varying, + guardian_address_state character varying, + guardian_address_zip character varying, + guardian_address_country character varying, + guardian_2_first_name character varying, + guardian_2_last_name character varying, + guardian_2_email character varying, + guardian_2_phone character varying, + guardian_2_address_street1 character varying, + guardian_2_address_street2 character varying, + guardian_2_address_city character varying, + guardian_2_address_state character varying, + guardian_2_address_zip character varying, + guardian_2_address_country character varying ); @@ -3790,6 +3811,7 @@ INSERT INTO "schema_migrations" (version) VALUES ('20200616124214'), ('20200619081446'), ('20200619085823'), -('20200619134853'); +('20200619134853'), +('20200622180507'); -- 2.47.3 From 80a2aa1c029c7f99ac204bc5cf83d8e3bf07e83d Mon Sep 17 00:00:00 2001 From: Bilal Date: Wed, 24 Jun 2020 11:24:43 +0200 Subject: [PATCH 4/5] fix MR comments --- config/locales/en.yml | 22 +++++----- config/locales/es.yml | 42 +++++++++++++------ .../user_managing_medical_releases_spec.rb | 6 +-- 3 files changed, 44 insertions(+), 26 deletions(-) diff --git a/config/locales/en.yml b/config/locales/en.yml index 48883b1..9482f66 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -398,16 +398,16 @@ en: person_phone: Phone number person_title: Title medical_release: - guardian_2_address_city: Second guardian city - guardian_2_address_country: Second guardian country - guardian_2_address_state: Second guardian state - guardian_2_address_street1: Second guardian address - guardian_2_address_street2: Second guardian address (Line 2) - guardian_2_address_zip: Second guardian zip code - guardian_2_email: Second guardian email - guardian_2_first_name: Second guardian first name - guardian_2_last_name: Second guardian last name - guardian_2_phone: Second guardian phone + guardian_2_address_city: Guardian 2 city + guardian_2_address_country: Guardian 2 country + guardian_2_address_state: Guardian 2 state + guardian_2_address_street1: Guardian 2 address + guardian_2_address_street2: Guardian 2 address (Line 2) + guardian_2_address_zip: Guardian 2 zip code + guardian_2_email: Guardian 2 email + guardian_2_first_name: Guardian 2 first name + guardian_2_last_name: Guardian 2 last name + guardian_2_phone: Guardian 2 phone guardian_address_city: Guardian city guardian_address_country: Guardian country guardian_address_state: Guardian state @@ -937,7 +937,7 @@ en: new: cancel: Cancel guardian_2_info: - heading: Second Guardian Information + heading: Second Guardian Information (if company requires) guardian_2_photo: heading: Second Guardian Photo instructions: > diff --git a/config/locales/es.yml b/config/locales/es.yml index dd922cb..4f3d43d 100644 --- a/config/locales/es.yml +++ b/config/locales/es.yml @@ -116,16 +116,16 @@ es: helpers: label: appearance_release: - guardian_2_address_city: Second guardian city (ES) - guardian_2_address_country: Second guardian country (ES) - guardian_2_address_state: Second guardian state (ES) - guardian_2_address_street1: Second guardian address (ES) - guardian_2_address_street2: Second guardian address (Line 2) (ES) - guardian_2_address_zip: Second guardian zip code (ES) - guardian_2_email: Second guardian email (ES) - guardian_2_first_name: Second guardian first name (ES) - guardian_2_last_name: Second guardian last name (ES) - guardian_2_phone: Second guardian phone (ES) + guardian_2_address_city: Guardian 2 city (ES) + guardian_2_address_country: Guardian 2 country (ES) + guardian_2_address_state: Guardian 2 state (ES) + guardian_2_address_street1: Guardian 2 address (ES) + guardian_2_address_street2: Guardian 2 address (Line 2) (ES) + guardian_2_address_zip: Guardian 2 zip code (ES) + guardian_2_email: Guardian 2 email (ES) + guardian_2_first_name: Guardian 2 first name (ES) + guardian_2_last_name: Guardian 2 last name (ES) + guardian_2_phone: Guardian 2 phone (ES) guardian_address_city: Guardian city (ES) guardian_address_country: Guardian country (ES) guardian_address_state: Guardian state (ES) @@ -144,7 +144,18 @@ es: person_name: Nómbre person_phone: Número de teléfono medical_release: + guardian_2_address_city: Guardian 2 city (ES) + guardian_2_address_country: Guardian 2 country (ES) + guardian_2_address_state: Guardian 2 state (ES) + guardian_2_address_street1: Guardian 2 address (ES) + guardian_2_address_street2: Guardian 2 address (Line 2) (ES) + guardian_2_address_zip: Guardian 2 zip code (ES) + guardian_2_email: Guardian 2 email (ES) + guardian_2_first_name: "" + guardian_2_last_name: "" + guardian_2_phone: "" guardian_address_city: Guardian City (ES) + guardian_address_country: Guardian country (ES) guardian_address_state: Guardian State (ES) guardian_address_street1: Guardian address (ES) guardian_address_street2: Guardian address (line 2) (ES) @@ -155,10 +166,17 @@ es: guardian_phone: Guardian Phone (ES) minor: El firmante es un menor person_address_city: Person City (ES) + person_address_country: Country (ES) person_address_state: Person State (ES) person_address_street1: Person Address (ES) person_address_street2: Person Address (line 2) (ES) person_address_zip: Person ZIP (ES) + person_date_of_birth: Date of birth (ES) + person_email: Email address (ES) + person_first_name: First name (ES) + person_last_name: Last name (ES) + person_name: Name (ES) + person_phone: Phone number (ES) project: client_name: Nómbre del cliente del proyecto description: Descripción del proyecto @@ -195,7 +213,7 @@ es: new: cancel: Cancelar guardian_2_info: - heading: Second Guardian Information (ES) + heading: Second Guardian Information (if company requires) (ES) guardian_2_photo: heading: Second Guardian Photo (ES) instructions: > @@ -233,7 +251,7 @@ es: medical_releases: new: guardian_2_info: - heading: Second Guardian Information (ES) + heading: Second Guardian Information (if company requires) (ES) guardian_2_photo: heading: Second Guardian Photo (ES) instructions: > diff --git a/spec/features/user_managing_medical_releases_spec.rb b/spec/features/user_managing_medical_releases_spec.rb index 842001e..2c3032e 100644 --- a/spec/features/user_managing_medical_releases_spec.rb +++ b/spec/features/user_managing_medical_releases_spec.rb @@ -358,14 +358,14 @@ feature "User managing medical releases" do end def guardian_2_first_name_field - 'Second guardian first name' + t('helpers.label.medical_release.guardian_2_first_name') end def guardian_2_last_name_field - 'Second guardian last name' + t('helpers.label.medical_release.guardian_2_last_name') end def guardian_2_phone_field - 'Second guardian phone' + t('helpers.label.medical_release.guardian_2_phone') end end -- 2.47.3 From f978fb5778cc05fda7b965a256dae592601eb116 Mon Sep 17 00:00:00 2001 From: Bilal Date: Wed, 24 Jun 2020 12:03:53 +0200 Subject: [PATCH 5/5] fix MR comments --- .../user_managing_medical_releases_spec.rb | 62 ++++++++++++++----- 1 file changed, 45 insertions(+), 17 deletions(-) diff --git a/spec/features/user_managing_medical_releases_spec.rb b/spec/features/user_managing_medical_releases_spec.rb index 2c3032e..59510fb 100644 --- a/spec/features/user_managing_medical_releases_spec.rb +++ b/spec/features/user_managing_medical_releases_spec.rb @@ -36,13 +36,13 @@ feature "User managing medical releases" do visit new_account_project_contract_template_medical_release_path(project.account, project, contract_template) - expect(page).not_to have_content('GUARDIAN INFORMATION') - expect(page).not_to have_content('GUARDIAN PHOTO') + expect(page).not_to have_content guardian_information_heading.upcase + expect(page).not_to have_content guardian_photo_heading.upcase page.check person_is_minor_checkbox - expect(page).to have_content('GUARDIAN INFORMATION') - expect(page).to have_content('GUARDIAN PHOTO') - expect(page).to have_content 'Guardian Email' + expect(page).to have_content guardian_information_heading.upcase + expect(page).to have_content guardian_photo_heading.upcase + expect(page).to have_content guardian_email_field.titleize fill_in guardian_first_name_field, with: 'Guardian' fill_in guardian_last_name_field, with: 'Name' @@ -58,7 +58,7 @@ feature "User managing medical releases" do fill_in guardian_email_field, with: 'invalid@email' click_button submit_release_button - expect(page).to have_content('Guardian email is not an email') + expect(page).to have_content email_validation_error_for('Guardian') fill_in guardian_email_field, with: 'valid@email.com' fill_in_guardian_address_fields @@ -77,19 +77,19 @@ feature "User managing medical releases" do visit new_account_project_contract_template_medical_release_path(project.account, project, contract_template) - expect(page).not_to have_content('SECOND GUARDIAN INFORMATION') - expect(page).not_to have_content('SECOND GUARDIAN PHOTO') + expect(page).not_to have_content guardian_2_information_heading.upcase + expect(page).not_to have_content guardian_2_photo_heading.upcase page.check person_is_minor_checkbox - expect(page).to have_content('GUARDIAN INFORMATION') - expect(page).to have_content('GUARDIAN PHOTO') - expect(page).to have_content 'Guardian Email' + expect(page).to have_content guardian_information_heading.upcase + expect(page).to have_content guardian_photo_heading.upcase + expect(page).to have_content guardian_email_field.titleize - expect(page).to have_content 'SECOND GUARDIAN INFORMATION' - expect(page).to have_content 'SECOND GUARDIAN PHOTO' - expect(page).to have_content 'Second Guardian Email' - expect(page).to have_content 'Second Guardian Phone' - expect(page).to have_content 'Second Guardian Address' + expect(page).to have_content guardian_2_information_heading.upcase + expect(page).to have_content guardian_2_photo_heading.upcase + expect(page).to have_content guardian_2_email_field.titleize + expect(page).to have_content guardian_2_phone_field.titleize + expect(page).to have_content guardian_2_address_street1_field.titleize fill_in guardian_first_name_field, with: 'Guardian' fill_in guardian_last_name_field, with: 'Name' @@ -105,7 +105,7 @@ feature "User managing medical releases" do fill_in guardian_email_field, with: 'invalid@email' click_button submit_release_button - expect(page).to have_content('Guardian email is not an email') + expect(page).to have_content email_validation_error_for('Guardian') fill_in guardian_email_field, with: 'valid@email.com' fill_in_guardian_address_fields @@ -368,4 +368,32 @@ feature "User managing medical releases" do def guardian_2_phone_field t('helpers.label.medical_release.guardian_2_phone') end + + def guardian_2_email_field + t('helpers.label.medical_release.guardian_2_email') + end + + def guardian_2_address_street1_field + t('helpers.label.medical_release.guardian_2_address_street1') + end + + def email_validation_error_for(prefix) + "#{prefix} email is not an email" + end + + def guardian_photo_heading + t 'public.medical_releases.new.guardian_photo.heading' + end + + def guardian_information_heading + t 'public.medical_releases.new.guardian_info.heading' + end + + def guardian_2_photo_heading + t 'public.medical_releases.new.guardian_2_photo.heading' + end + + def guardian_2_information_heading + t 'public.medical_releases.new.guardian_2_info.heading' + end end -- 2.47.3