Upstream cast me sync

This commit is contained in:
Senad Uka
2020-07-22 13:37:34 +00:00
parent e3acdb4d0e
commit 95e9a70c4b
20 changed files with 260 additions and 67 deletions

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -1,6 +1,7 @@
class CastingSubmission < ApplicationRecord
belongs_to :casting_call
has_many_attached :files
has_one_attached :interview_recording
has_secure_token

View File

@@ -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? %>
<p>
<%= link_to casting_submission.interview_recording do %>
<%= fa_icon "file-text-o" %> <%= casting_submission.interview_recording.filename %>
<% end %>
<span class="text-muted"><%= fa_icon "long-arrow-left" %> <em>Current interview recording</em></span>
</p>
<% end %>
<% end %>
<div class="row align-items-center text-center mt-4">
<%= link_to t("shared.cancel"), [:admin, :casting_submissions], class: "col-3 text-reset" %>
<div class="col-9">

View File

@@ -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 %>

View File

@@ -1,2 +0,0 @@
<%= render "shared/initiate_hubspot_chat" %>
<p class="alert alert-success p-3 lead text-center"><%= t '.success_message' %></p>

View File

@@ -1,6 +1,12 @@
<tr>
<td><%= file.filename %></td>
<td class="text-right">
<%= link_to fa_icon("download"), file, target: "_blank" %>
</td>
</tr>
<li class="my-2" id="<%= dom_id(file) %>">
<% 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 %>
<div class="border rounded bg-light text-muted d-flex justify-content-center align-items-center fix-h-and-w">
<%= link_to file, target: "_blank" do %>
<%= fa_icon("file", style: "font-size: 2rem") %>
<div class="mt-2"><%= file.filename %></div>
<% end %>
</div>
<% end %>
</li>

View File

@@ -0,0 +1,14 @@
<div class="overflow-auto mh-30">
<ul class="list-unstyled d-flex flex-column align-items-center text-center" id="casting_submission_file_list_<%= casting_submission.id %>">
<% if files.present? %>
<%= render partial: "casting_submissions/file", collection: files %>
<% else %>
<li class="my-3">
Files will appear here.
</li>
<% end %>
</ul>
<div class="d-flex mt-2 justify-content-center" id="casting_submission_files_pagination_<%= casting_submission.id %>">
<%= will_paginate(files, param_name: 'files_page', params: { active_files_tab: casting_submission.id }) if files.present? %>
</div>
</div>

View File

@@ -0,0 +1,15 @@
<% if casting_submission.interview_recording.present? %>
<div id="casting_submission_video" class="embed-responsive-item"></div>
<% else %>
<div id="casting_submission_video" class="embed-responsive-item">
<table class="w-100 h-100 bg-secondary">
<tbody>
<tr>
<td class="text-center align-middle text-white">
Video player will appear here when the interview recording is available.
</td>
</tr>
</tbody>
</table>
</div>
<% end %>

View File

@@ -1,25 +1,79 @@
<div class="col-md-12">
<h2 class="h6 mt-3">Files:</h2>
<div class="pt-2 mx-n3">
<table class="table table-striped tr-px-4 align-all-middle">
<thead class="thead-light">
<tr>
<th>Filename</th>
<th></th>
</tr>
</thead>
<tbody id="task_requests">
<% if @files.any? %>
<%= render partial: "file", collection: @files %>
<% else %>
<tr>
<td colspan="12" class="py-4 text-center text-muted"><%= t(".empty") %></td>
</tr>
<% end %>
</tbody>
</table>
<div class="mt-4" id="task_requests_pagiantion">
<%= will_paginate @files %>
<% content_for :header do %>
<header class="container-fluid py-3 border-bottom sticky-top bg-light">
<div class="row align-items-center justify-content-center">
<div class="col-4 text-center">
<%= product_wordmark(:cast_me, class: 'navbar-brand') %>
</div>
</div>
</header>
<% end %>
<div class="row">
<div class="col-lg-8 col-md-12 mb-3">
<div class="card shadow-sm">
<div class="card-header">
<div class="d-flex justify-content-start flex-column">
<h1 class="h2 mb-1"><%= @casting_submission.performer_name %></h1>
<h1 class="h6 mb-1"><%= @casting_call.title %></h1>
</div>
</div>
<div class="card-body p-0">
<div class="embed-responsive embed-responsive-16by9">
<%= 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 %>
</div>
</div>
</div>
</div>
</div>
<div class="col-lg-4 col-md-12 mb-3">
<div class="card shadow-sm mb-3">
<div class="card-header">
<ul class="nav nav-tabs card-header-tabs">
<li class="nav-item">
<%= link_to "Home", "#home", class: class_string("nav-link", "active" => !params[:active_tab].present?), data: { toggle: "tab" } %>
</li>
<li class="nav-item">
<%= link_to "Files", "#files", class: class_string("nav-link", "active" => params[:active_tab] == "files"), data: { toggle: "tab" } %>
</li>
</ul>
</div>
<div class="card-body p-3">
<div class="tab-content">
<div class="<%= class_string("tab-pane fade show", "active" => !params[:active_tab].present?) %>" id="home">
<div class="row">
<div class="col-md-12">
<dl>
<%= 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: ":" %>
</dl>
</div>
</div>
</div>
<div class="<%= class_string("tab-pane fade show", "active" => params[:active_tab] == 'files') %>" id="files">
<div class="tab-pane fade show active" id="files_casting_submission_<%= @casting_submission.id %>">
<%= render partial: 'casting_submissions/files_section', locals: { casting_submission: @casting_submission, files: @files } %>
</div>
</div>
</div>
</div>
</div>
</div>
</div>

View File

@@ -12,20 +12,11 @@
<%= card_header text: @casting_call.title %>
<div class="card-body">
<div class="row">
<div class="col-md-6 col-sm-12">
<div class="col-12">
<dl>
<%= 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: ":" %>
</dl>
</div>
<div class="col-md-6 col-sm-12">
<dl>
<%= 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: ":" %>
</dl>
</div>
</div>

View File

@@ -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.

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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"

View File

@@ -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

View File

@@ -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

View File

@@ -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