Skip to content

Commit 6008265

Browse files
authored
Merge from docusealco/wip
2 parents 528a121 + 7fe5694 commit 6008265

36 files changed

Lines changed: 478 additions & 156 deletions

Gemfile.lock

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ GEM
116116
erubi (~> 1.4)
117117
parser (>= 2.4)
118118
smart_properties
119-
bigdecimal (4.1.0)
119+
bigdecimal (4.1.2)
120120
bindex (0.8.1)
121121
bootsnap (1.23.0)
122122
msgpack (~> 1.2)
@@ -161,7 +161,7 @@ GEM
161161
irb (~> 1.10)
162162
reline (>= 0.3.8)
163163
declarative (0.0.20)
164-
devise (5.0.3)
164+
devise (5.0.4)
165165
bcrypt (~> 3.0)
166166
orm_adapter (~> 0.1)
167167
railties (>= 7.0)
@@ -268,13 +268,13 @@ GEM
268268
mini_magick (>= 4.9.5, < 6)
269269
ruby-vips (>= 2.0.17, < 3)
270270
io-console (0.8.2)
271-
irb (1.17.0)
271+
irb (1.18.0)
272272
pp (>= 0.6.0)
273273
prism (>= 1.3.0)
274274
rdoc (>= 4.0.0)
275275
reline (>= 0.4.2)
276276
jmespath (1.6.2)
277-
json (2.19.3)
277+
json (2.19.5)
278278
jwt (3.1.2)
279279
base64
280280
language_server-protocol (3.17.0.5)
@@ -311,7 +311,7 @@ GEM
311311
mini_magick (5.3.1)
312312
logger
313313
mini_mime (1.1.5)
314-
minitest (6.0.3)
314+
minitest (6.0.6)
315315
drb (~> 2.0)
316316
prism (~> 1.5)
317317
msgpack (1.8.0)
@@ -429,7 +429,7 @@ GEM
429429
tsort (>= 0.2)
430430
zeitwerk (~> 2.6)
431431
rainbow (3.1.1)
432-
rake (13.3.1)
432+
rake (13.4.2)
433433
rdoc (7.2.0)
434434
erb
435435
psych (>= 4.0.0)
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
# frozen_string_literal: true
2+
3+
class SubmissionsResendEmailController < ApplicationController
4+
load_and_authorize_resource :submission
5+
6+
before_action do
7+
authorize!(:manage, :resend_all)
8+
authorize!(:update, @submission)
9+
end
10+
11+
def create
12+
submitters = @submission.submitters.reject(&:completed_at?).select { |s| s.email.present? && !s.declined_at? }
13+
14+
if Docuseal.multitenant?
15+
recent_submitter_ids =
16+
SubmissionEvent.where(submitter_id: submitters.map(&:id),
17+
event_type: 'send_email',
18+
created_at: 10.hours.ago..Time.current).pluck(:submitter_id).to_set
19+
20+
submitters = submitters.reject { |s| recent_submitter_ids.include?(s.id) }
21+
end
22+
23+
submitters.each do |submitter|
24+
SendSubmitterInvitationEmailJob.perform_async('submitter_id' => submitter.id)
25+
26+
submitter.sent_at ||= Time.current
27+
submitter.save!
28+
end
29+
30+
notice =
31+
if submitters.empty?
32+
I18n.t('email_has_been_sent_already')
33+
else
34+
I18n.t('emails_have_been_sent_to_n_recipients', count: submitters.size)
35+
end
36+
37+
redirect_back(fallback_location: submission_path(@submission), notice:)
38+
end
39+
end

app/controllers/submissions_unarchive_controller.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ class SubmissionsUnarchiveController < ApplicationController
44
load_and_authorize_resource :submission
55

66
def create
7+
authorize!(:update, @submission)
8+
79
@submission.update!(archived_at: nil)
810

911
redirect_to submission_path(@submission), notice: I18n.t('submission_has_been_unarchived')

app/controllers/submitters_send_email_controller.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ class SubmittersSendEmailController < ApplicationController
44
load_and_authorize_resource :submitter
55

66
def create
7+
authorize!(:update, @submitter)
8+
79
if Docuseal.multitenant? && SubmissionEvent.exists?(submitter: @submitter,
810
event_type: 'send_email',
911
created_at: 10.hours.ago..Time.current)

app/controllers/template_documents_controller.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ def index
1010
end
1111

1212
def create
13+
authorize!(:update, @template)
14+
1315
if params[:blobs].blank? && params[:files].blank?
1416
return render json: { error: I18n.t('file_is_missing') }, status: :unprocessable_content
1517
end

app/controllers/templates_clone_and_replace_controller.rb

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@ def create
1313

1414
cloned_template = Templates::Clone.call(@template, author: current_user)
1515
cloned_template.name = File.basename(params[:files].first.original_filename, '.*')
16+
17+
authorize!(:create, cloned_template)
18+
1619
cloned_template.save!
1720

1821
documents = Templates::ReplaceAttachments.call(cloned_template, params, extract_fields: true)

app/controllers/templates_controller.rb

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,8 +77,6 @@ def update
7777

7878
WebhookUrls.enqueue_events(@template, 'template.updated')
7979

80-
TemplateVersions.find_or_create_for(@template, author: current_user) if params[:revision]
81-
8280
head :ok
8381
end
8482

app/controllers/templates_folders_controller.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ class TemplatesFoldersController < ApplicationController
66
def edit; end
77

88
def update
9+
authorize!(:update, @template)
10+
911
name = [params[:parent_name], params[:name]].compact_blank.join(' / ')
1012

1113
@template.folder = TemplateFolders.find_or_create_by_name(current_user, name)

app/controllers/templates_restore_controller.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ class TemplatesRestoreController < ApplicationController
44
load_and_authorize_resource :template
55

66
def create
7+
authorize!(:update, @template)
8+
79
@template.update!(archived_at: nil)
810

911
WebhookUrls.enqueue_events(@template, 'template.updated')

app/controllers/templates_versions_controller.rb

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,12 @@ def show
1414

1515
render json: TemplateVersions.serialize(version)
1616
end
17+
18+
def create
19+
authorize!(:update, @template)
20+
21+
TemplateVersions.find_or_create_for(@template, author: current_user)
22+
23+
head :ok
24+
end
1725
end

0 commit comments

Comments
 (0)