diff --git a/app/assets/javascripts/photo_preview.js b/app/assets/javascripts/photo_preview.js index 34c4543..3f0cbb8 100644 --- a/app/assets/javascripts/photo_preview.js +++ b/app/assets/javascripts/photo_preview.js @@ -57,7 +57,4 @@ $(document).on("turbolinks:load", function() { $("[data-behavior=take-guardian-photo]").click(function(e) { $("[data-ujs-target=guardian-photo-input]").trigger("click"); }); - $("[data-behavior=take-guardian-2-photo]").click(function(e) { - $("[data-ujs-target=guardian-2-photo-input]").trigger("click"); - }); }); diff --git a/app/controllers/contract_templates_controller.rb b/app/controllers/contract_templates_controller.rb index 6e09308..5f3fbc6 100644 --- a/app/controllers/contract_templates_controller.rb +++ b/app/controllers/contract_templates_controller.rb @@ -66,7 +66,10 @@ class ContractTemplatesController < ApplicationController :question_3_text, :question_4_text, :question_5_text, :question_6_text, :question_7_text, :question_8_text, - :question_9_text, :question_10_text) + :question_9_text, :question_10_text, + :question_11_text, :question_12_text, + :question_13_text, :question_14_text, + :question_15_text) end def download_attributes diff --git a/app/controllers/public/appearance_releases_controller.rb b/app/controllers/public/appearance_releases_controller.rb index 17d5464..419fcd1 100644 --- a/app/controllers/public/appearance_releases_controller.rb +++ b/app/controllers/public/appearance_releases_controller.rb @@ -71,25 +71,8 @@ class Public::AppearanceReleasesController < Public::BaseController ] 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 - def appearance_release_params params.require(:appearance_release).permit(person_params, guardian_params, - second_guardian_params, :minor, :signature_base64, :person_date_of_birth, :locale, :contract_template) diff --git a/app/controllers/public/medical_releases_controller.rb b/app/controllers/public/medical_releases_controller.rb index 7645582..097a607 100644 --- a/app/controllers/public/medical_releases_controller.rb +++ b/app/controllers/public/medical_releases_controller.rb @@ -53,7 +53,9 @@ class Public::MedicalReleasesController < Public::BaseController :question_5_answer, :question_6_answer, :question_7_answer, :question_8_answer, :question_9_answer, :question_10_answer, - photos: [], + :question_11_answer, :question_12_answer, + :question_13_answer, :question_14_answer, + :question_15_answer, photos: [], ) end diff --git a/app/helpers/dropzone_helper.rb b/app/helpers/dropzone_helper.rb index bdd32f4..1b03afc 100644 --- a/app/helpers/dropzone_helper.rb +++ b/app/helpers/dropzone_helper.rb @@ -2,7 +2,7 @@ module DropzoneHelper def dropzone_placeholder_message_for(releasable) case releasable.model_name.param_key when "acquired_media_release" - "To Add Photos & Videos to the release:
Drag & Drop Files
or
Click or Tap here to browse photos and connect to Camera" + '(Optional) To add the licensed photos or videos ("Property") to this release:
Drag & Drop Files
or
Click or Tap here to browse photos and connect to Camera' when "material_release" t 'material_releases.form.photos.dropzone_label' when "music_release" diff --git a/app/models/appearance_release.rb b/app/models/appearance_release.rb index 9a750a7..078eefd 100644 --- a/app/models/appearance_release.rb +++ b/app/models/appearance_release.rb @@ -12,9 +12,7 @@ class AppearanceRelease < ApplicationRecord include Taggable include PersonName include GuardianPhotoable - include SecondGuardianPhotoable include GuardianName - include SecondGuardianName has_one_attached :person_photo @@ -40,17 +38,6 @@ class AppearanceRelease < ApplicationRecord %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] - ] - # These validations apply to all releases validates :person_email, email: true, allow_blank: true @@ -145,10 +132,6 @@ class AppearanceRelease < ApplicationRecord true end - def second_guardian_present? - self.guardian_2_first_name.present? - 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/models/concerns/second_guardian_name.rb b/app/models/concerns/second_guardian_name.rb deleted file mode 100644 index 8e4e04d..0000000 --- a/app/models/concerns/second_guardian_name.rb +++ /dev/null @@ -1,20 +0,0 @@ -module SecondGuardianName - extend ActiveSupport::Concern - - included do - def guardian_2_name - "#{guardian_2_first_name} #{guardian_2_last_name}".titleize - end - - def guardian_2_name=(value) - if value.include?(' ') - split = value.split(" ", 2) - self.guardian_2_first_name = split.first - self.guardian_2_last_name = split.last - else - self.guardian_2_first_name = value - self.guardian_2_last_name = "(Not Given)" - end - end - end -end diff --git a/app/models/concerns/second_guardian_photoable.rb b/app/models/concerns/second_guardian_photoable.rb deleted file mode 100644 index 5e21240..0000000 --- a/app/models/concerns/second_guardian_photoable.rb +++ /dev/null @@ -1,9 +0,0 @@ -module SecondGuardianPhotoable - extend ActiveSupport::Concern - - included do - has_one_attached :guardian_2_photo - - validates :guardian_2_photo, content_type: ["image/png", "image/jpeg"] - end -end diff --git a/app/models/medical_release.rb b/app/models/medical_release.rb index 512c75c..4967ef9 100644 --- a/app/models/medical_release.rb +++ b/app/models/medical_release.rb @@ -8,6 +8,8 @@ class MedicalRelease < ApplicationRecord include Syncable include PersonName + NUMBER_OF_CUSTOM_FIELDS = 15 + composed_of :person_address, class_name: "Address", mapping: [ diff --git a/app/views/contracts/_photos.html.erb b/app/views/contracts/_photos.html.erb index 242881c..6f429f7 100644 --- a/app/views/contracts/_photos.html.erb +++ b/app/views/contracts/_photos.html.erb @@ -5,9 +5,6 @@ <% if release.respond_to? :guardian_photo %> <% @total_photos_count += release.guardian_photo.attached? ? 1 : 0 %> <% end %> -<% if release.respond_to? :guardian_2_photo %> - <% @total_photos_count += release.guardian_2_photo.attached? ? 1 : 0 %> -<% end %>

