Files
old-holivud2/app/models/casting_submission.rb

26 lines
702 B
Ruby
Raw Normal View History

2020-07-17 04:50:04 +02:00
class CastingSubmission < ApplicationRecord
2020-07-15 11:57:21 +02:00
belongs_to :casting_call
has_many_attached :files
2020-07-22 13:37:34 +00:00
has_one_attached :interview_recording
2020-07-15 11:57:21 +02:00
2020-07-27 10:18:49 +00:00
NUMBER_OF_MARKER_FIELDS = 15
2020-07-15 11:57:21 +02:00
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
2020-07-16 18:03:37 +02:00
2020-07-27 10:18:49 +00:00
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
2020-07-16 18:03:37 +02:00
end
2020-07-15 11:57:21 +02:00
end