Compare commits

..

4 Commits

Author SHA1 Message Date
Bilal
62ef25e511 fix casting submission view page 2020-07-23 12:12:45 +02:00
Bilal
b82aaf77ff remove specs related to zoom url validation 2020-07-22 14:13:04 +02:00
Bilal
e08dd36d68 remove zoom url validation 2020-07-22 14:05:31 +02:00
Senad Uka
95e9a70c4b Upstream cast me sync 2020-07-22 13:37:34 +00:00
20 changed files with 206 additions and 136 deletions

View File

@@ -17,8 +17,7 @@ class CastingCallsController < ApplicationController
if @casting_call.save if @casting_call.save
log_create_analytics log_create_analytics
castme_url = url_for([@project, @casting_call]) redirect_to [@project, :casting_calls], notice: t(".notice")
SubmitHubspotFormJob.perform_later(email: @casting_call.user_email, castme_url: castme_url, form_guid: ENV["HUBSPOT_CASTING_CALL_REQUEST_FORM_GUID"])
else else
render :new render :new
end end

View File

@@ -9,7 +9,9 @@ class CastingSubmissionsController < ApplicationController
end end
def show 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 end
private private

View File

@@ -6,34 +6,10 @@ class CastingSubmission < ApplicationRecord
has_secure_token has_secure_token
validates :performer_name, presence: true validates :performer_name, presence: true
validate :zoom_meeting_url_validation
scope :completed, -> { where.not(interviewed_at: nil) } scope :completed, -> { where.not(interviewed_at: nil) }
def join_zoom_meeting_url
uri = URI.parse(self.zoom_meeting_url)
zoom_meeting_id = uri.path.gsub("/j/", "")
zoom_meeting_pwd = uri.query.gsub("pwd=", "")
"zoommtg://zoom.us/join?confno=#{zoom_meeting_id}&pwd=#{zoom_meeting_pwd}"
end
def zip_file_name def zip_file_name
"#{self.casting_call.title.parameterize}_#{self.performer_name.parameterize}_#{Time.now.strftime('%Y-%m-%d_%H-%M-%S')}" "#{self.casting_call.title.parameterize}_#{self.performer_name.parameterize}_#{Time.now.strftime('%Y-%m-%d_%H-%M-%S')}"
end end
def zoom_meeting_url_validation
# valid url format :
# https://us01web.zoom.us/j/12345?pwd=Ab103odw3ok343ko
valid_url_regex = %r{^https\://[a-z0-9]+\.zoom.us/j/[0-9]+\?pwd\=.+}
return true if zoom_meeting_url.match valid_url_regex
errors.add(:base, invalid_meeting_url_message)
end
private
def invalid_meeting_url_message
I18n.t('casting_submissions.validation_errors.invalid_meeting_url')
end
end end

View File

@@ -7,7 +7,7 @@
<%= form.text_field :zoom_meeting_url %> <%= form.text_field :zoom_meeting_url %>
<% unless casting_submission.new_record? %> <% unless casting_submission.new_record? %>
<%= form.file_field :interview_recording, 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 } %> <%= 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? %> <% if casting_submission.interview_recording.attached? %>
<p> <p>
@@ -17,6 +17,8 @@
<span class="text-muted"><%= fa_icon "long-arrow-left" %> <em>Current interview recording</em></span> <span class="text-muted"><%= fa_icon "long-arrow-left" %> <em>Current interview recording</em></span>
</p> </p>
<% end %> <% end %>
<% end %> <% end %>
<div class="row align-items-center text-center mt-4"> <div class="row align-items-center text-center mt-4">

View File

