app/controllers/insured/families_controller.rb
def upload_notice
    if !params[:file] || !params[:subject]
      flash[:error] = "File or Subject not provided"
      redirect_back(fallback_location: :back)
      return
    elsif file_content_type != 'application/pdf'
      flash[:error] = "Please upload a PDF file. Other file formats are not supported."
      redirect_back(fallback_location: :back)
      return
    end

    doc_uri = Aws::S3Storage.save(file_path, 'notices')

    if doc_uri.present?
      notice_document = Document.new({title: file_name, creator: "hbx_staff", subject: "notice", identifier: doc_uri,
                                      format: file_content_type})
      begin
        @person.documents << notice_document
        @person.save!
        send_notice_upload_notifications(notice_document, params[:subject])
        flash[:notice] = "File Saved"
      rescue => e
        flash[:error] = "Could not save file."
      end
    else
      flash[:error] = "Could not save file."
    end

      redirect_back(fallback_location: :back)
    return
  end
# admin manually uploads a notice for person
admin manually uploads a notice for person
admin manually uploads a notice for person
def upload_notice
    if !params[:file] || !params[:subject]
      flash[:error] = "File or Subject not provided"
      redirect_back(fallback_location: :back)
      return
    elsif file_content_type != 'application/pdf'
      flash[:error] = "Please upload a PDF file. Other file formats are not supported."
      redirect_back(fallback_location: :back)
      return
    end
    doc_uri = Aws::S3Storage.save(file_path, 'notices')
    if doc_uri.present?
      notice_document = Document.new({title: file_name, creator: "hbx_staff", subject: "notice", identifier: doc_uri,
                                      format: file_content_type})
      begin
        @person.documents << notice_document
        @person.save!
        send_notice_upload_notifications(notice_document, params[:subject])
        flash[:notice] = "File Saved"
      rescue => e
        flash[:error] = "Could not save file."
      end
    else
      flash[:error] = "Could not save file."
    end
      redirect_back(fallback_location: :back)
    return
  end
def upload_notice if ! params [ :file ] || ! params [ :subject ] flash [ :error ] = "File or Subject not provided" redirect_back ( fallback_location : :back ) return elsif file_content_type != 'application/pdf' flash [ :error ] = "Please upload a PDF file. Other file formats are not supported." redirect_back ( fallback_location : :back ) return end doc_uri = Aws :: S3Storage . save ( file_path , 'notices' ) if doc_uri . present? notice_document = Document . new ( { title : file_name , creator : "hbx_staff" , subject : "notice" , identifier : doc_uri , format : file_content_type } ) begin @person . documents << notice_document @person . save! send_notice_upload_notifications ( notice_document , params [ :subject ] ) flash [ :notice ] = "File Saved" rescue => e flash [ :error ] = "Could not save file." end else flash [ :error ] = "Could not save file." end redirect_back ( fallback_location : :back ) return end
admin manually uploads a notice for person
admin manually uploads a notice for person