Compare commits

...

5 Commits

Author SHA1 Message Date
bilal
13084cc4a3 fix MR comments 2020-06-18 09:47:40 +02:00
bilal
fd2b33039c fix MR comments 2020-06-18 09:39:38 +02:00
bilal
0c669ab3f3 rebase master 2020-06-17 15:06:30 +02:00
bilal
f2b6bf8351 use guardian_address_street1 for old guardian_address 2020-06-17 15:00:59 +02:00
bilal
50d8ea158e destructure guardian address field for appearance release 2020-06-17 15:00:22 +02:00
13 changed files with 96 additions and 14 deletions

View File

@@ -78,7 +78,7 @@ class AppearanceReleasesController < ApplicationController
end end
def appearance_release_params def appearance_release_params
params.require(:appearance_release).permit(:contract, :guardian_address, :guardian_first_name, :guardian_last_name, :guardian_phone, :guardian_photo, :guardian_email, :minor, params.require(:appearance_release).permit(:contract, :guardian_address_street1, :guardian_first_name, :guardian_last_name, :guardian_phone, :guardian_photo, :guardian_email, :minor,
:person_address, :person_first_name, :person_last_name, :person_phone, :person_email, :person_photo, :person_address, :person_first_name, :person_last_name, :person_phone, :person_email, :person_photo,
:applicable_medium_id, :applicable_medium_text, :applicable_medium_id, :applicable_medium_text,
:territory_id, :territory_text, :territory_id, :territory_text,

View File

@@ -39,9 +39,25 @@ class Public::AppearanceReleasesController < Public::BaseController
authorize appearance_releases.build(params) authorize appearance_releases.build(params)
end 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 appearance_release_params def appearance_release_params
params.require(:appearance_release).permit(:person_address, :person_first_name, :person_last_name, :person_phone, :person_email, :person_photo, params.require(:appearance_release).permit(:person_address, :person_first_name, :person_last_name, :person_phone, :person_email, :person_photo,
:guardian_address, :guardian_first_name, :guardian_last_name, :guardian_phone, :guardian_email, :guardian_photo, :minor, guardian_params, :minor,
:signature_base64, :person_date_of_birth, :signature_base64, :person_date_of_birth,
:locale, :contract_template,) :locale, :contract_template,)
end end

View File

@@ -16,6 +16,18 @@ class AppearanceRelease < ApplicationRecord
has_one_attached :person_photo has_one_attached :person_photo
composed_of :guardian_address,
class_name: 'Address',
mapping: [
%w[guardian_address_street1 street1],
%w[guardian_address_street2 street2],
%w[guardian_address_city city],
%w[guardian_address_state state],
%w[guardian_address_zip zip],
%w[guardian_address_country country]
]
# These validations apply to all releases # These validations apply to all releases
validates :person_email, email: true, allow_blank: true validates :person_email, email: true, allow_blank: true
validates :person_first_name, :person_last_name, presence: true validates :person_first_name, :person_last_name, presence: true

View File

@@ -23,7 +23,7 @@
<%= form.phone_field :guardian_phone, wrapper_class: "col-sm-6" %> <%= form.phone_field :guardian_phone, wrapper_class: "col-sm-6" %>
</div> </div>
<div class="form-row"> <div class="form-row">
<%= form.text_field :guardian_address, wrapper_class: "col-sm-6" %> <%= form.text_field :guardian_address_street1, wrapper_class: "col-sm-6" %>
</div> </div>
</div> </div>
<% end %> <% end %>

View File

@@ -79,9 +79,7 @@
<div class="form-row"> <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>
<div class="form-row"> <%= render "shared/address_fields", form: form, subject: "guardian" %>
<%= form.text_field :guardian_address, wrapper_class: "col-sm-6" %>
</div>
<% end %> <% end %>
<hr> <hr>

View File

@@ -336,6 +336,12 @@ en:
person_last_name: Last name person_last_name: Last name
person_name: Name person_name: Name
person_phone: Phone number person_phone: Phone number
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
location_release: location_release:
address_city: City address_city: City
address_country: Country address_country: Country

View File

@@ -115,7 +115,6 @@ es:
helpers: helpers:
label: label:
appearance_release: appearance_release:
guardian_address: Dirección del tutor legal
guardian_name: Nómbre del tutor legal guardian_name: Nómbre del tutor legal
guardian_phone: Número de teléfono del tutor legal guardian_phone: Número de teléfono del tutor legal
minor: El firmante es un menor minor: El firmante es un menor
@@ -123,6 +122,12 @@ es:
person_email: Dirección de correo electrónico person_email: Dirección de correo electrónico
person_name: Nómbre person_name: Nómbre
person_phone: Número de teléfono person_phone: Número de teléfono
guardian_address_city: Guardian city (ES)
guardian_address_country: Guardian country (ES)
guardian_address_state: Guardian state (ES)
guardian_address_street1: Dirección del tutor legal
guardian_address_street2: Dirección del tutor legal (Línea 2)
guardian_address_zip: Guardian zip code (ES)
project: project:
client_name: Nómbre del cliente del proyecto client_name: Nómbre del cliente del proyecto
description: Descripción del proyecto description: Descripción del proyecto

View File

@@ -0,0 +1,10 @@
class DestructureGuardianAddressColumnInAppearanceReleases < ActiveRecord::Migration[6.0]
def change
rename_column :appearance_releases, :guardian_address, :guardian_address_street1
add_column :appearance_releases, :guardian_address_street2, :string
add_column :appearance_releases, :guardian_address_city, :string
add_column :appearance_releases, :guardian_address_state, :string
add_column :appearance_releases, :guardian_address_zip, :string
add_column :appearance_releases, :guardian_address_country, :string
end
end

View File

@@ -296,7 +296,7 @@ CREATE TABLE public.appearance_releases (
created_at timestamp without time zone NOT NULL, created_at timestamp without time zone NOT NULL,
updated_at timestamp without time zone NOT NULL, updated_at timestamp without time zone NOT NULL,
minor boolean DEFAULT false, minor boolean DEFAULT false,
guardian_address character varying, guardian_address_street1 character varying,
guardian_name_old character varying, guardian_name_old character varying,
guardian_phone character varying, guardian_phone character varying,
person_email character varying, person_email character varying,
@@ -318,7 +318,12 @@ CREATE TABLE public.appearance_releases (
guardian_first_name character varying, guardian_first_name character varying,
guardian_last_name character varying, guardian_last_name character varying,
identifier character varying, identifier character varying,
guardian_email character varying guardian_email 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
); );
@@ -3654,6 +3659,7 @@ INSERT INTO "schema_migrations" (version) VALUES
('20200610085411'), ('20200610085411'),
('20200610140459'), ('20200610140459'),
('20200612121539'), ('20200612121539'),
('20200615131722'); ('20200615131722'),
('20200616124214');

View File

@@ -265,6 +265,9 @@ RSpec.describe AppearanceReleasesController, tye: :controller do
def minor_appearance_release_params def minor_appearance_release_params
attributes_for(:appearance_release, :non_native, :minor_with_guardian_photo) attributes_for(:appearance_release, :non_native, :minor_with_guardian_photo)
.except(:contract) .except(:contract)
.except(:guardian_address_street2).except(:guardian_address_city)
.except(:guardian_address_state).except(:guardian_address_zip)
.except(:guardian_address_country)
.merge(contract_param, exploitable_rights_params) .merge(contract_param, exploitable_rights_params)
end end

View File

@@ -120,7 +120,19 @@ describe Public::AppearanceReleasesController do
def minor_appearance_release_params(with_guardian_photo = true) def minor_appearance_release_params(with_guardian_photo = true)
minor_type = with_guardian_photo ? :minor_with_guardian_photo : :minor minor_type = with_guardian_photo ? :minor_with_guardian_photo : :minor
attributes_for(:appearance_release, minor_type).merge(signature_param) attributes_for(:appearance_release, minor_type)
.merge(signature_param, guardian_address_params)
end
def guardian_address_params
{
guardian_address_street1: "St1",
guardian_address_street2: "St2",
guardian_address_city: "City",
guardian_address_state: "State",
guardian_address_zip: "ZIP",
guardian_address_country: "Country"
}
end end
def signature_param def signature_param

View File

@@ -31,7 +31,12 @@ FactoryBot.define do
minor true minor true
guardian_first_name "Jamie" guardian_first_name "Jamie"
guardian_last_name "Doe" guardian_last_name "Doe"
guardian_address "100 Test Lane, New York, 10001" guardian_address_street1 "St1"
guardian_address_street2 "St2"
guardian_address_city "City"
guardian_address_state "State"
guardian_address_zip "ZIP"
guardian_address_country "Country"
guardian_phone "123-555-1234" guardian_phone "123-555-1234"
guardian_email "guardian@galaxy.all" guardian_email "guardian@galaxy.all"
end end
@@ -40,9 +45,14 @@ FactoryBot.define do
minor true minor true
guardian_first_name "Jamie" guardian_first_name "Jamie"
guardian_last_name "Doe" guardian_last_name "Doe"
guardian_address "100 Test Lane, New York, 10001"
guardian_phone "123-555-1234" guardian_phone "123-555-1234"
guardian_email "guardian@galaxy.all" guardian_email "guardian@galaxy.all"
guardian_address_street1 "St1"
guardian_address_street2 "St2"
guardian_address_city "City"
guardian_address_state "State"
guardian_address_zip "ZIP"
guardian_address_country "Country"
guardian_photo do guardian_photo do
path = Rails.root.join("spec", "fixtures", "files", "pratt.jpg") path = Rails.root.join("spec", "fixtures", "files", "pratt.jpg")
Rack::Test::UploadedFile.new(path, "image/jpeg") Rack::Test::UploadedFile.new(path, "image/jpeg")

View File

@@ -54,7 +54,11 @@ describe ContractTemplatePreview do
'person_phone' => '00 111 222 333 4444', 'person_phone' => '00 111 222 333 4444',
'updated_at' => nil, 'updated_at' => nil,
'minor' => true, 'minor' => true,
'guardian_address' => 'Street 3, Street 4, City-2, State-2 112233, Country-2', 'guardian_address_street1' => 'Street 3',
'guardian_address_street2' => 'Street 4',
'guardian_address_city' => 'City-2',
'guardian_address_state' => 'State-2',
'guardian_address_zip' => '112233',
"guardian_first_name" => nil, "guardian_first_name" => nil,
"guardian_last_name" => nil, "guardian_last_name" => nil,
"guardian_name_old" => nil, "guardian_name_old" => nil,