From f4899ae6b04c31265b3240c0d34d1dc549736cc1 Mon Sep 17 00:00:00 2001 From: Bilal Date: Mon, 7 Sep 2020 15:55:12 +0300 Subject: [PATCH 1/2] show person photo in appearance release pdf --- spec/features/user_managing_appearance_releases_spec.rb | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/spec/features/user_managing_appearance_releases_spec.rb b/spec/features/user_managing_appearance_releases_spec.rb index ad73acb..ee71aae 100644 --- a/spec/features/user_managing_appearance_releases_spec.rb +++ b/spec/features/user_managing_appearance_releases_spec.rb @@ -684,6 +684,15 @@ feature 'User managing appearance releases' do expect(page).to have_selector("#top-person-photo[src^='#{person_photo_url}']") end + scenario "viewing the contract PDF - it shows person photo on first page if person photo is attached" do + appearance_release = create(:appearance_release_with_contract_template, :native, :minor_with_guardian_photo, project: project) + + visit view_release_pdf_html_preview_link_for(appearance_release) + + person_photo_url = url_for(appearance_release.person_photo.variant(auto_orient: true, resize: "200x200")).to_s + expect(page).to have_selector("#top-person-photo[src^='#{person_photo_url}']") + end + scenario 'deleting a release', js: true do appearance_release = create(:appearance_release, project: project) -- 2.47.3 From ed7d8511d5e5d4a9d82abc0d0a6ab2e27b55d816 Mon Sep 17 00:00:00 2001 From: Bilal Date: Wed, 9 Sep 2020 14:23:51 +0300 Subject: [PATCH 2/2] fix MR comments --- app/views/contracts/_logo_page.html.erb | 37 +++++++++++++++++++++++++ app/views/contracts/pdf.html.erb | 33 ++++------------------ 2 files changed, 43 insertions(+), 27 deletions(-) create mode 100644 app/views/contracts/_logo_page.html.erb diff --git a/app/views/contracts/_logo_page.html.erb b/app/views/contracts/_logo_page.html.erb new file mode 100644 index 0000000..307471e --- /dev/null +++ b/app/views/contracts/_logo_page.html.erb @@ -0,0 +1,37 @@ +<% has_logo = local_assigns[:logo] %> +<% has_user_photo = releasable.model_name == "AppearanceRelease" && releasable.person_photo.attached? %> + +<% if has_logo || has_user_photo %> + + + + + +
+ <% if has_logo %> + + <% end %> + + <% if has_user_photo %> + <%= image_tag releasable.photos.first.variant(auto_orient: true, resize: "200x200"), id: "top-person-photo" %> + <% end %> +
+ +
+<% end %> + +<% if preview %> +

PREVIEW ONLY

+<% end %> + +<% if contract_template.body.present? %> + <%= contract_template.body %> +
+<% end %> + +<% if releasable.minor? && contract_template.guardian_clause.present? %> +

Guardian Clause

+ <%= contract_template.guardian_clause %> +<% end %> \ No newline at end of file diff --git a/app/views/contracts/pdf.html.erb b/app/views/contracts/pdf.html.erb index c354ed5..fcc565f 100644 --- a/app/views/contracts/pdf.html.erb +++ b/app/views/contracts/pdf.html.erb @@ -1,33 +1,12 @@ -<% if local_assigns[:logo] %> -