diff --git a/app/controllers/admin/casting_submissions_controller.rb b/app/controllers/admin/casting_submissions_controller.rb index f8cf5d1..e2f1e62 100644 --- a/app/controllers/admin/casting_submissions_controller.rb +++ b/app/controllers/admin/casting_submissions_controller.rb @@ -40,7 +40,7 @@ class Admin::CastingSubmissionsController < Admin::ApplicationController end def casting_submission_params - params.require(:casting_submission).permit(:casting_call_id, :performer_name, :interview_date, :zoom_meeting_url) + params.require(:casting_submission).permit(:casting_call_id, :performer_name, :interview_date, :zoom_meeting_url, :interview_recording) end def casting_submissions diff --git a/app/controllers/casting_calls_controller.rb b/app/controllers/casting_calls_controller.rb index c06d729..3763ea7 100644 --- a/app/controllers/casting_calls_controller.rb +++ b/app/controllers/casting_calls_controller.rb @@ -17,8 +17,7 @@ class CastingCallsController < ApplicationController if @casting_call.save log_create_analytics - castme_url = url_for([@project, @casting_call]) - SubmitHubspotFormJob.perform_later(email: @casting_call.user_email, castme_url: castme_url, form_guid: ENV["HUBSPOT_CASTING_CALL_REQUEST_FORM_GUID"]) + redirect_to [@project, :casting_calls], notice: t(".notice") else render :new end diff --git a/app/controllers/casting_submissions_controller.rb b/app/controllers/casting_submissions_controller.rb index e191276..bbed3fe 100644 --- a/app/controllers/casting_submissions_controller.rb +++ b/app/controllers/casting_submissions_controller.rb @@ -9,7 +9,9 @@ class CastingSubmissionsController < ApplicationController end def show - @files = @casting_submission.files.paginate(page: params[:page]) + @casting_call = @casting_submission.casting_call + @files = @casting_submission.files.order("created_at DESC").paginate(page: params[:files_page]) + render layout: 'application' end private diff --git a/app/models/casting_submission.rb b/app/models/casting_submission.rb index 6ac4f8f..d9262a7 100644 --- a/app/models/casting_submission.rb +++ b/app/models/casting_submission.rb @@ -1,6 +1,7 @@ class CastingSubmission < ApplicationRecord belongs_to :casting_call has_many_attached :files + has_one_attached :interview_recording has_secure_token diff --git a/app/views/admin/casting_submissions/_form.html.erb b/app/views/admin/casting_submissions/_form.html.erb index b615bc6..1d04c20 100644 --- a/app/views/admin/casting_submissions/_form.html.erb +++ b/app/views/admin/casting_submissions/_form.html.erb @@ -6,6 +6,21 @@ <%= form.text_field :interview_date, class: "datepicker-control" %> <%= form.text_field :zoom_meeting_url %> + <% unless casting_submission.new_record? %> + <%= form.file_field :interview_recording, accept: "video/*", data: { direct_upload_url: rails_direct_uploads_url, aws_bucket: ENV['AWS_BUCKET'], aws_access_key_id: ENV['AWS_ACCESS_KEY_ID'], signer_url: multipart_signatures_url } %> + + <% if casting_submission.interview_recording.attached? %> +

+ <%= link_to casting_submission.interview_recording do %> + <%= fa_icon "file-text-o" %> <%= casting_submission.interview_recording.filename %> + <% end %> + <%= fa_icon "long-arrow-left" %> Current interview recording +

