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
24 changed files with 279 additions and 159 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,38 +1,15 @@
class CastingSubmission < ApplicationRecord
belongs_to :casting_call
has_many_attached :files
has_one_attached :interview_recording
has_secure_token
validates :performer_name, presence: true
validate :zoom_meeting_url_validation
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
"#{self.casting_call.title.parameterize}_#{self.performer_name.parameterize}_#{Time.now.strftime('%Y-%m-%d_%H-%M-%S')}"
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

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

@@ -45,7 +45,7 @@
</div>
</div>
<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>

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:

View File

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

View File

@@ -9,20 +9,6 @@ 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: -
--
@@ -331,8 +317,8 @@ CREATE TABLE public.appearance_releases (
person_last_name character varying,
guardian_first_name character varying,
guardian_last_name character varying,
guardian_email character varying,
identifier character varying,
guardian_email character varying,
person_address_street2 character varying,
person_address_city character varying,
person_address_state character varying,
@@ -742,15 +728,6 @@ CREATE SEQUENCE public.contract_templates_id_seq
ALTER SEQUENCE public.contract_templates_id_seq OWNED BY public.contract_templates.id;
--
-- Name: data_migrations; Type: TABLE; Schema: public; Owner: -
--
CREATE TABLE public.data_migrations (
version character varying NOT NULL
);
--
-- Name: directories; Type: TABLE; Schema: public; Owner: -
--
@@ -1492,6 +1469,7 @@ CREATE TABLE public.settings (
--
CREATE SEQUENCE public.settings_id_seq
AS integer
START WITH 1
INCREMENT BY 1
NO MINVALUE
@@ -1527,6 +1505,7 @@ CREATE TABLE public.taggings (
--
CREATE SEQUENCE public.taggings_id_seq
AS integer
START WITH 1
INCREMENT BY 1
NO MINVALUE
@@ -1557,6 +1536,7 @@ CREATE TABLE public.tags (
--
CREATE SEQUENCE public.tags_id_seq
AS integer
START WITH 1
INCREMENT BY 1
NO MINVALUE
@@ -1917,9 +1897,9 @@ CREATE TABLE public.zoom_meetings (
api_meeting_id character varying,
created_at timestamp(6) without time zone NOT NULL,
updated_at timestamp(6) without time zone NOT NULL,
status integer DEFAULT 0,
zoom_user_id bigint,
project_id bigint
project_id bigint,
status integer DEFAULT 0
);
@@ -2426,14 +2406,6 @@ ALTER TABLE ONLY public.contract_templates
ADD CONSTRAINT contract_templates_pkey PRIMARY KEY (id);
--
-- Name: data_migrations data_migrations_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--
ALTER TABLE ONLY public.data_migrations
ADD CONSTRAINT data_migrations_pkey PRIMARY KEY (version);
--
-- Name: directories directories_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

View File

@@ -37,16 +37,6 @@ RSpec.describe Admin::CastingSubmissionsController, type: :controller do
post :create, params: { casting_submission: casting_submission_params }
}.to change(CastingSubmission, :count)
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
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 }
}.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

@@ -8,35 +8,57 @@ feature "Admin managing casting submissions" do
sign_in current_user
end
scenario "admin cannot create casting submission with invalid zoom url", js: true do
scenario "when creating new casting call interview - interview recording field is not visible" do
visit admin_casting_submissions_path
cc = create(:casting_call, title: "SpecialCastingCall")
click_link create_casting_submission_button
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
fill_in performer_name_field, with: "TestName"
select cc.title, from: casting_call_field
fill_in zoom_meeting_url_field, with: "malformed url"
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 do
click_on submit_casting_submission_form
end.to change(CastingSubmission, :count).by(0)
expect(page).to have_content zoom_meeting_url_invalid_error
expect(CastingSubmission.last.interview_recording).not_to be_attached
fill_in zoom_meeting_url_field, with: "https://similar.google.com/j/24324324?pwd=334kni3j4"
visit edit_admin_casting_submission_path(cci)
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
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
fill_in zoom_meeting_url_field, with: "https://s01.zoom.us/j/343434?pwd=dawidj34ijij"
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 do
click_on submit_casting_submission_form
end.to change(CastingSubmission, :count).by(1)
expect(page).to have_content create_casting_submission_button
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
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
@@ -49,6 +71,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 +98,32 @@ 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
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

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