add second guardian fields to the public signing form for talent releases

This commit is contained in:
Bilal
2020-06-25 18:31:20 +02:00
parent fe131491cd
commit 181be3fc1d
8 changed files with 269 additions and 31 deletions

View File

@@ -45,42 +45,59 @@ class Public::TalentReleasesController < Public::BaseController
.permit( .permit(
person_params, person_params,
guardian_params, guardian_params,
second_guardian_params,
:signature_base64, :signature_base64,
:locale, :locale,
:contract_template, :contract_template,
photos: [], photos: []
) )
end end
def person_params def person_params
[ %i[
:person_first_name, person_first_name
:person_last_name, person_last_name
:person_phone, person_phone
:person_email, person_email
:person_address_street1, person_address_street1
:person_address_street2, person_address_street2
:person_address_city, person_address_city
:person_address_state, person_address_state
:person_address_zip, person_address_zip
:person_address_country, person_address_country
] ]
end end
def guardian_params def guardian_params
[ %i[
:guardian_first_name, guardian_first_name
:guardian_last_name, guardian_last_name
:guardian_phone, guardian_phone
:guardian_email, guardian_email
:minor, minor
:guardian_address_street1, guardian_address_street1
:guardian_address_street2, guardian_address_street2
:guardian_address_city, guardian_address_city
:guardian_address_state, guardian_address_state
:guardian_address_zip, guardian_address_zip
:guardian_address_country, guardian_address_country
:guardian_photo, guardian_photo
]
end
def second_guardian_params
%i[
guardian_2_first_name
guardian_2_last_name
guardian_2_phone
guardian_2_email
guardian_2_address_street1
guardian_2_address_street2
guardian_2_address_city
guardian_2_address_state
guardian_2_address_zip
guardian_2_address_country
guardian_2_photo
] ]
end end

View File

@@ -11,7 +11,9 @@ class TalentRelease < ApplicationRecord
include Taggable include Taggable
include PersonName include PersonName
include GuardianPhotoable include GuardianPhotoable
include SecondGuardianPhotoable
include GuardianName include GuardianName
include SecondGuardianName
composed_of :person_address, composed_of :person_address,
class_name: "Address", class_name: "Address",
@@ -35,6 +37,17 @@ class TalentRelease < ApplicationRecord
%w(guardian_address_country country) %w(guardian_address_country country)
] ]
composed_of :guardian_2_address,
class_name: "Address",
mapping: [
%w(guardian_2_address_street1 street1),
%w(guardian_2_address_street2 street2),
%w(guardian_2_address_city city),
%w(guardian_2_address_state state),
%w(guardian_2_address_zip zip),
%w(guardian_2_address_country country)
]
def self.face_photo_acceptable_content_types def self.face_photo_acceptable_content_types
["image/png", "image/jpeg"] ["image/png", "image/jpeg"]
end end
@@ -58,6 +71,7 @@ class TalentRelease < ApplicationRecord
# These validations apply to releases being signed by a minor # These validations apply to releases being signed by a minor
with_options if: :minor? do with_options if: :minor? do
validates :guardian_first_name, :guardian_last_name, presence: true validates :guardian_first_name, :guardian_last_name, presence: true
validates :guardian_email, :guardian_2_email, email: true, allow_blank: true
validates :guardian_phone, presence: true validates :guardian_phone, presence: true
end end
@@ -84,6 +98,10 @@ class TalentRelease < ApplicationRecord
false false
end end
def second_guardian_present?
guardian_2_first_name.present?
end
def contract_file_name def contract_file_name
"#{project.name.parameterize}_#{contract_template.release_type}_#{(signed_at || created_at).strftime("%Y.%m.%d")}_#{release_number}_#{filename_suffix.parameterize}" "#{project.name.parameterize}_#{contract_template.release_type}_#{(signed_at || created_at).strftime("%Y.%m.%d")}_#{release_number}_#{filename_suffix.parameterize}"
end end

View File

