26 lines
702 B
Ruby
26 lines
702 B
Ruby
class CastingSubmission < ApplicationRecord
|
|
belongs_to :casting_call
|
|
has_many_attached :files
|
|
has_one_attached :interview_recording
|
|
|
|
NUMBER_OF_MARKER_FIELDS = 15
|
|
|
|
has_secure_token
|
|
|
|
validates :performer_name, presence: true
|
|
|
|
scope :completed, -> { where.not(interviewed_at: nil) }
|
|
|
|
def zip_file_name
|
|
"#{self.casting_call.title.parameterize}_#{self.performer_name.parameterize}_#{Time.now.strftime('%Y-%m-%d_%H-%M-%S')}"
|
|
end
|
|
|
|
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
|