+ <% end %> + + + <% end %> +
<%= link_to t("shared.cancel"), [:admin, :casting_submissions], class: "col-3 text-reset" %>
diff --git a/app/views/casting_calls/_form.html.erb b/app/views/casting_calls/_form.html.erb index b4e43a6..dbafe5a 100644 --- a/app/views/casting_calls/_form.html.erb +++ b/app/views/casting_calls/_form.html.erb @@ -9,7 +9,7 @@ <%= form.text_field :title %> <%= form.text_area :description %> <%= form.text_area :project_description %> - <%= field_set_tag "Chatbot" do %> + <%= field_set_tag t(".headings.chatbot") do %> <%= form.text_area :interview_instructions, rows: 6 %> <%= form.text_area :questions, rows: 8 %> <%= form.text_area :interview_requirements, rows: 6 %> diff --git a/app/views/casting_calls/create.html.erb b/app/views/casting_calls/create.html.erb deleted file mode 100644 index 9a52e24..0000000 --- a/app/views/casting_calls/create.html.erb +++ /dev/null @@ -1,2 +0,0 @@ -<%= render "shared/initiate_hubspot_chat" %> -

<%= t '.success_message' %>

diff --git a/app/views/casting_submissions/_file.html.erb b/app/views/casting_submissions/_file.html.erb index 85fe6bb..b0c90a8 100644 --- a/app/views/casting_submissions/_file.html.erb +++ b/app/views/casting_submissions/_file.html.erb @@ -1,6 +1,12 @@ - - <%= file.filename %> - - <%= link_to fa_icon("download"), file, target: "_blank" %> - - +
  • + <% if file.variable? %> + <%= link_to image_tag(file.variant(resize_and_pad: [300, 300, background: "#F7F8F9"]), class: "bg-light img-thumbnail img-fluid"), file, target: "_blank" %> + <% else %> +
    + <%= link_to file, target: "_blank" do %> + <%= fa_icon("file", style: "font-size: 2rem") %> +
    <%= file.filename %>
    + <% end %> +
    + <% end %> +
  • diff --git a/app/views/casting_submissions/_files_section.html.erb b/app/views/casting_submissions/_files_section.html.erb new file mode 100644 index 0000000..bc4d644 --- /dev/null +++ b/app/views/casting_submissions/_files_section.html.erb @@ -0,0 +1,14 @@ +
    +
      + <% if files.present? %> + <%= render partial: "casting_submissions/file", collection: files %> + <% else %> +
    • + Files will appear here. +
    • + <% end %> +
    +
    + <%= will_paginate(files, param_name: 'files_page', params: { active_files_tab: casting_submission.id }) if files.present? %> +
    +
    diff --git a/app/views/casting_submissions/_video.html.erb b/app/views/casting_submissions/_video.html.erb new file mode 100644 index 0000000..2eadb93 --- /dev/null +++ b/app/views/casting_submissions/_video.html.erb @@ -0,0 +1,15 @@ +<% if casting_submission.interview_recording.present? %> +
    +<% else %> +
    + + + + + + +
    + Video player will appear here when the interview recording is available. +
    +
    +<% end %> \ No newline at end of file diff --git a/app/views/casting_submissions/show.html.erb b/app/views/casting_submissions/show.html.erb index 727d285..e270e1d 100644 --- a/app/views/casting_submissions/show.html.erb +++ b/app/views/casting_submissions/show.html.erb @@ -1,25 +1,79 @@ -
    -

    Files:

    -
    - - - - - - - - - <% if @files.any? %> - <%= render partial: "file", collection: @files %> - <% else %> - - - - <% end %> - -
    Filename
    <%= t(".empty") %>
    -
    - <%= will_paginate @files %> +<% content_for :header do %> +
    +
    +
    + <%= product_wordmark(:cast_me, class: 'navbar-brand') %> +
    +
    +
    +<% end %> + +
    +
    +
    +
    +
    +

    <%= @casting_submission.performer_name %>

    +

    <%= @casting_call.title %>

    +
    +
    +
    +
    + <%= render partial: 'casting_submissions/video', locals: { casting_submission: @casting_submission } %> + <% if @casting_submission.interview_recording.present? %> + <%= javascript_tag nonce: true do %> + new Clappr.Player({ + parentId: '#casting_submission_video', + source: "<%= rails_blob_url(@casting_submission.interview_recording, host: AppHost.new.domain_with_port) %>", + width: '100%', + height: '100%', + mute: true, + autoPlay: true, + hlsMinimumDvrSize: 1 + }); + <% end %> + <% end %> +
    +
    -
    \ No newline at end of file +
    +
    +
    + +
    +
    +
    +
    !params[:active_tab].present?) %>" id="home"> +
    +
    +
    + <%= description_list_pair_for @casting_call, :title, append: ":" %> + <%= description_list_pair_for @casting_call, :status, append: ":" %> + <%= description_list_pair_for @casting_call, :created_at, append: ":" %> + <%= description_list_pair_for @casting_call, :description, append: ":" %> + <%= description_list_pair_for @casting_call, :project_description, append: ":" %> + <%= description_list_pair_for @casting_call, :interview_instructions, append: ":" %> + <%= description_list_pair_for @casting_call, :interview_requirements, append: ":" %> + <%= description_list_pair_for @casting_call, :questions, append: ":" %> +
    +
    +
    +
    +
    params[:active_tab] == 'files') %>" id="files"> +
    + <%= render partial: 'casting_submissions/files_section', locals: { casting_submission: @casting_submission, files: @files } %> +
    +
    +
    +
    +
    +
    +
    diff --git a/app/views/public/casting_calls/show.html.erb b/app/views/public/casting_calls/show.html.erb index ae634f7..c9ec824 100644 --- a/app/views/public/casting_calls/show.html.erb +++ b/app/views/public/casting_calls/show.html.erb @@ -12,20 +12,11 @@ <%= card_header text: @casting_call.title %>
    -
    +
    <%= description_list_pair_for @casting_call, :title, append: ":" %> <%= description_list_pair_for @casting_call, :description, append: ":" %> <%= description_list_pair_for @casting_call, :project_description, append: ":" %> - <%= description_list_pair_for @casting_call, :created_at, append: ":" %> -
    -
    -
    -
    - <%= description_list_pair_for @casting_call, :status, append: ":" %> - <%= description_list_pair_for @casting_call, :interview_instructions, append: ":" %> - <%= description_list_pair_for @casting_call, :interview_requirements, append: ":" %> - <%= description_list_pair_for @casting_call, :questions, append: ":" %>
    diff --git a/config/locales/en.yml b/config/locales/en.yml index 00cf46b..c271801 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -247,13 +247,6 @@ en: bulk_taggings: new_bulk_tag_modal: submit: Add - casting_submissions: - index: - empty: Casting Submission results will appear here. - show: - empty: Casting Submission files and recorded meeetings will appear here. - validation_errors: - invalid_meeting_url: Zoom Meeting URL is invalid casting_calls: cancel: notice: The casting call request has been cancelled successfully @@ -261,11 +254,12 @@ en: actions: manage: Manage create: - notice: The casting call request has been created - success_message: Your casting call request was successfully submitted. Thank you. A chat window will pop up on the lower right in a few seconds. + notice: The casting call request has been created successfully. edit: heading: Edit Casting Call form: + headings: + chatbot: Chatbot Instructions info_message: After submitting this casting call request, you'll be connected via chat with a ME Suite representative. index: actions: @@ -289,6 +283,13 @@ en: empty: Casting Submission results will appear here. show: empty: Casting Submission files and recorded meeetings will appear here. + casting_submissions: + index: + empty: Casting Submission results will appear here. + show: + empty: Casting Submission files and recorded meeetings will appear here. + validation_errors: + invalid_meeting_url: Zoom Meeting URL is invalid contract_downloads: download: failure: Your download could not be generated. diff --git a/spec/controllers/casting_calls_controller_spec.rb b/spec/controllers/casting_calls_controller_spec.rb index 3c23bee..299e76e 100644 --- a/spec/controllers/casting_calls_controller_spec.rb +++ b/spec/controllers/casting_calls_controller_spec.rb @@ -60,12 +60,6 @@ RSpec.describe CastingCallsController, type: :controller do post :create, params: { project_id: project.id, casting_call: casting_call_params } }.to have_enqueued_job(TrackAnalyticsJob).with(user, account, :track_create_casting_call, user_agent: "Rails Testing", user_ip: "0.0.0.0") end - - it "submits data to hubspot form" do - expect { - post :create, params: { project_id: project.id, casting_call: casting_call_params } - }.to have_enqueued_job(SubmitHubspotFormJob) - end end describe "#update" do diff --git a/spec/controllers/casting_submissions_controller_spec.rb b/spec/controllers/casting_submissions_controller_spec.rb index 4d71040..b02d70c 100644 --- a/spec/controllers/casting_submissions_controller_spec.rb +++ b/spec/controllers/casting_submissions_controller_spec.rb @@ -36,8 +36,9 @@ RSpec.describe CastingSubmissionsController, type: :controller do it "shows files of casting submission" do get :show, params: { project_id: project, id: casting_submission.id } - expect(response.body).to have_content("Filename") - expect(response.body).to have_content("location_photo.png") + expect(response.body).to have_content(casting_submission.performer_name) + expect(response.body).to have_content(casting_submission.casting_call.title) + expect(response.body).to have_content(casting_submission.casting_call.project_description) end end end diff --git a/spec/controllers/public/casting_calls_controller_spec.rb b/spec/controllers/public/casting_calls_controller_spec.rb index e7ce2c5..65b69fd 100644 --- a/spec/controllers/public/casting_calls_controller_spec.rb +++ b/spec/controllers/public/casting_calls_controller_spec.rb @@ -19,9 +19,6 @@ RSpec.describe Public::CastingCallsController, type: :controller do expect(response.body).to have_content(casting_call.title) expect(response.body).to have_content(casting_call.description) expect(response.body).to have_content(casting_call.project_description) - expect(response.body).to have_content(casting_call.interview_instructions) - expect(response.body).to have_content(casting_call.interview_requirements) - expect(response.body).to have_content(casting_call.questions) expect(response.body).to have_link("Schedule an Audition") end end diff --git a/spec/factories/casting_calls.rb b/spec/factories/casting_calls.rb index 0db776a..434d27e 100644 --- a/spec/factories/casting_calls.rb +++ b/spec/factories/casting_calls.rb @@ -2,6 +2,7 @@ FactoryBot.define do factory :casting_call do association :project user_email 'test@email.com' + title 'Casting Call Title' description "Casting call description" project_description "Casting call project description" interview_instructions "Interview instructions" diff --git a/spec/factories/casting_submissions.rb b/spec/factories/casting_submissions.rb index a5b729f..f83935d 100644 --- a/spec/factories/casting_submissions.rb +++ b/spec/factories/casting_submissions.rb @@ -9,5 +9,9 @@ FactoryBot.define do trait :with_files do files { [Rack::Test::UploadedFile.new('spec/fixtures/files/location_photo.png', 'image/png')] } end + + trait :with_interview_recording do + interview_recording { Rack::Test::UploadedFile.new('spec/fixtures/files/video_file.mp4', 'video/mp4') } + end end end diff --git a/spec/features/admin_managing_casting_submissions_spec.rb b/spec/features/admin_managing_casting_submissions_spec.rb index 5e963b0..a108328 100644 --- a/spec/features/admin_managing_casting_submissions_spec.rb +++ b/spec/features/admin_managing_casting_submissions_spec.rb @@ -39,6 +39,45 @@ feature "Admin managing casting submissions" do expect(page).to have_content create_casting_submission_button end + scenario "when creating new casting call interview - interview recording field is not visible" do + visit admin_casting_submissions_path + + click_on create_casting_submission_button + + expect(page).to have_content new_casting_submission_heading + expect(page).not_to have_field interview_recording_field + end + + scenario "admin can upload interview recording video when editing casting call interview" do + cc = create(:casting_call) + cci = create(:casting_submission, casting_call: cc) + + expect(CastingSubmission.last.interview_recording).not_to be_attached + + visit edit_admin_casting_submission_path(cci) + + expect(page).to have_content edit_casting_submission_heading + expect(page).to have_field interview_recording_field + expect(page).not_to have_content current_interview_recording_label + attach_file interview_recording_field, Rails.root.join(file_fixture('video_file.mp4')) + click_on update_casting_submission_button + expect(page).to have_content casting_submission_updated_message + expect(CastingSubmission.last.interview_recording).to be_attached + end + + scenario "when editing casting call interview with already uploaded interview video, interview recording file name link is shown below file field" do + cc = create(:casting_call) + cci = create(:casting_submission, :with_interview_recording, casting_call: cc) + + expect(CastingSubmission.last.interview_recording).to be_attached + + visit edit_admin_casting_submission_path(cci) + + expect(page).to have_content edit_casting_submission_heading + expect(page).to have_content current_interview_recording_label + expect(page).to have_link CastingSubmission.last.interview_recording.attachment.blob.filename.to_s + end + private def create_casting_submission_button @@ -49,6 +88,14 @@ feature "Admin managing casting submissions" do t 'admin.casting_submissions.new.heading' end + def edit_casting_submission_heading + 'Edit Casting Submission' + end + + def update_casting_submission_button + 'Update Casting submission' + end + def submit_casting_submission_form t 'helpers.submit.casting_submission.create' end @@ -68,4 +115,16 @@ feature "Admin managing casting submissions" do def casting_call_field 'casting_submission[casting_call_id]' end + + def casting_submission_updated_message + t 'admin.casting_submissions.update.notice' + end + + def interview_recording_field + 'casting_submission[interview_recording]' + end + + def current_interview_recording_label + 'Current interview recording' + end end diff --git a/spec/features/user_managing_casting_calls_spec.rb b/spec/features/user_managing_casting_calls_spec.rb index f42f125..9024892 100644 --- a/spec/features/user_managing_casting_calls_spec.rb +++ b/spec/features/user_managing_casting_calls_spec.rb @@ -47,7 +47,7 @@ feature "User managing casting calls" do click_on "Create Casting call" - expect(page).to have_content("Your casting call request was successfully submitted. Thank you. A chat window will pop up on the lower right in a few seconds.") + expect(page).to have_content("The casting call request has been created successfully.") end scenario "can update casting call requests" do @@ -74,6 +74,43 @@ feature "User managing casting calls" do expect(page).to have_content("The casting call request has been cancelled") end + scenario "can open casting call details" do + cc = create(:casting_call, title: "Dummy title", project: project) + + visit project_casting_calls_path(project) + + click_on manage_button + click_on view_button + + expect(page).to have_content cc.title + expect(page).to have_content cc.description + expect(page).to have_content cc.project_description + expect(page).to have_content cc.created_at + expect(page).to have_content cc.status + expect(page).to have_content cc.interview_instructions + expect(page).to have_content cc.interview_requirements + expect(page).to have_content cc.questions + end + + context "when signed out" do + scenario "user opens public accessible casting call URL" do + cc = create(:casting_call, title: "Dummy title", project: project) + + sign_out + public_url = "/casting_calls/#{cc.token}" + visit public_url + + expect(page).to have_content cc.title + expect(page).to have_content cc.description + expect(page).to have_content cc.project_description + expect(page).not_to have_content cc.created_at + expect(page).not_to have_content cc.status + expect(page).not_to have_content cc.interview_instructions + expect(page).not_to have_content cc.interview_requirements + expect(page).not_to have_content cc.questions + end + end + private def no_casting_calls_label @@ -84,6 +121,10 @@ feature "User managing casting calls" do t "casting_calls.casting_call.actions.manage" end + def view_button + 'View' + end + def add_new_casting_call_label t "casting_calls.index.actions.new" end