mirror of https://github.com/docusealco/docuseal
				
				
				
			
			You can not select more than 25 topics
			Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
		
		
		
		
		
			
		
			
				
					
					
						
							35 lines
						
					
					
						
							950 B
						
					
					
				
			
		
		
	
	
							35 lines
						
					
					
						
							950 B
						
					
					
				# frozen_string_literal: true
 | 
						|
 | 
						|
class SubmitFormController < ApplicationController
 | 
						|
  layout 'form'
 | 
						|
 | 
						|
  skip_before_action :authenticate_user!
 | 
						|
  skip_authorization_check
 | 
						|
 | 
						|
  def show
 | 
						|
    @submitter =
 | 
						|
      Submitter.preload(submission: [
 | 
						|
                          :template, { template_schema_documents: [:blob, { preview_images_attachments: :blob }] }
 | 
						|
                        ])
 | 
						|
               .find_by!(slug: params[:slug])
 | 
						|
 | 
						|
    return redirect_to submit_form_completed_path(@submitter.slug) if @submitter.completed_at?
 | 
						|
 | 
						|
    cookies[:submitter_sid] = @submitter.signed_id
 | 
						|
  end
 | 
						|
 | 
						|
  def update
 | 
						|
    submitter = Submitter.find_by!(slug: params[:slug])
 | 
						|
 | 
						|
    Submitters::SubmitValues.call(submitter, params, request)
 | 
						|
 | 
						|
    head :ok
 | 
						|
  rescue Submitters::SubmitValues::ValidationError => e
 | 
						|
    render json: { error: e.message }, status: :unprocessable_entity
 | 
						|
  end
 | 
						|
 | 
						|
  def completed
 | 
						|
    @submitter = Submitter.find_by!(slug: params[:submit_form_slug])
 | 
						|
  end
 | 
						|
end
 |