Initial commit

This commit is contained in:
Senad Uka
2020-05-31 22:38:19 +02:00
commit 858fafc3c5
1280 changed files with 65918 additions and 0 deletions

View File

@@ -0,0 +1,28 @@
class VideoAnalyses::AcquiredMediaReleasesController < ApplicationController
before_action :set_video
def index
@acquired_media_file_infos = filtered_file_infos
end
private
def set_video
@video = Video.find(params[:video_id])
end
def query_param
params[:query]
end
def filtered_file_infos
releasables = policy_scope(@video.acquired_media_releases)
results = FileInfo.where(releasable: releasables)
if query_param.present?
results = results.search_filename(query_param)
end
results
end
end

View File

@@ -0,0 +1,27 @@
class VideoAnalyses::AppearanceReleasesController < ApplicationController
before_action :set_video
def index
@appearance_releases = filtered_releases
end
private
def set_video
@video = Video.find(params[:video_id])
end
def query_param
params[:query]
end
def filtered_releases
results = policy_scope(@video.appearance_releases)
if query_param.present?
results = results.search(query_param)
end
results
end
end

View File

@@ -0,0 +1,77 @@
class VideoAnalyses::AudioConfirmationsController < ApplicationController
before_action :set_video, only: [:new, :create]
def new
@matched_file_name = params.delete(:matched_file_name)
@audio_confirmation = filtered_audio_confirmations.build(audio_confirmation_params)
@edl_events_data = build_presenter(@audio_confirmation.edl_type).present
@audio_confirmation.attributes = @edl_events_data[:edl_attributes]
end
def create
audio_confirmation = filtered_audio_confirmations.build(audio_confirmation_params)
audio_confirmation.save
@audio_confirmation_data = ::AudioConfirmations::AudioConfirmationPresenter.new.present(audio_confirmation)
@audio_confirmations_data = ::AudioConfirmations::AudioConfirmationsPresenter.new.present(filtered_audio_confirmations)
end
def destroy
audio_confirmation = find_audio_confirmation
video = audio_confirmation.video
audio_confirmation.destroy
@audio_confirmation_data = ::AudioConfirmations::AudioConfirmationPresenter.new.present(audio_confirmation)
@audio_confirmations_data = ::AudioConfirmations::AudioConfirmationsPresenter.new.present(video.audio_confirmations)
end
private
def build_presenter(edl_type)
files_for_request = if edl_type == "all_tracks"
FilesForRequest.new(@video)
else
AudioFilesForRequest.new(@video, @video.edl_timecode_start)
end
EdlEventsPresenter.new(
EdlEventGateway.new(
files_for_request,
@audio_confirmation.appears_at,
@audio_confirmation.appears_at,
channel_filter: ENV["DISABLE_EDL_CHANNEL_FILTER"] ? "" : "A",
)
)
end
def find_audio_confirmation
authorize policy_scope(AudioConfirmation).find(params[:id])
end
def set_video
@video = authorize policy_scope(Video).find(params[:video_id])
end
def filtered_audio_confirmations
policy_scope(@video.audio_confirmations)
end
def audio_confirmation_params
params.require(:audio_confirmation).permit(
:time_elapsed,
:channel,
:timecode_in,
:timecode_out,
:duration,
:source_file_name,
:clip_name,
:description,
:music_type,
:music_category,
:composer_info,
:publisher_info,
:catalog,
:title,
:confirmation_type,
:edl_type,
)
end
end

View File

@@ -0,0 +1,32 @@
class VideoAnalyses::EdlEventsController < ApplicationController
before_action :set_video
def create
@timecode = timecode
@edl_events = edl_event_gateway.edl_events
@info_message = t(".info_message", count: @edl_events.size)
end
private
def videos
policy_scope(Video)
end
def set_video
@video = authorize videos.find(params[:video_id])
end
def edl_event_gateway
@edl_event_gateway ||= EdlEventGateway.new(FilesForRequest.new(@video), timecode, timecode)
end
def edl_event_params
params.require(:edl_event).permit(:time_elapsed)
end
def timecode
time_elapsed = edl_event_params.fetch(:time_elapsed)
Timecode.from_seconds(time_elapsed.to_f).to_s
end
end

View File