<%= t '.heading', count: @total_photos_count %>

diff --git a/app/views/contracts/_signature_page.html.erb b/app/views/contracts/_signature_page.html.erb index 25d92ba..28ef969 100644 --- a/app/views/contracts/_signature_page.html.erb +++ b/app/views/contracts/_signature_page.html.erb @@ -40,7 +40,7 @@ <% if releasable.model_name == "MedicalRelease" %> - <% (1..10).each do |n| %> + <% (1..MedicalRelease::NUMBER_OF_CUSTOM_FIELDS).each do |n| %> <% if contract_template.public_send("question_#{n}_text").present? %>

<%= contract_template.public_send("question_#{n}_text") %>

<%= releasable.public_send("question_#{n}_answer") %>

@@ -69,19 +69,4 @@ <%= description_list_pair_for releasable, :signed_on, append: ":" %> - <% if releasable.respond_to?(:second_guardian_present?) && releasable.second_guardian_present? %> - -
-

Second guardian Information

- - <% # Second guardian information %> -
- <%= description_list_pair_for releasable, :guardian_2_name, append: ":" %> - <%= description_list_pair_for releasable, :guardian_2_address, append: ":" %> - <%= description_list_pair_for releasable, :guardian_2_phone, append: ":" %> - <%= description_list_pair_for releasable, :guardian_2_email, append: ":" %> -
- - <% end %> - <% end %> diff --git a/app/views/public/acquired_media_releases/new.html.erb b/app/views/public/acquired_media_releases/new.html.erb index abffa38..a61ddea 100644 --- a/app/views/public/acquired_media_releases/new.html.erb +++ b/app/views/public/acquired_media_releases/new.html.erb @@ -44,10 +44,6 @@
<%= card_field_set_tag t(".files.heading") do %> -
- <%= fa_icon "warning" %> - For optimal accuracy, please ensure video file names and photo file names match the source file name in the editing sequence. -
<%= render "shared/file_infos_dropzone", form: form, releasable: @acquired_media_release %> <% end %> diff --git a/app/views/public/appearance_releases/new.html.erb b/app/views/public/appearance_releases/new.html.erb index f23960f..99d4c40 100644 --- a/app/views/public/appearance_releases/new.html.erb +++ b/app/views/public/appearance_releases/new.html.erb @@ -113,49 +113,6 @@
- <%= 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 @appearance_release.guardian_2_photo.attached? %> - <%= javascript_tag nonce: true do %> - App.PhotoPreview.set("[data-behavior=guardian-photo-preview]", "<%= url_for(@appearance_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 @appearance_release.guardian_2_photo.attached? %> - <%= form.file_field :guardian_2_photo, hide_label: true, data: { ujs_target: "guardian-2-photo-input" }, accept: @appearance_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 %> diff --git a/app/views/public/medical_releases/new.html.erb b/app/views/public/medical_releases/new.html.erb index 918a5a9..bebb04b 100644 --- a/app/views/public/medical_releases/new.html.erb +++ b/app/views/public/medical_releases/new.html.erb @@ -14,9 +14,9 @@
- <% if (1..10).map {|n| @contract_template.public_send("question_#{n}_text").presence }.compact.any? %> + <% 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 %> - <% (1..10).each do |n| %> + <% (1..MedicalRelease::NUMBER_OF_CUSTOM_FIELDS).each do |n| %> <% if @contract_template.public_send("question_#{n}_text").present? %>
<%= form.text_area "question_#{n}_answer", wrapper_class: "col-sm-12", label: @contract_template.public_send("question_#{n}_text") %> diff --git a/app/views/shared/_custom_fields.html.erb b/app/views/shared/_custom_fields.html.erb index 48f729a..bdf2f9b 100644 --- a/app/views/shared/_custom_fields.html.erb +++ b/app/views/shared/_custom_fields.html.erb @@ -1,4 +1,4 @@ -<% (1..10).each do |n| %> +<% (1..MedicalRelease::NUMBER_OF_CUSTOM_FIELDS).each do |n| %>
<%= form.text_area "question_#{n}_text", wrapper_class: "col-sm-12" %>
diff --git a/config/locales/en.yml b/config/locales/en.yml index bc7cd23..1ee2770 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -60,10 +60,6 @@ en: activerecord: attributes: appearance_release: - guardian_2_address: Second guardian address - guardian_2_email: Second guardian email - guardian_2_name: Second guardian name - guardian_2_phone: Second guardian phone person_address: Address person_email: Email person_name: Name @@ -241,7 +237,6 @@ en: heading: New Release Template contracts: photos: - guardian_2_photo_heading: Second guardian photo guardian_photo_heading: Guardian photo heading: one: Photo @@ -316,8 +311,8 @@ en: graphics_only_edl_file: If you do not upload a Graphics Only EDL, the software will not generate a Graphics Cue List. label: acquired_media_release: - description: Description of licensed property - name: Name of licensed property + description: Description of property + name: Name of property person_address: Address person_address_city: City person_address_country: Country @@ -333,16 +328,6 @@ en: person_phone: Phone number person_title: Title appearance_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 @@ -815,12 +800,6 @@ 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: diff --git a/config/locales/es.yml b/config/locales/es.yml index 6ce2858..82258a2 100644 --- a/config/locales/es.yml +++ b/config/locales/es.yml @@ -66,7 +66,6 @@ es: heading: Release Info (ES) contracts: photos: - guardian_2_photo_heading: Second guardian photo (ES) guardian_photo_heading: Guardian photo (ES) heading: one: Photo (ES) @@ -116,16 +115,6 @@ 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_address_city: Guardian city (ES) guardian_address_country: Guardian country (ES) guardian_address_state: Guardian state (ES) @@ -178,12 +167,6 @@ es: notice: La autorización está firmada. ¡Gracias! new: cancel: Cancelar - 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_photo: diff --git a/db/migrate/20200619081446_add_more_questions_and_answers_to_medical_releases.rb b/db/migrate/20200619081446_add_more_questions_and_answers_to_medical_releases.rb new file mode 100644 index 0000000..3696559 --- /dev/null +++ b/db/migrate/20200619081446_add_more_questions_and_answers_to_medical_releases.rb @@ -0,0 +1,15 @@ +class AddMoreQuestionsAndAnswersToMedicalReleases < ActiveRecord::Migration[6.0] + def change + add_column :contract_templates, :question_11_text, :text + add_column :contract_templates, :question_12_text, :text + add_column :contract_templates, :question_13_text, :text + add_column :contract_templates, :question_14_text, :text + add_column :contract_templates, :question_15_text, :text + + add_column :medical_releases, :question_11_answer, :text + add_column :medical_releases, :question_12_answer, :text + add_column :medical_releases, :question_13_answer, :text + add_column :medical_releases, :question_14_answer, :text + add_column :medical_releases, :question_15_answer, :text + end +end diff --git a/db/migrate/20200619134853_add_second_guardian_fields_to_appearance_releases.rb b/db/migrate/20200619134853_add_second_guardian_fields_to_appearance_releases.rb deleted file mode 100644 index a067b44..0000000 --- a/db/migrate/20200619134853_add_second_guardian_fields_to_appearance_releases.rb +++ /dev/null @@ -1,14 +0,0 @@ -class AddSecondGuardianFieldsToAppearanceReleases < ActiveRecord::Migration[6.0] - def change - add_column :appearance_releases, :guardian_2_first_name, :string - add_column :appearance_releases, :guardian_2_last_name, :string - add_column :appearance_releases, :guardian_2_email, :string - add_column :appearance_releases, :guardian_2_phone, :string - add_column :appearance_releases, :guardian_2_address_street1, :string - add_column :appearance_releases, :guardian_2_address_street2, :string - add_column :appearance_releases, :guardian_2_address_city, :string - add_column :appearance_releases, :guardian_2_address_state, :string - add_column :appearance_releases, :guardian_2_address_zip, :string - add_column :appearance_releases, :guardian_2_address_country, :string - end -end diff --git a/db/structure.sql b/db/structure.sql index 972fe4c..d3f8386 100644 --- a/db/structure.sql +++ b/db/structure.sql @@ -9,6 +9,20 @@ SET xmloption = content; SET client_min_messages = warning; SET row_security = off; +-- +-- Name: plpgsql; Type: EXTENSION; Schema: -; Owner: - +-- + +CREATE EXTENSION IF NOT EXISTS plpgsql WITH SCHEMA pg_catalog; + + +-- +-- Name: EXTENSION plpgsql; Type: COMMENT; Schema: -; Owner: - +-- + +COMMENT ON EXTENSION plpgsql IS 'PL/pgSQL procedural language'; + + -- -- Name: fuzzystrmatch; Type: EXTENSION; Schema: -; Owner: - -- @@ -328,17 +342,7 @@ CREATE TABLE public.appearance_releases ( 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 + guardian_address_country character varying ); @@ -624,7 +628,12 @@ CREATE TABLE public.contract_templates ( question_7_text text, question_8_text text, question_9_text text, - question_10_text text + question_10_text text, + question_11_text text, + question_12_text text, + question_13_text text, + question_14_text text, + question_15_text text ); @@ -1014,7 +1023,12 @@ CREATE TABLE public.medical_releases ( question_7_answer text, question_8_answer text, question_9_answer text, - question_10_answer text + question_10_answer text, + question_11_answer text, + question_12_answer text, + question_13_answer text, + question_14_answer text, + question_15_answer text ); @@ -3677,6 +3691,6 @@ INSERT INTO "schema_migrations" (version) VALUES ('20200615131722'), ('20200615133602'), ('20200616124214'), -('20200619134853'); +('20200619081446'); diff --git a/spec/features/user_managing_appearance_releases_spec.rb b/spec/features/user_managing_appearance_releases_spec.rb index 8eba877..33e1eb3 100644 --- a/spec/features/user_managing_appearance_releases_spec.rb +++ b/spec/features/user_managing_appearance_releases_spec.rb @@ -72,61 +72,6 @@ feature 'User managing appearance releases' do 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_appearance_release_path(project.account, project, contract_template) - - expect(page).to have_photo_button - 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' - fill_in person_date_of_birth, with: '01/01/1999' - attach_file person_photo_field, file_fixture('person_photo.png'), visible: :all - attach_file guardian_photo_field, file_fixture('hemsworth.jpeg'), visible: :all - draw_signature file_fixture('signature.png'), 'appearance_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'), 'appearance_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(AppearanceRelease.last.guardian_2_first_name).to eq 'Second' - end end context 'when signed in' do @@ -509,18 +454,6 @@ feature 'User managing appearance releases' do 'appearance_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 - def guardian_first_name_field 'Guardian first name' end