From 4f1ebb27d04f64c4fdf6e0d2748c074489b106e8 Mon Sep 17 00:00:00 2001 From: Senad Uka Date: Mon, 27 Jul 2020 10:18:49 +0000 Subject: [PATCH] Upstream sync --- .../admin/casting_submissions_controller.rb | 11 +++- .../casting_submissions_controller.rb | 2 + app/models/casting_submission.rb | 30 +++------ .../admin/casting_submissions/_form.html.erb | 13 +++- app/views/casting_submissions/show.html.erb | 29 ++++++--- .../public/casting_submissions/show.html.erb | 2 +- config/locales/en.yml | 10 +-- config/locales/es.yml | 3 - ...3459_add_markers_to_casting_submissions.rb | 35 +++++++++++ db/structure.sql | 35 ++++++++++- .../casting_submissions_controller_spec.rb | 10 --- ...admin_managing_casting_submissions_spec.rb | 61 +++++++++---------- 12 files changed, 153 insertions(+), 88 deletions(-) create mode 100644 db/migrate/20200722193459_add_markers_to_casting_submissions.rb diff --git a/app/controllers/admin/casting_submissions_controller.rb b/app/controllers/admin/casting_submissions_controller.rb index e2f1e62..6e3fe94 100644 --- a/app/controllers/admin/casting_submissions_controller.rb +++ b/app/controllers/admin/casting_submissions_controller.rb @@ -40,7 +40,16 @@ 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, :interview_recording) + params.require(:casting_submission).permit( + :casting_call_id, :performer_name, :interview_date, + :zoom_meeting_url, :interview_recording, :time_elapsed_1, + :time_elapsed_2, :time_elapsed_3, :time_elapsed_4, :time_elapsed_5, + :time_elapsed_6, :time_elapsed_7, :time_elapsed_8, :time_elapsed_9, + :time_elapsed_10, :time_elapsed_11, :time_elapsed_12, :time_elapsed_13, + :time_elapsed_14, :time_elapsed_15, :note_1 , :note_2 , :note_3 , :note_4, + :note_5, :note_6, :note_7, :note_8, :note_9, :note_10, :note_11, :note_12, :note_13, + :note_14, :note_15 + ) end def casting_submissions diff --git a/app/controllers/casting_submissions_controller.rb b/app/controllers/casting_submissions_controller.rb index bbed3fe..9418344 100644 --- a/app/controllers/casting_submissions_controller.rb +++ b/app/controllers/casting_submissions_controller.rb @@ -11,6 +11,8 @@ class CastingSubmissionsController < ApplicationController def show @casting_call = @casting_submission.casting_call @files = @casting_submission.files.order("created_at DESC").paginate(page: params[:files_page]) + @markers = @casting_submission.markers + render layout: 'application' end diff --git a/app/models/casting_submission.rb b/app/models/casting_submission.rb index d9262a7..317ea39 100644 --- a/app/models/casting_submission.rb +++ b/app/models/casting_submission.rb @@ -3,37 +3,23 @@ class CastingSubmission < ApplicationRecord has_many_attached :files has_one_attached :interview_recording + NUMBER_OF_MARKER_FIELDS = 15 + 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') + def markers + (1..NUMBER_OF_MARKER_FIELDS).map do |n| + if public_send("time_elapsed_#{n}").present? + OpenStruct.new(id: n, time_elapsed: public_send("time_elapsed_#{n}"), note: public_send("note_#{n}") ) + end + end.compact end end diff --git a/app/views/admin/casting_submissions/_form.html.erb b/app/views/admin/casting_submissions/_form.html.erb index 1d04c20..d3867ce 100644 --- a/app/views/admin/casting_submissions/_form.html.erb +++ b/app/views/admin/casting_submissions/_form.html.erb @@ -7,7 +7,7 @@ <%= 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 } %> + <%= form.file_field :interview_recording, accept: "video/mp4", 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? %>

@@ -17,8 +17,15 @@ <%= fa_icon "long-arrow-left" %> Current interview recording