@@ -31,8 +31,6 @@
<%= form.text_field :person_first_name, required: true, wrapper_class: "col-sm-6" %> <%= form.text_field :person_first_name, required: true, wrapper_class: "col-sm-6" %>
<%= form.text_field :person_last_name, required: true, wrapper_class: "col-sm-6" %> <%= form.text_field :person_last_name, required: true, wrapper_class: "col-sm-6" %>
<%= form.phone_field :person_phone, wrapper_class: "col-sm-6" %> <%= form.phone_field :person_phone, wrapper_class: "col-sm-6" %>
</div>
<div class="form-row">
<%= form.email_field :person_email, wrapper_class: "col-sm-6" %> <%= form.email_field :person_email, wrapper_class: "col-sm-6" %>
</div> </div>
<%= render "shared/address_fields", form: form, subject: "person" %> <%= render "shared/address_fields", form: form, subject: "person" %>
@@ -51,8 +49,6 @@
<%= form.text_field :guardian_first_name, required: @talent_release.minor?, wrapper_class: "col-sm-3" %> <%= form.text_field :guardian_first_name, required: @talent_release.minor?, wrapper_class: "col-sm-3" %>
<%= form.text_field :guardian_last_name, required: @talent_release.minor?, wrapper_class: "col-sm-3" %> <%= form.text_field :guardian_last_name, required: @talent_release.minor?, wrapper_class: "col-sm-3" %>
<%= form.phone_field :guardian_phone, wrapper_class: "col-sm-6" %> <%= form.phone_field :guardian_phone, wrapper_class: "col-sm-6" %>
</div>
<div class="form-row">
<%= form.text_field :guardian_email, wrapper_class: "col-sm-6" %> <%= form.text_field :guardian_email, wrapper_class: "col-sm-6" %>
</div> </div>
<%= render "shared/address_fields", form: form, subject: "guardian" %> <%= render "shared/address_fields", form: form, subject: "guardian" %>
@@ -87,6 +83,48 @@
</div> </div>
<% end %> <% end %>
<hr>
<%= card_field_set_tag t(".guardian_2_info.heading") do %>
<div class="form-row">
<%= 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" %>
</div>
<%= render "shared/address_fields", form: form, subject: "guardian_2" %>
<% end %>
<hr>
<%= card_field_set_tag t(".guardian_2_photo.heading") do %>
<div class="alert alert-warning font-weight-bold"><%= t ".guardian_2_photo.instructions" %></div>
<div class="text-center">
<div class="d-inline-block mb-2" data-behavior="guardian-photo-preview" data-file-input="[data-ujs-target=guardian-2-photo-input]">
<div class="align-items-center d-flex photo-preview img-thumbnail justify-content-center">
<span><%= t ".guardian_2_photo.no_photo" %></span>
</div>
</div>
<div class="d-inline-block text-left">
<% if @talent_release.guardian_2_photo.attached? %>
<%= javascript_tag nonce: true do %>
App.PhotoPreview.set("[data-behavior=guardian-photo-preview]", "<%= url_for(@talent_release.guardian_2_photo.variant(auto_orient: true, resize: '200x200')) %>");
<% end %>
<% end %>
<div class="hidden-file-input">
<%= form.hidden_field :guardian_2_photo, value: form.object.guardian_2_photo.signed_id if @talent_release.guardian_2_photo.attached? %>
<%= form.file_field :guardian_2_photo, hide_label: true, data: { ujs_target: "guardian-2-photo-input" }, accept: @talent_release.class.face_photo_acceptable_content_types.join(","), direct_upload: true %>
</div>
<%= button_tag t(".guardian_2_photo.take_photo"), type: "button", class: "btn btn-lg btn-primary take-photo-button", data: { behavior: "trigger-click", target: "[data-ujs-target=guardian-2-photo-input]" } %>
</div>
<p class="p-2 font-weight-bold">
<%= fa_icon "arrow-up", text: t(".guardian_2_photo.camera_instructions_html") %><br>
<small class="text-muted"><%= t ".guardian_2_photo.warning" %></small>
</p>
</div>
<% end %>
<hr>
</div> </div>
<hr> <hr>

View File