@@ -9,7 +9,7 @@
<%= form.text_field :title %> <%= form.text_field :title %>
<%= form.text_area :description %> <%= form.text_area :description %>
<%= form.text_area :project_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 :interview_instructions, rows: 6 %>
<%= form.text_area :questions, rows: 8 %> <%= form.text_area :questions, rows: 8 %>
<%= form.text_area :interview_requirements, rows: 6 %> <%= 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> <li class="my-2" id="<%= dom_id(file) %>">
<td><%= file.filename %></td> <% if file.variable? %>
<td class="text-right"> <%= link_to image_tag(file.variant(resize_and_pad: [300, 300, background: "#F7F8F9"]), class: "bg-light img-thumbnail img-fluid"), file, target: "_blank" %>
<%= link_to fa_icon("download"), file, target: "_blank" %> <% else %>
</td> <div class="border rounded bg-light text-muted d-flex justify-content-center align-items-center fix-h-and-w">
</tr> <%= 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"> <% content_for :header do %>
<h2 class="h6 mt-3">Files:</h2> <header class="container-fluid py-3 border-bottom sticky-top bg-light">
<div class="pt-2 mx-n3"> <div class="row align-items-center justify-content-center">
<table class="table table-striped tr-px-4 align-all-middle"> <div class="col-4 text-center">
<thead class="thead-light"> <%= product_wordmark(:cast_me, class: 'navbar-brand') %>
<tr> </div>
<th>Filename</th> </div>
<th></th> </header>
</tr> <% end %>
</thead>
<tbody id="task_requests"> <div class="row">
<% if @files.any? %> <div class="col-lg-8 col-md-12 mb-3">
<%= render partial: "file", collection: @files %> <div class="card shadow-sm">
<% else %> <div class="card-header">
<tr> <div class="d-flex justify-content-start flex-column">
<td colspan="12" class="py-4 text-center text-muted"><%= t(".empty") %></td> <h1 class="h2 mb-1"><%= @casting_submission.performer_name %></h1>
</tr> <h1 class="h6 mb-1"><%= @casting_call.title %></h1>
<% end %> </div>
</tbody> </div>
</table> <div class="card-body p-0">
<div class="mt-4" id="task_requests_pagiantion"> <div class="embed-responsive embed-responsive-16by9">
<%= will_paginate @files %> <%= 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 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> </div>
</div> </div>

View File

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

View File

@@ -45,7 +45,7 @@
</div> </div>
</div> </div>
<div class="row align-items-center justify-content-center mt-3"> <div class="row align-items-center justify-content-center mt-3">
<%= link_to "Start Interview", @casting_submission.join_zoom_meeting_url, target: "_blank", class: "btn btn-primary" %> <%= link_to "Start Interview", @casting_submission.zoom_meeting_url, target: "_blank", class: "btn btn-primary" %>
</div> </div>
</div> </div>
</div> </div>

View File

@@ -247,13 +247,6 @@ en:
bulk_taggings: bulk_taggings:
new_bulk_tag_modal: new_bulk_tag_modal:
submit: Add 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: casting_calls:
cancel: cancel:
notice: The casting call request has been cancelled successfully notice: The casting call request has been cancelled successfully
@@ -261,11 +254,12 @@ en:
actions: actions:
manage: Manage manage: Manage
create: create:
notice: The casting call request has been created notice: The casting call request has been created successfully.
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.
edit: edit:
heading: Edit Casting Call heading: Edit Casting Call
form: form:
headings:
chatbot: Chatbot Instructions
info_message: After submitting this casting call request, you'll be connected via chat with a ME Suite representative. info_message: After submitting this casting call request, you'll be connected via chat with a ME Suite representative.
index: index:
actions: actions:

View File

@@ -76,9 +76,6 @@ es:
share_stream: Share live stream link with clients share_stream: Share live stream link with clients
stream_from_mobile_app: Stream from ME Suite Mobile app, or via a professional camera stream_from_mobile_app: Stream from ME Suite Mobile app, or via a professional camera
stream_multiple_cameras: Stream multiple cameras at one time stream_multiple_cameras: Stream multiple cameras at one time
casting_submissions:
validation_errors:
invalid_meeting_url: Zoom Meeting URL is invalid (ES)
contract_templates: contract_templates:
blank_contracts: blank_contracts:
create: create:

View File

@@ -37,16 +37,6 @@ RSpec.describe Admin::CastingSubmissionsController, type: :controller do
post :create, params: { casting_submission: casting_submission_params } post :create, params: { casting_submission: casting_submission_params }
}.to change(CastingSubmission, :count) }.to change(CastingSubmission, :count)
end end
it "does not create new record if zoom meeting url is not valid" do
expect {
post :create, params: {
casting_submission: casting_submission_params
.except(:zoom_meeting_url)
.merge(zoom_meeting_url: "malformed_url")
}
}.to change(CastingSubmission, :count).by(0)
end
end end
describe "#edit" do describe "#edit" do

