effective_cpd 0.2.1 → 0.3.0
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 +4 -4
- data/app/mailers/effective/cpd_mailer.rb +139 -67
- data/config/effective_cpd.rb +16 -22
- data/lib/effective_cpd/version.rb +1 -1
- data/lib/effective_cpd.rb +2 -31
- metadata +2 -3
- data/app/views/layouts/effective_cpd_mailer_layout.html.haml +0 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9940c548d939b8c1a285db0e19877bd4ed2147001fbebc947aaf6e02d548def6
|
4
|
+
data.tar.gz: 0547a9982f49587cbe07f2d3b65b6ab0da31be1728d7a55541cebd48cb560dde
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bc621cc69009ae0a6629d11f07b8fcabcbf9aafe011649b441d096e90754938104b24c5633b0b7374f298b005d4e558a2f6ebcdca1c19b2b442883d4a7e3e018
|
7
|
+
data.tar.gz: dca45ea584ab120514a7fb2d4231d2d19bcd373f84066e16ad57af2d05b46e605e7692d22e6e18c46913a3af233022dbac597672cacf337d7d350e80ae0b9030
|
@@ -1,122 +1,194 @@
|
|
1
1
|
module Effective
|
2
2
|
class CpdMailer < EffectiveCpd.parent_mailer_class
|
3
|
-
|
4
|
-
|
3
|
+
|
4
|
+
include EffectiveMailer
|
5
|
+
include EffectiveEmailTemplatesMailer if EffectiveCpd.use_effective_email_templates
|
5
6
|
|
6
7
|
# CPD Audit
|
7
|
-
def cpd_audit_opened(
|
8
|
-
|
9
|
-
|
8
|
+
def cpd_audit_opened(resource, opts = {})
|
9
|
+
raise('expected an Effective::CpdAudit') unless resource.kind_of?(Effective::CpdAudit)
|
10
|
+
|
11
|
+
@assigns = assigns_for(resource).merge(url: effective_cpd.cpd_audit_url(resource))
|
12
|
+
@cpd_audit = resource
|
13
|
+
|
14
|
+
subject = subject_for(__method__, 'CPD Audit Opened', resource, opts)
|
15
|
+
headers = headers_for(resource, opts)
|
10
16
|
|
11
|
-
mail(to:
|
17
|
+
mail(to: resource.user.email, subject: subject, **headers)
|
12
18
|
end
|
13
19
|
|
14
|
-
def cpd_audit_conflicted(
|
15
|
-
|
16
|
-
|
20
|
+
def cpd_audit_conflicted(resource, opts = {})
|
21
|
+
raise('expected an Effective::CpdAudit') unless resource.kind_of?(Effective::CpdAudit)
|
22
|
+
|
23
|
+
@assigns = assigns_for(resource).merge(url: effective_cpd.edit_admin_cpd_audit_url(resource))
|
24
|
+
@cpd_audit = resource
|
25
|
+
|
26
|
+
subject = subject_for(__method__, 'CPD Audit Conflicted', resource, opts)
|
27
|
+
headers = headers_for(resource, opts)
|
17
28
|
|
18
|
-
mail(to:
|
29
|
+
mail(to: mailer_admin, subject: subject, **headers)
|
19
30
|
end
|
20
31
|
|
21
|
-
def cpd_audit_conflict_resolved(
|
22
|
-
|
23
|
-
@assigns.merge!(url: effective_cpd.cpd_audit_url(cpd_audit))
|
32
|
+
def cpd_audit_conflict_resolved(resource, opts = {})
|
33
|
+
raise('expected an Effective::CpdAudit') unless resource.kind_of?(Effective::CpdAudit)
|
24
34
|
|
25
|
-
|
35
|
+
@assigns = assigns_for(resource).merge(url: effective_cpd.cpd_audit_url(resource))
|
36
|
+
@cpd_audit = resource
|
37
|
+
|
38
|
+
subject = subject_for(__method__, 'CPD Audit Conflict Resolved', resource, opts)
|
39
|
+
headers = headers_for(resource, opts)
|
40
|
+
|
41
|
+
mail(to: resource.user.email, subject: subject, **headers)
|
26
42
|
end
|
27
43
|
|
28
|
-
def cpd_audit_exemption_request(
|
29
|
-
|
30
|
-
|
44
|
+
def cpd_audit_exemption_request(resource, opts = {})
|
45
|
+
raise('expected an Effective::CpdAudit') unless resource.kind_of?(Effective::CpdAudit)
|
46
|
+
|
47
|
+
@assigns = assigns_for(resource).merge(url: effective_cpd.edit_admin_cpd_audit_url(resource))
|
48
|
+
@cpd_audit = resource
|
49
|
+
|
50
|
+
subject = subject_for(__method__, 'CPD Audit Exemption Request', resource, opts)
|
51
|
+
headers = headers_for(resource, opts)
|
31
52
|
|
32
|
-
mail(to:
|
53
|
+
mail(to: mailer_admin, subject: subject, **headers)
|
33
54
|
end
|
34
55
|
|
35
|
-
def cpd_audit_exemption_denied(
|
36
|
-
|
37
|
-
@assigns.merge!(url: effective_cpd.cpd_audit_url(cpd_audit))
|
56
|
+
def cpd_audit_exemption_denied(resource, opts = {})
|
57
|
+
raise('expected an Effective::CpdAudit') unless resource.kind_of?(Effective::CpdAudit)
|
38
58
|
|
39
|
-
|
59
|
+
@assigns = assigns_for(resource).merge(url: effective_cpd.cpd_audit_url(resource))
|
60
|
+
@cpd_audit = resource
|
61
|
+
|
62
|
+
subject = subject_for(__method__, 'CPD Audit Exemption Denied', resource, opts)
|
63
|
+
headers = headers_for(resource, opts)
|
64
|
+
|
65
|
+
mail(to: resource.user.email, subject: subject, **headers)
|
40
66
|
end
|
41
67
|
|
42
|
-
def cpd_audit_exemption_granted(
|
43
|
-
|
44
|
-
|
68
|
+
def cpd_audit_exemption_granted(resource, opts = {})
|
69
|
+
raise('expected an Effective::CpdAudit') unless resource.kind_of?(Effective::CpdAudit)
|
70
|
+
|
71
|
+
@assigns = assigns_for(resource).merge(url: effective_cpd.cpd_audit_url(resource))
|
72
|
+
@cpd_audit = resource
|
73
|
+
|
74
|
+
subject = subject_for(__method__, 'CPD Audit Exemption Granted', resource, opts)
|
75
|
+
headers = headers_for(resource, opts)
|
45
76
|
|
46
|
-
mail(to:
|
77
|
+
mail(to: resource.user.email, subject: subject, **headers)
|
47
78
|
end
|
48
79
|
|
49
|
-
def cpd_audit_extension_request(
|
50
|
-
|
51
|
-
@assigns.merge!(url: effective_cpd.edit_admin_cpd_audit_url(cpd_audit))
|
80
|
+
def cpd_audit_extension_request(resource, opts = {})
|
81
|
+
raise('expected an Effective::CpdAudit') unless resource.kind_of?(Effective::CpdAudit)
|
52
82
|
|
53
|
-
|
83
|
+
@assigns = assigns_for(resource).merge(url: effective_cpd.edit_admin_cpd_audit_url(resource))
|
84
|
+
@cpd_audit = resource
|
85
|
+
|
86
|
+
subject = subject_for(__method__, 'CPD Audit Extension Request', resource, opts)
|
87
|
+
headers = headers_for(resource, opts)
|
88
|
+
|
89
|
+
mail(to: mailer_admin, subject: subject, **headers)
|
54
90
|
end
|
55
91
|
|
56
|
-
def cpd_audit_extension_denied(
|
57
|
-
|
58
|
-
|
92
|
+
def cpd_audit_extension_denied(resource, opts = {})
|
93
|
+
raise('expected an Effective::CpdAudit') unless resource.kind_of?(Effective::CpdAudit)
|
94
|
+
|
95
|
+
@assigns = assigns_for(resource).merge(url: effective_cpd.cpd_audit_url(resource))
|
96
|
+
@cpd_audit = resource
|
97
|
+
|
98
|
+
subject = subject_for(__method__, 'CPD Audit Extension Denied', resource, opts)
|
99
|
+
headers = headers_for(resource, opts)
|
59
100
|
|
60
|
-
mail(to:
|
101
|
+
mail(to: resource.user.email, subject: subject, **headers)
|
61
102
|
end
|
62
103
|
|
63
|
-
def cpd_audit_extension_granted(
|
64
|
-
|
65
|
-
@assigns.merge!(url: effective_cpd.cpd_audit_url(cpd_audit))
|
104
|
+
def cpd_audit_extension_granted(resource, opts = {})
|
105
|
+
raise('expected an Effective::CpdAudit') unless resource.kind_of?(Effective::CpdAudit)
|
66
106
|
|
67
|
-
|
107
|
+
@assigns = assigns_for(resource).merge(url: effective_cpd.cpd_audit_url(resource))
|
108
|
+
@cpd_audit = resource
|
109
|
+
|
110
|
+
subject = subject_for(__method__, 'CPD Audit Extension Granted', resource, opts)
|
111
|
+
headers = headers_for(resource, opts)
|
112
|
+
|
113
|
+
mail(to: resource.user.email, subject: subject, **headers)
|
68
114
|
end
|
69
115
|
|
70
|
-
def cpd_audit_submitted(
|
71
|
-
|
72
|
-
|
116
|
+
def cpd_audit_submitted(resource, opts = {})
|
117
|
+
raise('expected an Effective::CpdAudit') unless resource.kind_of?(Effective::CpdAudit)
|
118
|
+
|
119
|
+
@assigns = assigns_for(resource).merge(url: effective_cpd.edit_admin_cpd_audit_url(resource))
|
120
|
+
@cpd_audit = resource
|
121
|
+
|
122
|
+
subject = subject_for(__method__, 'CPD Audit Submitted', resource, opts)
|
123
|
+
headers = headers_for(resource, opts)
|
73
124
|
|
74
|
-
mail(to:
|
125
|
+
mail(to: mailer_admin, subject: subject, **headers)
|
75
126
|
end
|
76
127
|
|
77
|
-
def cpd_audit_reviewed(
|
78
|
-
|
79
|
-
@assigns.merge!(url: effective_cpd.edit_admin_cpd_audit_url(cpd_audit))
|
128
|
+
def cpd_audit_reviewed(resource, opts = {})
|
129
|
+
raise('expected an Effective::CpdAudit') unless resource.kind_of?(Effective::CpdAudit)
|
80
130
|
|
81
|
-
|
131
|
+
@assigns = assigns_for(resource).merge(url: effective_cpd.edit_admin_cpd_audit_url(resource))
|
132
|
+
@cpd_audit = resource
|
133
|
+
|
134
|
+
subject = subject_for(__method__, 'CPD Audit Reviewed', resource, opts)
|
135
|
+
headers = headers_for(resource, opts)
|
136
|
+
|
137
|
+
mail(to: mailer_admin, subject: subject, **headers)
|
82
138
|
end
|
83
139
|
|
84
|
-
def cpd_audit_closed(
|
85
|
-
|
86
|
-
|
140
|
+
def cpd_audit_closed(resource, opts = {})
|
141
|
+
raise('expected an Effective::CpdAudit') unless resource.kind_of?(Effective::CpdAudit)
|
142
|
+
|
143
|
+
@assigns = assigns_for(resource).merge(url: effective_cpd.cpd_audit_url(resource))
|
144
|
+
@cpd_audit = resource
|
145
|
+
|
146
|
+
subject = subject_for(__method__, 'CPD Audit Closed', resource, opts)
|
147
|
+
headers = headers_for(resource, opts)
|
87
148
|
|
88
|
-
mail(to:
|
149
|
+
mail(to: resource.user.email, subject: subject, **headers)
|
89
150
|
end
|
90
151
|
|
91
152
|
# CPD Audit Review
|
92
|
-
def cpd_audit_review_opened(
|
93
|
-
|
94
|
-
@assigns.merge!(url: effective_cpd.cpd_audit_review_url(cpd_audit_review))
|
153
|
+
def cpd_audit_review_opened(resource, opts = {})
|
154
|
+
raise('expected an Effective::CpdAuditReview') unless resource.kind_of?(Effective::CpdAuditReview)
|
95
155
|
|
96
|
-
|
97
|
-
|
156
|
+
@assigns = assigns_for(resource).merge(url: effective_cpd.cpd_audit_review_url(resource))
|
157
|
+
@cpd_audit_review = resource
|
98
158
|
|
99
|
-
|
100
|
-
|
101
|
-
@assigns.merge!(url: effective_cpd.cpd_audit_review_url(cpd_audit_review))
|
159
|
+
subject = subject_for(__method__, 'CPD Audit Review Opened', resource, opts)
|
160
|
+
headers = headers_for(resource, opts)
|
102
161
|
|
103
|
-
mail(to:
|
162
|
+
mail(to: resource.user.email, subject: subject, **headers)
|
104
163
|
end
|
105
164
|
|
106
|
-
def
|
107
|
-
|
108
|
-
|
165
|
+
def cpd_audit_review_ready(resource, opts = {})
|
166
|
+
raise('expected an Effective::CpdAuditReview') unless resource.kind_of?(Effective::CpdAuditReview)
|
167
|
+
|
168
|
+
@assigns = assigns_for(resource).merge(url: effective_cpd.cpd_audit_review_url(resource))
|
169
|
+
@cpd_audit_review = resource
|
109
170
|
|
110
|
-
|
171
|
+
subject = subject_for(__method__, 'CPD Audit Review Ready', resource, opts)
|
172
|
+
headers = headers_for(resource, opts)
|
173
|
+
|
174
|
+
mail(to: resource.user.email, subject: subject, **headers)
|
111
175
|
end
|
112
176
|
|
113
|
-
|
177
|
+
def cpd_audit_review_submitted(resource, opts = {})
|
178
|
+
raise('expected an Effective::CpdAuditReview') unless resource.kind_of?(Effective::CpdAuditReview)
|
114
179
|
|
115
|
-
|
116
|
-
|
180
|
+
@assigns = assigns_for(resource).merge(url: effective_cpd.edit_admin_cpd_audit_url(resource.cpd_audit))
|
181
|
+
@cpd_audit_review = resource
|
182
|
+
|
183
|
+
subject = subject_for(__method__, 'CPD Audit Review Submitted', resource, opts)
|
184
|
+
headers = headers_for(resource, opts)
|
185
|
+
|
186
|
+
mail(to: mailer_admin, subject: subject, **headers)
|
117
187
|
end
|
118
188
|
|
119
|
-
|
189
|
+
protected
|
190
|
+
|
191
|
+
def assigns_for(resource)
|
120
192
|
unless resource.kind_of?(Effective::CpdAudit) || resource.kind_of?(Effective::CpdAuditReview)
|
121
193
|
raise('expected an Effective::CpdAudit or Effective::CpdAuditReview')
|
122
194
|
end
|
data/config/effective_cpd.rb
CHANGED
@@ -42,27 +42,21 @@ EffectiveCpd.setup do |config|
|
|
42
42
|
# Audit Reviewer Scope Collection
|
43
43
|
config.audit_reviewer_user_scope = :all
|
44
44
|
|
45
|
-
# Mailer
|
45
|
+
# Mailer Settings
|
46
|
+
# Please see config/initializers/effective_resources.rb for default effective_* gem mailer settings
|
47
|
+
#
|
46
48
|
# Configure the class responsible to send e-mails.
|
47
|
-
# config.mailer = 'Effective::
|
48
|
-
|
49
|
-
#
|
50
|
-
#
|
51
|
-
|
52
|
-
#
|
53
|
-
# config.
|
54
|
-
|
55
|
-
# Default
|
56
|
-
config.
|
57
|
-
|
58
|
-
#
|
59
|
-
config.
|
60
|
-
|
61
|
-
# Send Admin correspondence To
|
62
|
-
config.mailer_admin = "admin@example.com"
|
63
|
-
|
64
|
-
# Will work with effective_email_templates gem:
|
65
|
-
# - The audit and audit review email content will be preopulated based off the template
|
66
|
-
# - Uses an EmailTemplatesMailer mailer instead of ActionMailer::Base for default parent_mailer
|
67
|
-
config.use_effective_email_templates = false
|
49
|
+
# config.mailer = 'Effective::EventsMailer'
|
50
|
+
#
|
51
|
+
# Override effective_resource mailer defaults
|
52
|
+
#
|
53
|
+
# config.parent_mailer = nil # The parent class responsible for sending emails
|
54
|
+
# config.deliver_method = nil # The deliver method, deliver_later or deliver_now
|
55
|
+
# config.mailer_layout = nil # Default mailer layout
|
56
|
+
# config.mailer_sender = nil # Default From value
|
57
|
+
# config.mailer_admin = nil # Default To value for Admin correspondence
|
58
|
+
# config.mailer_subject = nil # Proc.new method used to customize Subject
|
59
|
+
|
60
|
+
# Use effective email templates for event notifications
|
61
|
+
config.use_effective_email_templates = true
|
68
62
|
end
|
data/lib/effective_cpd.rb
CHANGED
@@ -15,43 +15,14 @@ module EffectiveCpd
|
|
15
15
|
:cpd_audits_table_name, :cpd_audit_responses_table_name, :cpd_audit_response_options_table_name,
|
16
16
|
:cpd_audit_reviews_table_name, :cpd_audit_review_items_table_name,
|
17
17
|
:cycle_label, :credit_label, :layout, :auditee_user_scope, :audit_reviewer_user_scope,
|
18
|
-
:mailer, :parent_mailer, :deliver_method, :mailer_layout, :mailer_sender, :mailer_admin, :use_effective_email_templates
|
18
|
+
:mailer, :parent_mailer, :deliver_method, :mailer_layout, :mailer_sender, :mailer_admin, :mailer_subject, :use_effective_email_templates
|
19
19
|
]
|
20
20
|
end
|
21
21
|
|
22
22
|
include EffectiveGem
|
23
23
|
|
24
24
|
def self.mailer_class
|
25
|
-
|
26
|
-
Effective::CpdMailer
|
27
|
-
end
|
28
|
-
|
29
|
-
def self.parent_mailer_class
|
30
|
-
return parent_mailer.constantize if parent_mailer.present?
|
31
|
-
|
32
|
-
if use_effective_email_templates
|
33
|
-
require 'effective_email_templates'
|
34
|
-
Effective::EmailTemplatesMailer
|
35
|
-
else
|
36
|
-
ActionMailer::Base
|
37
|
-
end
|
38
|
-
end
|
39
|
-
|
40
|
-
def self.send_email(email, *args)
|
41
|
-
raise('expected args to be an Array') unless args.kind_of?(Array)
|
42
|
-
|
43
|
-
if defined?(Tenant)
|
44
|
-
tenant = Tenant.current || raise('expected a current tenant')
|
45
|
-
args << { tenant: tenant }
|
46
|
-
end
|
47
|
-
|
48
|
-
deliver_method = EffectiveCpd.deliver_method || EffectiveResources.deliver_method
|
49
|
-
|
50
|
-
begin
|
51
|
-
EffectiveCpd.mailer_class.send(email, *args).send(deliver_method)
|
52
|
-
rescue => e
|
53
|
-
raise if Rails.env.development? || Rails.env.test?
|
54
|
-
end
|
25
|
+
mailer&.constantize || Effective::CpdMailer
|
55
26
|
end
|
56
27
|
|
57
28
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: effective_cpd
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.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: 2022-
|
11
|
+
date: 2022-03-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -364,7 +364,6 @@ files:
|
|
364
364
|
- app/views/effective/cpd_statements/complete.html.haml
|
365
365
|
- app/views/effective/cpd_statements/start.html.haml
|
366
366
|
- app/views/effective/cpd_statements/submit.html.haml
|
367
|
-
- app/views/layouts/effective_cpd_mailer_layout.html.haml
|
368
367
|
- config/effective_cpd.rb
|
369
368
|
- config/routes.rb
|
370
369
|
- db/migrate/01_create_effective_cpd.rb.erb
|