effective_memberships 0.3.11 → 0.3.14

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 8200c84934681ed1e13ce23e75bf061f58e0f83f4549be02de3efdadf4f31c6e
4
- data.tar.gz: e09fda17565f145d34ccc7c18674159b943170a150a6798da453884fecc61372
3
+ metadata.gz: fa55f7742a08e8756e0b3db669d79875ac368f92c0b0363a04975ce1aa201b13
4
+ data.tar.gz: 5b664867bf6a689067f160141f0718b376b5b98f03be4dfa927ee285f295111e
5
5
  SHA512:
6
- metadata.gz: 15f1850e5b6aa9cc4124f49a1dd2ea8599222d2fbe54053d63b5bcc6171a3abfd9f551932d72eef79232024d7a04b93390c16fed8a57836e04ea3fea85011511
7
- data.tar.gz: 4a317ace51abee560000072f05426b38175900a56a2f0c31eede63207fa3b4edf6845608093b1d77eb47c9118c7f641031e68806e2b96c76b9f4edba6525440d
6
+ metadata.gz: 4a9dbe5ec6aec0b9fd1a5e446aa36cede071772da8bc2ac801316224b92c61fcd4807704da4c69ae65135ef48861abf82328d3ed2113970b5cf6a7a6015e3493
7
+ data.tar.gz: 3b94e9838b8a70f9e18f0924ff6d8d67d9554a2c091181114d09e8a5bd714712a3daabc23a243bc3a1e373083f15c861557bcbd1a915b009225518b158daf195
@@ -1,41 +1,61 @@
1
1
  module Effective
2
2
  class MembershipsMailer < EffectiveMemberships.parent_mailer_class
3
- include EffectiveEmailTemplatesMailer
4
3
 
5
- default from: -> { EffectiveMemberships.mailer_sender }
6
- layout -> { EffectiveMemberships.mailer_layout || 'effective_memberships_mailer_layout' }
4
+ include EffectiveMailer
5
+ include EffectiveEmailTemplatesMailer if EffectiveMemberships.use_effective_email_templates
7
6
 
8
7
  def applicant_completed(resource, opts = {})
9
8
  @assigns = assigns_for(resource)
10
- mail(to: resource.owner.email, **headers_for(resource, opts))
9
+ @applicant = resource
10
+
11
+ subject = subject_for(__method__, 'Applicant Completed', resource, opts)
12
+ headers = headers_for(resource, opts)
13
+
14
+ mail(to: resource.owner.email, subject: subject, **headers)
11
15
  end
12
16
 
13
17
  def applicant_missing_info(resource, opts = {})
14
18
  @assigns = assigns_for(resource)
15
- mail(to: resource.owner.email, **headers_for(resource, opts))
19
+ @applicant = resource
20
+
21
+ subject = subject_for(__method__, 'Applicant Missing Info', resource, opts)
22
+ headers = headers_for(resource, opts)
23
+
24
+ mail(to: resource.owner.email, subject: subject, **headers)
16
25
  end
17
26
 
18
27
  def applicant_approved(resource, opts = {})
19
28
  @assigns = assigns_for(resource)
20
- mail(to: resource.owner.email, **headers_for(resource, opts))
29
+ @applicant = resource
30
+
31
+ subject = subject_for(__method__, 'Applicant Approved', resource, opts)
32
+ headers = headers_for(resource, opts)
33
+
34
+ mail(to: resource.owner.email, subject: subject, **headers)
21
35
  end
22
36
 
23
37
  def applicant_declined(resource, opts = {})
24
38
  @assigns = assigns_for(resource)
25
- mail(to: resource.owner.email, **headers_for(resource, opts))
39
+ @applicant = resource
40
+
41
+ subject = subject_for(__method__, 'Applicant Declined', resource, opts)
42
+ headers = headers_for(resource, opts)
43
+
44
+ mail(to: resource.owner.email, subject: subject, **headers)
26
45
  end
27
46
 
28
47
  def applicant_reference_notification(resource, opts = {})
29
48
  @assigns = assigns_for(resource)
30
- mail(to: resource.email, **headers_for(resource, opts))
31
- end
49
+ @applicant_reference = resource
32
50
 
33
- protected
51
+ subject = subject_for(__method__, 'Reference Requested', resource, opts)
52
+ headers = headers_for(resource, opts)
34
53
 
35
- def headers_for(resource, opts = {})
36
- resource.respond_to?(:log_changes_datatable) ? opts.merge(log: resource) : opts
54
+ mail(to: resource.email, subject: subject, **headers)
37
55
  end
38
56
 
57
+ protected
58
+
39
59
  def assigns_for(resource)
40
60
  if resource.class.respond_to?(:effective_memberships_applicant?)
41
61
  return applicant_assigns(resource).merge(user_assigns(resource.owner))
@@ -56,7 +56,9 @@ module EffectiveMembershipsOwner
56
56
  owners = organizations if self.class.respond_to?(:effective_organizations_user?)
57
57
  owners = users if self.class.respond_to?(:effective_organizations_organization?)
58
58
 
59
- owners = Array(owners).reject { |owner| owner.try(:archived?) }
59
+ owners = Array(owners)
60
+ .select { |owner| owner.class.respond_to?(:effective_memberships_owner?) }
61
+ .reject { |owner| owner.try(:archived?) }
60
62
 
61
63
  owners.presence || [self]
62
64
  end
@@ -73,7 +75,11 @@ module EffectiveMembershipsOwner
73
75
 
74
76
  def organization_membership_present?(except: nil)
75
77
  return false unless self.class.respond_to?(:effective_organizations_user?)
