rename to templates

This commit is contained in:
Alex Turchyn
2023-05-31 23:19:20 +03:00
parent 98fc9d964a
commit 4a303cb423
59 changed files with 248 additions and 264 deletions
+10 -10
View File
@@ -1,16 +1,16 @@
# frozen_string_literal: true
class SubmissionsController < ApplicationController
before_action :load_flow, only: %i[index new create]
before_action :load_template, only: %i[index new create]
def index
@submissions = @flow.submissions.active
@submissions = @template.submissions.active
end
def show
@submission =
Submission.joins(:flow).where(flow: { account_id: current_account.id })
.preload(flow: { documents_attachments: { preview_images_attachments: :blob } })
Submission.joins(:template).where(template: { account_id: current_account.id })
.preload(template: { documents_attachments: { preview_images_attachments: :blob } })
.find(params[:id])
end
@@ -21,7 +21,7 @@ class SubmissionsController < ApplicationController
submissions =
emails.map do |email|
submission = @flow.submissions.create!(email:, sent_at: params[:send_email] == '1' ? Time.current : nil)
submission = @template.submissions.create!(email:, sent_at: params[:send_email] == '1' ? Time.current : nil)
if params[:send_email] == '1'
SubmissionMailer.invitation_email(submission, message: params[:message]).deliver_later!
@@ -30,21 +30,21 @@ class SubmissionsController < ApplicationController
submission
end
redirect_to flow_submissions_path(@flow), notice: "#{submissions.size} recepients added"
redirect_to template_submissions_path(@template), notice: "#{submissions.size} recepients added"
end
def destroy
submission = Submission.joins(:flow).where(flow: { account_id: current_account.id })
submission = Submission.joins(:template).where(template: { account_id: current_account.id })
.find(params[:id])
submission.update!(deleted_at: Time.current)
redirect_to flow_submissions_path(submission.flow), notice: 'Submission has been archieved'
redirect_to template_submissions_path(submission.template), notice: 'Submission has been archieved'
end
private
def load_flow
@flow = current_account.flows.find(params[:flow_id])
def load_template
@template = current_account.templates.find(params[:template_id])
end
end