effective_resources 2.22.1 → 2.23.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/helpers/effective_acts_as_email_form_helper.rb +9 -1
- data/app/models/concerns/acts_as_email_form.rb +2 -2
- data/app/models/concerns/acts_as_purchasable_wizard.rb +1 -1
- data/app/models/concerns/effective_devise_user.rb +31 -19
- data/app/views/effective/acts_as_email_form/_fields.html.haml +7 -15
- data/lib/effective_resources/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b5203021d6f8cd741603bcf0459f4277f6227c56fde16fd21fb99cae45564667
|
4
|
+
data.tar.gz: 505149510d60183e7b0935a043f6be30d96dbb79099225a89c6fdc136ad1100d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5efcc14c75d711551ae84574fd1bb64970273a170c7135a645af656b55be45ea8b71520827950933b13d636a32c51c5b0a4a58326666bbcf8722394ae086b6ad
|
7
|
+
data.tar.gz: ca89163745a47fe5be4342149df505800565cf6afc6991a9d765de4099d8b2efe17f570f27026eadaa5f7c6629edcd6d7f25c4f0ba5e6a13ea6b840f52c49f15
|
@@ -20,12 +20,20 @@ module EffectiveActsAsEmailFormHelper
|
|
20
20
|
# These defaults are only used when there is no email_template
|
21
21
|
email_defaults = form.object.email_form_defaults(action) unless email_template.present?
|
22
22
|
|
23
|
+
from = email_template&.from || email_defaults[:from] || EffectiveResources.mailer_froms.first
|
24
|
+
subject = email_template&.subject || email_defaults[:subject] || ''
|
25
|
+
body = email_template&.body || email_defaults[:body] || ''
|
26
|
+
content_type = email_template&.content_type || email_defaults[:content_type] || ''
|
27
|
+
|
23
28
|
locals = {
|
24
29
|
form: form,
|
25
30
|
email_to: to,
|
31
|
+
email_from: from,
|
32
|
+
email_subject: subject,
|
33
|
+
email_body: body,
|
34
|
+
email_content_type: content_type,
|
26
35
|
email_skip: skip,
|
27
36
|
email_action: (action || true),
|
28
|
-
email_defaults: email_defaults,
|
29
37
|
email_template: email_template,
|
30
38
|
email_variables: variables
|
31
39
|
}
|
@@ -41,7 +41,7 @@ module ActsAsEmailForm
|
|
41
41
|
validates :email_form_body, presence: true
|
42
42
|
|
43
43
|
validate(unless: -> { email_form_from.blank? }) do
|
44
|
-
|
44
|
+
errors.add(:email_form_from, 'must be a valid email address') unless email_form_from.include?('@')
|
45
45
|
end
|
46
46
|
end
|
47
47
|
|
@@ -60,7 +60,7 @@ module ActsAsEmailForm
|
|
60
60
|
|
61
61
|
# Only considered when not using an effective email template
|
62
62
|
def email_form_defaults(action)
|
63
|
-
{ from: nil, subject: nil, body: nil }
|
63
|
+
{ from: nil, subject: nil, body: nil, content_type: 'text/plain' }
|
64
64
|
end
|
65
65
|
|
66
66
|
end
|
@@ -96,7 +96,7 @@ module ActsAsPurchasableWizard
|
|
96
96
|
# From Billing Step
|
97
97
|
order.billing_address = owner.billing_address if owner.try(:billing_address).present?
|
98
98
|
|
99
|
-
# This will
|
99
|
+
# This will assign all order items to match the prices from their purchasable
|
100
100
|
order.try(:update_purchasable_attributes)
|
101
101
|
|
102
102
|
# Handle effective_memberships coupon fees price reduction
|
@@ -45,25 +45,6 @@ module EffectiveDeviseUser
|
|
45
45
|
avatar_url :string
|
46
46
|
end
|
47
47
|
|
48
|
-
# Devise invitable ignores model validations, so we manually check for duplicate email addresses.
|
49
|
-
before_save(if: -> { new_record? && try(:invitation_sent_at).present? }) do
|
50
|
-
if email.blank?
|
51
|
-
errors.add(:email, "can't be blank")
|
52
|
-
raise("email can't be blank")
|
53
|
-
end
|
54
|
-
|
55
|
-
value = email.strip.downcase
|
56
|
-
|
57
|
-
if self.class.where(email: value).present?
|
58
|
-
errors.add(:email, 'has already been taken')
|
59
|
-
raise("email has already been taken")
|
60
|
-
end
|
61
|
-
|
62
|
-
if respond_to?(:alternate_email) && self.class.where(alternate_email: value).present?
|
63
|
-
errors.add(:email, 'has already been taken')
|
64
|
-
raise("email has already been taken")
|
65
|
-
end
|
66
|
-
end
|
67
48
|
|
68
49
|
# Clear the provider if an oauth signed in user resets password
|
69
50
|
before_save(if: -> { persisted? && encrypted_password_changed? }) do
|
@@ -245,6 +226,30 @@ module EffectiveDeviseUser
|
|
245
226
|
super(value.to_s.strip.downcase.presence)
|
246
227
|
end
|
247
228
|
|
229
|
+
# Devise invitable ignores model validations, so we manually check for duplicate email addresses.
|
230
|
+
def invite!(invited_by = nil, options = {})
|
231
|
+
if new_record?
|
232
|
+
value = email.to_s.strip.downcase
|
233
|
+
|
234
|
+
if value.blank?
|
235
|
+
errors.add(:email, "can't be blank")
|
236
|
+
return false
|
237
|
+
end
|
238
|
+
|
239
|
+
if self.class.where(email: value).present?
|
240
|
+
errors.add(:email, 'has already been taken')
|
241
|
+
return false
|
242
|
+
end
|
243
|
+
|
244
|
+
if respond_to?(:alternate_email) && self.class.where(alternate_email: value).present?
|
245
|
+
errors.add(:email, 'has already been taken')
|
246
|
+
return false
|
247
|
+
end
|
248
|
+
end
|
249
|
+
|
250
|
+
super
|
251
|
+
end
|
252
|
+
|
248
253
|
def reinvite!
|
249
254
|
invite!
|
250
255
|
end
|
@@ -258,6 +263,13 @@ module EffectiveDeviseUser
|
|
258
263
|
false
|
259
264
|
end
|
260
265
|
|
266
|
+
# This allows the Sign Up form to work for existing users with a pending invitation
|
267
|
+
# It assigns the attributes from the sign_up_params, saves the user, accepts the invitation
|
268
|
+
# Note that this action skips the invitation_token validation and is therefore insecure.
|
269
|
+
def allow_sign_up_from_invitation?
|
270
|
+
true
|
271
|
+
end
|
272
|
+
|
261
273
|
def inactive_message
|
262
274
|
(respond_to?(:archived?) && archived?) ? :archived : super
|
263
275
|
end
|
@@ -4,26 +4,18 @@
|
|
4
4
|
= form.check_box :email_form_skip, label: 'Do not send email'
|
5
5
|
|
6
6
|
= form.hide_if :email_form_skip, true do
|
7
|
+
- errors = form.object.errors.present?
|
8
|
+
|
7
9
|
- if email_to.present?
|
8
10
|
= form.static_field :email_form_to, label: 'To', value: (email_to.try(:email) || email_to)
|
9
11
|
|
10
|
-
|
11
|
-
|
12
|
-
= form.text_field :email_form_subject, label: 'Subject'
|
13
|
-
= form.text_area :email_form_body, label: 'Body', rows: 10
|
14
|
-
|
15
|
-
- elsif email_template.present?
|
16
|
-
-# email_template is an Effective::EmailTemplate
|
17
|
-
- from_value = email_template.from || EffectiveResources.mailer_froms.first
|
18
|
-
= form.select :email_form_from, mailer_froms_collection(), label: 'From', value: from_value
|
19
|
-
= form.text_field :email_form_subject, label: 'Subject', value: email_template.subject
|
20
|
-
= form.text_area :email_form_body, label: 'Body', value: email_template.body, rows: 10
|
12
|
+
= form.select :email_form_from, mailer_froms_collection(), label: 'From', value: (email_from unless errors)
|
13
|
+
= form.text_field :email_form_subject, label: 'Subject', value: (email_subject unless errors)
|
21
14
|
|
15
|
+
- if email_content_type == 'text/html'
|
16
|
+
= form.article_editor :email_form_body, label: 'Body', mode: :email, value: (email_body unless errors)
|
22
17
|
- else
|
23
|
-
|
24
|
-
= form.select :email_form_from, mailer_froms_collection(), label: 'From', value: from_value
|
25
|
-
= form.text_field :email_form_subject, label: 'Subject', value: (email_defaults[:subject] || '')
|
26
|
-
= form.text_area :email_form_body, label: 'Body', rows: 10, value: (email_defaults[:body] || '')
|
18
|
+
= form.text_area :email_form_body, label: 'Body', rows: 10, value: (email_body unless errors)
|
27
19
|
|
28
20
|
- if email_variables.present?
|
29
21
|
%p The available variables are:
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: effective_resources
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.23.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Code and Effect
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-06-
|
11
|
+
date: 2024-06-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|