validate zoom meeting url
This commit is contained in:
@@ -1,14 +1,11 @@
|
||||
class Admin::CastingCallInterviewsController < Admin::ApplicationController
|
||||
before_action :set_casting_call_interview, only: [:edit, :update, :show, :complete]
|
||||
before_action :build_casting_call_interview, only: [:new, :create]
|
||||
before_action :set_accounts, only: %i[new create edit]
|
||||
|
||||
def index
|
||||
@casting_call_interviews = casting_call_interviews.order_by_recent.paginate(page: params[:page])
|
||||
end
|
||||
|
||||
def new
|
||||
@accounts = accounts
|
||||
end
|
||||
|
||||
def create
|
||||
@casting_call_interview.attributes = casting_call_interview_params
|
||||
@@ -20,10 +17,6 @@ class Admin::CastingCallInterviewsController < Admin::ApplicationController
|
||||
end
|
||||
end
|
||||
|
||||
def edit
|
||||
@accounts = accounts
|
||||
end
|
||||
|
||||
def update
|
||||
if @casting_call_interview.update(casting_call_interview_params)
|
||||
redirect_to [:admin, :casting_call_interviews], notice: t(".notice")
|
||||
@@ -42,6 +35,10 @@ class Admin::CastingCallInterviewsController < Admin::ApplicationController
|
||||
|
||||
private
|
||||
|
||||
def set_accounts
|
||||
@accounts = accounts
|
||||
end
|
||||
|
||||
def casting_call_interview_params
|
||||
params.require(:casting_call_interview).permit(:casting_call_id, :performer_name, :interview_date, :zoom_meeting_url)
|
||||
end
|
||||
|
||||
@@ -5,6 +5,7 @@ class CastingCallInterview < ApplicationRecord
|
||||
has_secure_token
|
||||
|
||||
validates :performer_name, presence: true
|
||||
validate :zoom_meeting_url_validation
|
||||
|
||||
scope :completed, -> { where.not(interviewed_at: nil) }
|
||||
|
||||
@@ -19,4 +20,19 @@ class CastingCallInterview < ApplicationRecord
|
||||
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_call_interviews.validation_errors.invalid_meeting_url')
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user