class Admin::CastingSubmissionsController < Admin::ApplicationController before_action :set_casting_submission, only: [:edit, :update, :show, :complete] before_action :build_casting_submission, only: [:new, :create] before_action :set_accounts, only: %i[new create edit] def index @casting_submissions = casting_submissions.order_by_recent.paginate(page: params[:page]) end def create @casting_submission.attributes = casting_submission_params if @casting_submission.save redirect_to [:admin, :casting_submissions], notice: t(".notice") else render :new end end def update if @casting_submission.update(casting_submission_params) redirect_to [:admin, :casting_submissions], notice: t(".notice") else render :edit end end def complete if @casting_submission.update(interviewed_at: Time.zone.now) redirect_to [:admin, :casting_submissions], notice: t(".notice") else redirect_to [:admin, :casting_submissions], notice: t(".alert") end end private def set_accounts @accounts = accounts end def casting_submission_params params.require(:casting_submission).permit( :casting_call_id, :performer_name, :interview_date, :zoom_meeting_url, :interview_recording, :time_elapsed_1, :time_elapsed_2, :time_elapsed_3, :time_elapsed_4, :time_elapsed_5, :time_elapsed_6, :time_elapsed_7, :time_elapsed_8, :time_elapsed_9, :time_elapsed_10, :time_elapsed_11, :time_elapsed_12, :time_elapsed_13, :time_elapsed_14, :time_elapsed_15, :note_1 , :note_2 , :note_3 , :note_4, :note_5, :note_6, :note_7, :note_8, :note_9, :note_10, :note_11, :note_12, :note_13, :note_14, :note_15 ) end def casting_submissions policy_scope CastingSubmission end def set_casting_submission @casting_submission = authorize policy_scope(CastingSubmission).find(params[:id]) end def accounts policy_scope Account end def build_casting_submission @casting_submission = authorize policy_scope(CastingSubmission).build end end