76
- organizations.any? { |organization| organization != except && organization.membership_present? }
78
+
79
+ organizations
80
+ .select { |organization| organization.class.respond_to?(:effective_memberships_owner?) }
81
+ .reject { |organization| organization.try(:archived?) }
82
+ .any? { |organization| organization != except && organization.membership_present? }
77
83
  end
78
84
 
79
85
  def assign_member_role
@@ -26,27 +26,21 @@ EffectiveMemberships.setup do |config|
26
26
  # When false, hide the reviewed state entirely
27
27
  # config.applicant_reviews = false
28
28
 
29
- # Mailer Configuration
29
+ # Mailer Settings
30
+ # Please see config/initializers/effective_resources.rb for default effective_* gem mailer settings
31
+ #
30
32
  # Configure the class responsible to send e-mails.
31
33
  # config.mailer = 'Effective::MembershipsMailer'
32
-
33
- # Configure the parent class responsible to send e-mails.
34
- # config.parent_mailer = 'ActionMailer::Base'
35
-
36
- # Default deliver method
37
- # config.deliver_method = :deliver_later
38
-
39
- # Default layout
40
- # config.mailer_layout = 'effective_memberships_mailer_layout'
41
-
42
- # Default From
43
- config.mailer_sender = "no-reply@example.com"
44
-
45
- # Send Admin correspondence To
46
- config.mailer_admin = "admin@example.com"
47
-
48
- # Will work with effective_email_templates gem:
49
- # - The audit and audit review email content will be preopulated based off the template
50
- # - Uses an EmailTemplatesMailer mailer instead of ActionMailer::Base for default parent_mailer
51
- config.use_effective_email_templates = false
34
+ #
35
+ # Override effective_resource mailer defaults
36
+ #
37
+ # config.parent_mailer = nil # The parent class responsible for sending emails
38
+ # config.deliver_method = nil # The deliver method, deliver_later or deliver_now
39
+ # config.mailer_layout = nil # Default mailer layout
40
+ # config.mailer_sender = nil # Default From value
41
+ # config.mailer_admin = nil # Default To value for Admin correspondence
42
+ # config.mailer_subject = nil # Proc.new method used to customize Subject
43
+
44
+ # Will work with effective_email_templates gem
45
+ config.use_effective_email_templates = true
52
46
  end
@@ -1,3 +1,3 @@
1
1
  module EffectiveMemberships
2
- VERSION = '0.3.11'
2
+ VERSION = '0.3.14'
3
3
  end
@@ -10,7 +10,7 @@ module EffectiveMemberships
10
10
  :category_class_name, :applicant_class_name, :applicant_review_class_name, :fee_payment_class_name, :registrar_class_name, :membership_card_class_name,
11
11
  :additional_fee_types, :applicant_reviews,
12
12
  :layout,
13
- :mailer, :parent_mailer, :deliver_method, :mailer_layout, :mailer_sender, :mailer_admin, :use_effective_email_templates
13
+ :mailer, :parent_mailer, :deliver_method, :mailer_layout, :mailer_sender, :mailer_admin, :mailer_subject, :use_effective_email_templates
14
14
  ]
15
15
  end
16
16
 
@@ -50,17 +50,6 @@ module EffectiveMemberships
50
50
  mailer&.constantize || Effective::MembershipsMailer
51
51
  end
52
52
 
53
- def self.parent_mailer_class
54
- return parent_mailer.constantize if parent_mailer.present?
55
-
56
- if use_effective_email_templates
57
- require 'effective_email_templates'
58
- Effective::EmailTemplatesMailer
59
- else
60
- ActionMailer::Base
61
- end
62
- end
63
-
64
53
  def self.fee_types
65
54
  required = ['Applicant', 'Prorated', 'Discount', 'Renewal', 'Late', 'Admin']
66
55
  additional = Array(additional_fee_types)
@@ -73,21 +62,4 @@ module EffectiveMemberships
73
62
  ['Admin']
74
63
  end
75
64
 
76
- def self.send_email(email, *args)
77
- raise('expected args to be an Array') unless args.kind_of?(Array)
78
-
79
- if defined?(Tenant)
80
- tenant = Tenant.current || raise('expected a current tenant')
81
- args.last.kind_of?(Hash) ? args.last.merge!(tenant: tenant) : args << { tenant: tenant }
82
- end
83
-
84
- deliver_method = EffectiveMemberships.deliver_method || EffectiveResources.deliver_method
85
-
86
- begin
87
- EffectiveMemberships.mailer_class.send(email, *args).send(deliver_method)
88
- rescue => e
89
- raise if Rails.env.development? || Rails.env.test?
90
- end
91
- end
92
-
93
65
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: effective_memberships
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.11
4
+ version: 0.3.14
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: 2022-02-28 00:00:00.000000000 Z
11
+ date: 2022-03-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -410,7 +410,6 @@ files:
410
410
  - app/views/effective/memberships_mailer/applicant_declined.liquid
411
411
  - app/views/effective/memberships_mailer/applicant_missing_info.liquid
412
412
  - app/views/effective/memberships_mailer/applicant_reference_notification.liquid
413
- - app/views/layouts/effective_memberships_mailer_layout.html.haml
414
413
  - config/effective_memberships.rb
415
414
  - config/routes.rb
416
415
  - db/migrate/01_create_effective_memberships.rb.erb
@@ -1,7 +0,0 @@
1
- !!!
2
- %html{style: 'background: #fff;'}
3
- %head
4
- %meta{:content => 'text/html; charset=UTF-8', 'http-equiv' => 'Content-Type'}
5
-
6
- %body{style: 'background: #fff;'}
7
- = yield