handle template archived
This commit is contained in:
@@ -54,6 +54,12 @@ module Api
|
|||||||
|
|
||||||
return render json: { error: 'Template not found' }, status: :unprocessable_content if @template.nil?
|
return render json: { error: 'Template not found' }, status: :unprocessable_content if @template.nil?
|
||||||
|
|
||||||
|
if @template.archived_at?
|
||||||
|
Rollbar.warning("Archived template submission: #{@template.id}") if defined?(Rollbar)
|
||||||
|
|
||||||
|
return render json: { error: 'Template has been archived' }, status: :unprocessable_content
|
||||||
|
end
|
||||||
|
|
||||||
if @template.fields.blank?
|
if @template.fields.blank?
|
||||||
Rollbar.warning("Template does not contain fields: #{@template.id}") if defined?(Rollbar)
|
Rollbar.warning("Template does not contain fields: #{@template.id}") if defined?(Rollbar)
|
||||||
|
|
||||||
|
|||||||
@@ -38,6 +38,8 @@ class SubmissionsController < ApplicationController
|
|||||||
end
|
end
|
||||||
|
|
||||||
def create
|
def create
|
||||||
|
return redirect_to template_path(@template), alert: I18n.t('template_has_been_archived') if @template.archived_at?
|
||||||
|
|
||||||
save_template_message(@template, params) if params[:save_message] == '1'
|
save_template_message(@template, params) if params[:save_message] == '1'
|
||||||
|
|
||||||
[params.delete(:subject), params.delete(:body)] if params[:is_custom_message] != '1'
|
[params.delete(:subject), params.delete(:body)] if params[:is_custom_message] != '1'
|
||||||
|
|||||||
@@ -75,6 +75,10 @@ module Mcp
|
|||||||
|
|
||||||
return { content: [{ type: 'text', text: 'Template not found' }], isError: true } unless template
|
return { content: [{ type: 'text', text: 'Template not found' }], isError: true } unless template
|
||||||
|
|
||||||
|
if template.archived_at?
|
||||||
|
return { content: [{ type: 'text', text: 'Template has been archived' }], isError: true }
|
||||||
|
end
|
||||||
|
|
||||||
current_ability.authorize!(:create, Submission.new(template:, account_id: current_user.account_id))
|
current_ability.authorize!(:create, Submission.new(template:, account_id: current_user.account_id))
|
||||||
|
|
||||||
return { content: [{ type: 'text', text: 'Template has no fields' }], isError: true } if template.fields.blank?
|
return { content: [{ type: 'text', text: 'Template has no fields' }], isError: true } if template.fields.blank?
|
||||||
|
|||||||
Reference in New Issue
Block a user