<% end %> - - +
+ <%= card_field_set_tag t(".casting_submission_markers.heading") do %> + <% (1..CastingSubmission::NUMBER_OF_MARKER_FIELDS).each do |n| %> +
+ <%= form.number_field "time_elapsed_#{n}", wrapper_class: "col-md-6", label: "Elapsed Time #{n} (in seconds)" %> + <%= form.text_area "note_#{n}", wrapper_class: "col-md-6", label: "Note #{n}" %> +
+ <% end %> + <% end %> <% end %>
diff --git a/app/views/casting_submissions/show.html.erb b/app/views/casting_submissions/show.html.erb index e270e1d..52fc0a7 100644 --- a/app/views/casting_submissions/show.html.erb +++ b/app/views/casting_submissions/show.html.erb @@ -22,14 +22,27 @@ <%= 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 + var markerData = <%= raw @markers.to_json %>; + + var player = new Clappr.Player({ + parentId: '#casting_submission_video', + source: "<%= rails_blob_url(@casting_submission.interview_recording, host: AppHost.new.domain_with_port) %>", + plugins: { + core: [ClapprMarkersPlugin] + }, + markersPlugin: {}, + width: '100%', + height: '100%', + mute: true, + autoPlay: true, + hlsMinimumDvrSize: 1 + }); + + markerData.forEach(function(marker, index) { + var markers = player.getPlugin("markers-plugin"); + var marker = new ClapprMarkersPlugin.StandardMarker(Number(marker.table.time_elapsed), marker.table.note) + + markers.addMarker(marker); }); <% end %> <% end %> diff --git a/app/views/public/casting_submissions/show.html.erb b/app/views/public/casting_submissions/show.html.erb index 687f59f..1ddee2b 100644 --- a/app/views/public/casting_submissions/show.html.erb +++ b/app/views/public/casting_submissions/show.html.erb @@ -45,7 +45,7 @@
- <%= 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" %>
diff --git a/config/locales/en.yml b/config/locales/en.yml index c271801..73923f1 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -105,6 +105,9 @@ en: notice: The casting submission has been completed create: notice: The casting submission has been created + form: + casting_submission_markers: + heading: Markers index: actions: new: Create Casting Submission @@ -283,13 +286,6 @@ 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/config/locales/es.yml b/config/locales/es.yml index be1257b..251a063 100644 --- a/config/locales/es.yml +++ b/config/locales/es.yml @@ -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: diff --git a/db/migrate/20200722193459_add_markers_to_casting_submissions.rb b/db/migrate/20200722193459_add_markers_to_casting_submissions.rb new file mode 100644 index 0000000..28e9e57 --- /dev/null +++ b/db/migrate/20200722193459_add_markers_to_casting_submissions.rb @@ -0,0 +1,35 @@ +class AddMarkersToCastingSubmissions < ActiveRecord::Migration[6.0] + def change + add_column :casting_submissions, :time_elapsed_1, :integer + add_column :casting_submissions, :time_elapsed_2, :integer + add_column :casting_submissions, :time_elapsed_3, :integer + add_column :casting_submissions, :time_elapsed_4, :integer + add_column :casting_submissions, :time_elapsed_5, :integer + add_column :casting_submissions, :time_elapsed_6, :integer + add_column :casting_submissions, :time_elapsed_7, :integer + add_column :casting_submissions, :time_elapsed_8, :integer + add_column :casting_submissions, :time_elapsed_9, :integer + add_column :casting_submissions, :time_elapsed_10, :integer + add_column :casting_submissions, :time_elapsed_11, :integer + add_column :casting_submissions, :time_elapsed_12, :integer + add_column :casting_submissions, :time_elapsed_13, :integer + add_column :casting_submissions, :time_elapsed_14, :integer + add_column :casting_submissions, :time_elapsed_15, :integer + + add_column :casting_submissions, :note_1, :text + add_column :casting_submissions, :note_2, :text + add_column :casting_submissions, :note_3, :text + add_column :casting_submissions, :note_4, :text + add_column :casting_submissions, :note_5, :text + add_column :casting_submissions, :note_6, :text + add_column :casting_submissions, :note_7, :text + add_column :casting_submissions, :note_8, :text + add_column :casting_submissions, :note_9, :text + add_column :casting_submissions, :note_10, :text + add_column :casting_submissions, :note_11, :text + add_column :casting_submissions, :note_12, :text + add_column :casting_submissions, :note_13, :text + add_column :casting_submissions, :note_14, :text + add_column :casting_submissions, :note_15, :text + end +end diff --git a/db/structure.sql b/db/structure.sql index fcd9e16..c1861af 100644 --- a/db/structure.sql +++ b/db/structure.sql @@ -622,7 +622,37 @@ CREATE TABLE public.casting_submissions ( created_at timestamp(6) without time zone NOT NULL, updated_at timestamp(6) without time zone NOT NULL, token character varying, - interviewed_at timestamp without time zone + interviewed_at timestamp without time zone, + time_elapsed_1 integer, + time_elapsed_2 integer, + time_elapsed_3 integer, + time_elapsed_4 integer, + time_elapsed_5 integer, + time_elapsed_6 integer, + time_elapsed_7 integer, + time_elapsed_8 integer, + time_elapsed_9 integer, + time_elapsed_10 integer, + time_elapsed_11 integer, + time_elapsed_12 integer, + time_elapsed_13 integer, + time_elapsed_14 integer, + time_elapsed_15 integer, + note_1 text, + note_2 text, + note_3 text, + note_4 text, + note_5 text, + note_6 text, + note_7 text, + note_8 text, + note_9 text, + note_10 text, + note_11 text, + note_12 text, + note_13 text, + note_14 text, + note_15 text ); @@ -4078,6 +4108,7 @@ INSERT INTO "schema_migrations" (version) VALUES ('20200706193123'), ('20200706230803'), ('20200707070522'), -('20200714175331'); +('20200714175331'), +('20200722193459'); diff --git a/spec/controllers/admin/casting_submissions_controller_spec.rb b/spec/controllers/admin/casting_submissions_controller_spec.rb index bfc684f..aacbcef 100644 --- a/spec/controllers/admin/casting_submissions_controller_spec.rb +++ b/spec/controllers/admin/casting_submissions_controller_spec.rb @@ -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 diff --git a/spec/features/admin_managing_casting_submissions_spec.rb b/spec/features/admin_managing_casting_submissions_spec.rb index a108328..046e23c 100644 --- a/spec/features/admin_managing_casting_submissions_spec.rb +++ b/spec/features/admin_managing_casting_submissions_spec.rb @@ -8,37 +8,6 @@ feature "Admin managing casting submissions" do sign_in current_user 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 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 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 def create_casting_submission_button @@ -127,4 +110,20 @@ feature "Admin managing casting submissions" do 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