@@ -458,6 +458,16 @@ en:
project: project:
predefined_client_name: Client predefined_client_name: Client
talent_release: talent_release:
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: City guardian_address_city: City
guardian_address_country: Guardian country guardian_address_country: Guardian country
guardian_address_state: State guardian_address_state: State
@@ -1011,6 +1021,16 @@ en:
notice: Your release has been signed. Thank you! notice: Your release has been signed. Thank you!
new: new:
cancel: Cancel cancel: Cancel
guardian_2_info:
heading: Second Guardian Information (if company requires)
guardian_2_photo:
camera_instructions_html: Click <em>Take Photo</em> to Turn ON Camera
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!
no_photo: No photo yet
take_photo: Take Photo
warning: If your photo appears sideways, it will be autocorrected when you submit your release.
guardian_clause: guardian_clause:
heading: Guardian Clause heading: Guardian Clause
guardian_info: guardian_info:

View File

@@ -194,6 +194,36 @@ es:
name: Nómbre del proyecto de vídeo name: Nómbre del proyecto de vídeo
producer_address: Dirección del productor producer_address: Dirección del productor
producer_name: Nómbre del productor producer_name: Nómbre del productor
talen_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 first name (ES)
guardian_2_last_name: Guardian 2 last name (ES)
guardian_2_phone: Guardian 2 phone (ES)
guardian_address_city: City (ES)
guardian_address_country: Guardian country (ES)
guardian_address_state: State (ES)
guardian_address_street1: Guardian address (ES)
guardian_address_street2: Guardian address (Line 2) (ES)
guardian_address_zip: Zip code (ES)
guardian_email: Guardian email address (ES)
guardian_name: Guardian name (ES)
guardian_phone: Guardian phone number (ES)
minor: Is the person a minor? (ES)
person_address_city: City (ES)
person_address_country: Country (ES)
person_address_state: State (ES)
person_address_street1: Address (ES)
person_address_street2: Address (Line 2) (ES)
person_address_zip: Zip code (ES)
person_email: Email address (ES)
person_name: Name (ES)
person_phone: Phone number (ES)
placeholder: placeholder:
appearance_release: appearance_release:
person_address: Calle, Número de apartamento, Ciudad, Estado, Código Postal person_address: Calle, Número de apartamento, Ciudad, Estado, Código Postal
@@ -281,6 +311,15 @@ es:
warning: Si su foto aparece de lado, se corregirá automáticamente cuando actualizar la autorización warning: Si su foto aparece de lado, se corregirá automáticamente cuando actualizar la autorización
talent_releases: talent_releases:
new: new:
guardian_2_info:
heading: Second Guardian Information (if company requires) (ES)
guardian_2_photo:
camera_instructions_html: ""
heading: Second Guardian Photo (ES)
instructions: ""
no_photo: ""
take_photo: ""
warning: ""
guardian_clause: guardian_clause:
heading: Guardian Clause (ES) heading: Guardian Clause (ES)
guardian_photo: guardian_photo:
@@ -290,6 +329,10 @@ es:
no_photo: No hay foto todavía no_photo: No hay foto todavía
take_photo: Take Photo (ES) take_photo: Take Photo (ES)
warning: (ES) If your photo appears sideways, it will be autocorrected when you submit your release. (ES) warning: (ES) If your photo appears sideways, it will be autocorrected when you submit your release. (ES)
photo:
heading: Photos (ES)
guardian_info:
heading: ""
teams: teams:
show: show:
choose_project: ¿Qué proyecto de la lista de abajo asistirá? choose_project: ¿Qué proyecto de la lista de abajo asistirá?

View File

@@ -0,0 +1,14 @@
class AddSecondGuardianFieldsToTalentReleases < ActiveRecord::Migration[6.0]
def change
add_column :talent_releases, :guardian_2_first_name, :string
add_column :talent_releases, :guardian_2_last_name, :string
add_column :talent_releases, :guardian_2_email, :string
add_column :talent_releases, :guardian_2_phone, :string
add_column :talent_releases, :guardian_2_address_street1, :string
add_column :talent_releases, :guardian_2_address_street2, :string
add_column :talent_releases, :guardian_2_address_city, :string
add_column :talent_releases, :guardian_2_address_state, :string
add_column :talent_releases, :guardian_2_address_zip, :string
add_column :talent_releases, :guardian_2_address_country, :string
end
end

