Upstream sync
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user