31 lines
1.2 KiB
Ruby
31 lines
1.2 KiB
Ruby
class InterviewDownloadsController < ApplicationController
|
|
include ProjectContext
|
|
|
|
before_action :set_project, only: [:create]
|
|
before_action :set_casting_call_interview, only: :create
|
|
|
|
include ProjectLayout
|
|
|
|
def create
|
|
download = @project.downloads.create!(name: @casting_call_interview.zip_file_name, release_type: "CastingCallInterview")
|
|
|
|
other_downloads_in_progress = @project.downloads.unfinished_desc_order.offset(1)
|
|
|
|
if other_downloads_in_progress.any?
|
|
in_progress_downloads_details = render_to_string "_other_pending_downloads", locals: { downloads: other_downloads_in_progress, release_type: "CastingCallInterview" }, :layout => false
|
|
ProjectsChannel.broadcast_download_generation_update(download, in_progress_downloads_details)
|
|
else
|
|
ProjectsChannel.broadcast_download_generation_update(download, I18n.t("interview_downloads.download.pending", release_type: "Casting Call Interview"))
|
|
end
|
|
|
|
GenerateInterviewFilesZipJob.perform_later(@project, download, @casting_call_interview)
|
|
end
|
|
|
|
private
|
|
|
|
def set_casting_call_interview
|
|
authorize(Download)
|
|
@casting_call_interview = policy_scope(@project.casting_call_interviews).find(params[:casting_call_interview_id])
|
|
end
|
|
end
|