From 518bbe3d1c54265f6f451aaf605ec9c144778bef Mon Sep 17 00:00:00 2001 From: DocuSeal Date: Sat, 7 Oct 2023 14:30:12 +0300 Subject: [PATCH] do not allow to submit archived forms --- app/controllers/submit_form_controller.rb | 2 ++ app/views/start_form/show.html.erb | 28 +++++++++++++++-------- app/views/submit_form/archived.html.erb | 21 +++++++++++++++++ 3 files changed, 41 insertions(+), 10 deletions(-) create mode 100644 app/views/submit_form/archived.html.erb diff --git a/app/controllers/submit_form_controller.rb b/app/controllers/submit_form_controller.rb index e5385f32..ea9e8597 100644 --- a/app/controllers/submit_form_controller.rb +++ b/app/controllers/submit_form_controller.rb @@ -18,6 +18,8 @@ class SubmitFormController < ApplicationController Submitters::MaybeUpdateDefaultValues.call(@submitter, current_user) cookies[:submitter_sid] = @submitter.signed_id + + render @submitter.submission.template.deleted_at? ? :archived : :show end def update diff --git a/app/views/start_form/show.html.erb b/app/views/start_form/show.html.erb index f0a3aefe..3e6c8b17 100644 --- a/app/views/start_form/show.html.erb +++ b/app/views/start_form/show.html.erb @@ -3,7 +3,9 @@
<%= render 'banner' %> -

You have been invited to submit a form

+ <% unless @template.deleted_at? %> +

You have been invited to submit a form

+ <% end %>
@@ -12,19 +14,25 @@

<%= @template.name %>

-

Invited by <%= @template.account.name %>

+ <% if @template.deleted_at? %> +

Form has been deleted by <%= @template.account.name %>.

+ <% else %> +

Invited by <%= @template.account.name %>

+ <% end %>
- <%= form_for @submitter, url: start_form_path(@template.slug), data: { turbo_frame: :_top }, method: :put, html: { class: 'space-y-4' } do |f| %> -
- <%= f.label :email, class: 'label' %> - <%= f.email_field :email, value: current_user&.email, required: true, class: 'base-input', placeholder: 'Provide your email to start' %> -
-
- <%= f.button button_title(title: 'Start', disabled_with: 'Starting'), class: 'base-button' %> -
+ <% unless @template.deleted_at? %> + <%= form_for @submitter, url: start_form_path(@template.slug), data: { turbo_frame: :_top }, method: :put, html: { class: 'space-y-4' } do |f| %> +
+ <%= f.label :email, class: 'label' %> + <%= f.email_field :email, value: current_user&.email, required: true, class: 'base-input', placeholder: 'Provide your email to start' %> +
+
+ <%= f.button button_title(title: 'Start', disabled_with: 'Starting'), class: 'base-button' %> +
+ <% end %> <% end %> diff --git a/app/views/submit_form/archived.html.erb b/app/views/submit_form/archived.html.erb new file mode 100644 index 00000000..56411a4d --- /dev/null +++ b/app/views/submit_form/archived.html.erb @@ -0,0 +1,21 @@ +
+
+
+
+ <%= render 'start_form/banner' %> +
+
+
+
+ <%= svg_icon('writing_sign', class: 'w-10 h-10') %> +
+
+

<%= @submitter.submission.template.name %>

+

Form has been deleted by <%= @submitter.submission.template.account.name %>.

+
+
+
+
+
+
+<%= render 'shared/attribution' %>