View File

@@ -60,12 +60,6 @@ RSpec.describe CastingCallsController, type: :controller do
post :create, params: { project_id: project.id, casting_call: casting_call_params } 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") }.to have_enqueued_job(TrackAnalyticsJob).with(user, account, :track_create_casting_call, user_agent: "Rails Testing", user_ip: "0.0.0.0")
end 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 end
describe "#update" do describe "#update" do

View File

@@ -36,8 +36,9 @@ RSpec.describe CastingSubmissionsController, type: :controller do
it "shows files of casting submission" do it "shows files of casting submission" do
get :show, params: { project_id: project, id: casting_submission.id } get :show, params: { project_id: project, id: casting_submission.id }
expect(response.body).to have_content("Filename") expect(response.body).to have_content(casting_submission.performer_name)
expect(response.body).to have_content("location_photo.png") 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 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.title)
expect(response.body).to have_content(casting_call.description) 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.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") expect(response.body).to have_link("Schedule an Audition")
end end
end end

View File

@@ -8,37 +8,6 @@ feature "Admin managing casting submissions" do
sign_in current_user sign_in current_user
end end
scenario "admin cannot create casting submission with invalid zoom url", js: true do
visit admin_casting_submissions_path
cc = create(:casting_call, title: "SpecialCastingCall")
click_link create_casting_submission_button
expect(page).to have_content new_casting_submission_heading
fill_in performer_name_field, with: "TestName"
select cc.title, from: casting_call_field
fill_in zoom_meeting_url_field, with: "malformed url"
expect do
click_on submit_casting_submission_form
end.to change(CastingSubmission, :count).by(0)
expect(page).to have_content zoom_meeting_url_invalid_error
fill_in zoom_meeting_url_field, with: "https://similar.google.com/j/24324324?pwd=334kni3j4"
expect do
click_on submit_casting_submission_form
end.to change(CastingSubmission, :count).by(0)
expect(page).to have_content zoom_meeting_url_invalid_error
fill_in zoom_meeting_url_field, with: "https://s01.zoom.us/j/343434?pwd=dawidj34ijij"
expect do
click_on submit_casting_submission_form
end.to change(CastingSubmission, :count).by(1)
expect(page).to have_content create_casting_submission_button
end
scenario "when creating new casting call interview - interview recording field is not visible" do scenario "when creating new casting call interview - interview recording field is not visible" do
visit admin_casting_submissions_path visit admin_casting_submissions_path
@@ -78,6 +47,20 @@ feature "Admin managing casting submissions" do
expect(page).to have_link CastingSubmission.last.interview_recording.attachment.blob.filename.to_s expect(page).to have_link CastingSubmission.last.interview_recording.attachment.blob.filename.to_s
end end
scenario "when admin opens view page for casting submission, it does not fail if zoom meeting URL is invalid" do
cc = create(:casting_call)
cci = create(:casting_submission, casting_call: cc, zoom_meeting_url: "anything")
visit admin_casting_submissions_path
click_on manage_button
click_link view_link
expect(page).to have_content casting_submission_details_header
expect(page).to have_content interview_files_label
expect(page).to have_content cci.performer_name
end
private private
def create_casting_submission_button def create_casting_submission_button
@@ -127,4 +110,20 @@ feature "Admin managing casting submissions" do
def current_interview_recording_label def current_interview_recording_label
'Current interview recording' 'Current interview recording'
end end
def manage_button
'Manage'
end
def view_link
'View'
end
def casting_submission_details_header
'Casting submission details'
end
def interview_files_label
'INTERVIEW FILES:'
end
end end

View File

@@ -47,7 +47,7 @@ feature "User managing casting calls" do
click_on "Create Casting call" 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 end
scenario "can update casting call requests" do 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") expect(page).to have_content("The casting call request has been cancelled")
end 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 private
def no_casting_calls_label def no_casting_calls_label
@@ -84,6 +121,10 @@ feature "User managing casting calls" do
t "casting_calls.casting_call.actions.manage" t "casting_calls.casting_call.actions.manage"
end end
def view_button
'View'
end
def add_new_casting_call_label def add_new_casting_call_label
t "casting_calls.index.actions.new" t "casting_calls.index.actions.new"
end end