@@ -0,0 +1,85 @@
class VideoAnalyses::GraphicsElementsController < ApplicationController
before_action :set_video, only: [:new, :create]
def new
@matched_file_name = params.delete(:matched_file_name)
@graphics_element = filtered_graphics_elements.build(graphics_element_params)
@edl_events_data = build_presenter(@graphics_element.edl_type).present
@graphics_element.attributes = @edl_events_data[:edl_attributes]
end
def create
graphics_element = filtered_graphics_elements.build(graphics_element_params)
graphics_element.save
@graphics_element_data = ::GraphicsElements::GraphicsElementPresenter.new.present(graphics_element)
@graphics_elements_data = ::GraphicsElements::GraphicsElementsPresenter.new.present(filtered_graphics_elements)
end
def edit
@graphics_element = find_graphics_element
@video = @graphics_element.video
@edl_events_data = build_presenter(@graphics_element.edl_type).present
end
def update
graphics_element = find_graphics_element
graphics_element.update(graphics_element_params)
@video = graphics_element.video
@graphics_element_data = ::GraphicsElements::GraphicsElementPresenter.new.present(graphics_element)
@graphics_elements_data = ::GraphicsElements::GraphicsElementsPresenter.new.present(filtered_graphics_elements)
end
def destroy
graphics_element = find_graphics_element
@graphics_element_data = ::GraphicsElements::GraphicsElementPresenter.new.present(graphics_element)
graphics_element.destroy
@graphics_elements_data = ::GraphicsElements::GraphicsElementsPresenter.new.present(graphics_element.video.graphics_elements)
end
private
def find_graphics_element
authorize policy_scope(GraphicsElement).find(params[:id])
end
def build_presenter(edl_type)
files_for_request = if edl_type == "all_tracks"
FilesForRequest.new(@video)
else
GraphicsFilesForRequest.new(@video, @video.edl_timecode_start)
end
EdlEventsPresenter.new(
EdlEventGateway.new(
files_for_request,
@graphics_element.appears_at,
@graphics_element.appears_at,
channel_filter: ENV["DISABLE_EDL_CHANNEL_FILTER"] ? "" : "V",
)
)
end
def set_video
@video = authorize policy_scope(Video).find(params[:video_id])
end
def filtered_graphics_elements
policy_scope(@video.graphics_elements)
end
def graphics_element_params
params.require(:graphics_element).permit(
:graphic_type,
:text,
:time_elapsed,
:channel,
:timecode_in,
:timecode_out,
:duration,
:source_file_name,
:clip_name,
:description,
:edl_type,
)
end
end

View File

@@ -0,0 +1,27 @@
class VideoAnalyses::LocationReleasesController < ApplicationController
before_action :set_video
def index
@location_releases = filtered_releases
end
private
def set_video
@video = Video.find(params[:video_id])
end
def query_param
params[:query]
end
def filtered_releases
results = policy_scope(@video.location_releases)
if query_param.present?
results = results.search(query_param)
end
results
end
end

View File

@@ -0,0 +1,27 @@
class VideoAnalyses::MaterialReleasesController < ApplicationController
before_action :set_video
def index
@material_releases = filtered_releases
end
private
def set_video
@video = Video.find(params[:video_id])
end
def query_param
params[:query]
end
def filtered_releases
results = policy_scope(@video.material_releases)
if query_param.present?
results = results.search(query_param)
end
results
end
end

View File

@@ -0,0 +1,28 @@
class VideoAnalyses::MusicReleasesController < ApplicationController
before_action :set_video
def index
@music_release_file_infos = filtered_file_infos
end
private
def set_video
@video = Video.find(params[:video_id])
end
def query_param
params[:query]
end
def filtered_file_infos
releasables = policy_scope(@video.project.music_releases)
results = FileInfo.where(releasable: releasables)
if query_param.present?
results = results.search_filename(query_param)
end
results
end
end

View File

@@ -0,0 +1,27 @@
class VideoAnalyses::TalentReleasesController < ApplicationController
before_action :set_video
def index
@talent_releases = filtered_releases
end
private
def set_video
@video = Video.find(params[:video_id])
end
def query_param
params[:query]
end
def filtered_releases
results = policy_scope(@video.talent_releases)
if query_param.present?
results = results.search(query_param)
end
results
end
end

View File

@@ -0,0 +1,77 @@
class VideoAnalyses::UnreleasedAppearancesController < ApplicationController
before_action :set_video, except: [:edit, :update, :destroy]
def new
@unreleased_appearance = @video.unreleased_appearances.build(unreleased_appearance_params)
@edl_events_data = build_presenter.present
@unreleased_appearance.attributes = @edl_events_data[:edl_attributes]
end
def create
@unreleased_appearance = @video.unreleased_appearances.build(unreleased_appearance_params)
@unreleased_appearance.save
@unreleased_appearances_data = UnreleasedAppearancesPresenter.new.present(@video.unreleased_appearances)
end
def edit
@unreleased_appearance = find_unreleased_appearance
@video = @unreleased_appearance.video
@edl_events_data = build_presenter.present
end
def update
unreleased_appearance = find_unreleased_appearance
unreleased_appearance.update(unreleased_appearance_params)
@unreleased_appearances_data = UnreleasedAppearancesPresenter.new.present(unreleased_appearance.video.unreleased_appearances)
end
def destroy
unreleased_appearance = find_unreleased_appearance
video = unreleased_appearance.video
unreleased_appearance.destroy
@unreleased_appearances_data = UnreleasedAppearancesPresenter.new.present(video.unreleased_appearances)
end
private
def build_presenter
EdlEventsPresenter.new(EdlEventGateway.new(FilesForRequest.new(@video), @unreleased_appearance.appears_at, @unreleased_appearance.appears_at))
end
def unreleased_appearance_params
params
.require(:unreleased_appearance)
.permit(
:notes,
:time_elapsed,
:channel,
:timecode_in,
:timecode_out,
:duration,
:source_file_name,
:clip_name,
:description,
:note_category
)
end
def unreleased_appearances
if @video
policy_scope(@video.unreleased_appearances)
else
policy_scope(UnreleasedAppearance)
end
end
def videos
policy_scope(Video)
end
def find_unreleased_appearance
authorize unreleased_appearances.find(params[:id])
end
def set_video
@video = authorize videos.find(params[:video_id])
end
end