View File

@@ -1503,7 +1503,17 @@ CREATE TABLE public.talent_releases (
person_first_name character varying, person_first_name character varying,
person_last_name character varying, person_last_name character varying,
guardian_first_name character varying, guardian_first_name character varying,
guardian_last_name character varying guardian_last_name 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
); );
@@ -3812,6 +3822,7 @@ INSERT INTO "schema_migrations" (version) VALUES
('20200619081446'), ('20200619081446'),
('20200619085823'), ('20200619085823'),
('20200619134853'), ('20200619134853'),
('20200622180507'); ('20200622180507'),
('20200625144713');

View File

@@ -62,6 +62,47 @@ feature "User managing talent releases" do
expect(page).to have_content("Your release was successfully submitted. Thank you.") expect(page).to have_content("Your release was successfully submitted. Thank you.")
end end
scenario "creating a release for a minor with two guardians", js: true do
contract_template = create(:contract_template, project: project)
visit new_account_project_contract_template_talent_release_path(project.account, project, contract_template)
expect(page).not_to have_content guardian_information_heading.upcase
expect(page).not_to have_content guardian_2_information_heading.upcase
expect(page).not_to have_content guardian_photo_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_heading.upcase
expect(page).to have_content guardian_2_information_heading.upcase
expect(page).to have_content guardian_photo_heading.upcase
expect(page).to have_content guardian_2_photo_heading.upcase
fill_in person_first_name_field, with: "Jane"
fill_in person_last_name_field, with: "Doe"
fill_in person_address_field, with: "123 Test Lane, New York, NY 10000"
fill_in person_phone_field, with: "555-555-5555"
fill_in person_email_field, with: "jane.doe@test.com"
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 guardian_2_first_name_field, with: "Second"
fill_in guardian_2_last_name_field, with: "Guardian"
drop_file Rails.root.join(file_fixture("person_photo.png")), type: :dropzone
attach_file guardian_photo_field, file_fixture("hemsworth.jpeg"), visible: :all
attach_file guardian_2_photo_field, file_fixture("person_photo.png"), visible: :all
draw_signature file_fixture("signature.png"), "talent_release_signature_base64"
click_button submit_button
expect(page).to have_content success_submit_message
expect(TalentRelease.last.guardian_2_photo.attached?).to eq true
expect(TalentRelease.last.guardian_2_name).to eq "Second Guardian"
end
end end
context "when signed in" do context "when signed in" do
@@ -301,6 +342,14 @@ feature "User managing talent releases" do
"Guardian last name" "Guardian last name"
end end
def guardian_2_first_name_field
"talent_release[guardian_2_first_name]"
end
def guardian_2_last_name_field
"talent_release[guardian_2_last_name]"
end
def guardian_phone_field def guardian_phone_field
"Guardian phone" "Guardian phone"
end end
@@ -309,6 +358,10 @@ feature "User managing talent releases" do
"talent_release[guardian_photo]" "talent_release[guardian_photo]"
end end
def guardian_2_photo_field
"talent_release[guardian_2_photo]"
end
def have_photo_button def have_photo_button
have_selector(".take-photo-button") have_selector(".take-photo-button")
end end
@@ -387,4 +440,28 @@ feature "User managing talent releases" do
select "Other", from: "Restriction" select "Other", from: "Restriction"
fill_in "Describe other restrictions", with: "Test" fill_in "Describe other restrictions", with: "Test"
end end
def guardian_information_heading
t 'public.talent_releases.new.guardian_info.heading'
end
def guardian_2_information_heading
t 'public.talent_releases.new.guardian_2_info.heading'
end
def guardian_photo_heading
t 'public.talent_releases.new.guardian_photo.heading'
end
def guardian_2_photo_heading
t 'public.talent_releases.new.guardian_2_photo.heading'
end
def submit_button
t 'shared.submit_release_long'
end
def success_submit_message
"Your release was successfully submitted. Thank you."
end
end end