effective_cpd 0.6.5 → 0.6.7

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: 4773c3b6961452cc64a5378b56d7227bab9c08df6bfc812d82f433988d8dfb03
4
- data.tar.gz: e92d9b394e070adeb054cf19ecf72ab6dd36a16dc144021fd7aa249bc33bbfd9
3
+ metadata.gz: 9f8ab2919547d6a9f2385feb05cd00366bfdf1d4bc8749be2714f2d789249164
4
+ data.tar.gz: 02f0a5a137070f384f19a604b1ff7df6af74e2c420c589306072c5e02a289969
5
5
  SHA512:
6
- metadata.gz: 3fa597aabce1172fd1070d7d907eea1eb0452d44d3e920ca0b4d553f96b5c3ef8901cdf9714c7ac0b44c61a615f45665ae00a78e83acd7da5171759730ce3a89
7
- data.tar.gz: 26b1acedec51bd60c81a485de86cc35d084d8bb16e8e7648e3c84a0b48743b603fedba909c9a4c3b48554fc59ed12a50a70c8dbe1414a9be3ffe452b350115e7
6
+ metadata.gz: fdb6eb4fea328ded00578d5c16d1e4ed9d46f1560a28c5af53d9fdd3a7ad8675bfe3deb9a8266b0de2a13f37109f22f2fc814850985bf2abaac39070e5b3c592
7
+ data.tar.gz: fd01df0b6f085280c1fc4c8065ba321de5644f765655de4bb0d11b5927c8caf81117a4d1ca50d87338ba0e075669c68a068b23374152ede1536afab78231ddee
@@ -19,6 +19,7 @@ module EffectiveCpdStatement
19
19
 
20
20
  included do
21
21
  acts_as_tokened
22
+ acts_as_reportable if respond_to?(:acts_as_reportable)
22
23
 
23
24
  acts_as_wizard(
24
25
  start: 'Start',
@@ -68,6 +69,11 @@ module EffectiveCpdStatement
68
69
  scope :draft, -> { where(submitted_at: nil) }
69
70
  scope :completed, -> { where.not(submitted_at: nil) }
70
71
 
72
+ # effective_reports
73
+ def reportable_scopes
74
+ { draft: nil, completed: nil }
75
+ end
76
+
71
77
  before_validation(if: -> { new_record? }) do
72
78
  self.user ||= current_user
73
79
  self.score ||= 0
@@ -23,6 +23,7 @@ module Effective
23
23
 
24
24
  acts_as_email_form
25
25
  acts_as_tokened
26
+ acts_as_reportable if respond_to?(:acts_as_reportable)
26
27
 
27
28
  COMPLETED_STATES = [:exemption_granted, :closed]
28
29
 
@@ -120,6 +121,11 @@ module Effective
120
121
  scope :waiting_on_auditee, -> { where(status: WAITING_ON_AUDITEE_STATES) }
121
122
  scope :waiting_on_reviewers, -> { where(status: WAITING_ON_REVIEWERS_STATES) }
122
123
 
124
+ # effective_reports
125
+ def reportable_scopes
126
+ { draft: nil, available: nil, completed: nil, waiting_on_admin: nil, waiting_on_auditee: nil, waiting_on_reviewers: nil }
127
+ end
128
+
123
129
  before_validation(if: -> { new_record? }) do
124
130
  self.notification_date ||= Time.zone.now
125
131
  self.due_date ||= deadline_to_submit()
@@ -181,10 +187,6 @@ module Effective
181
187
 
182
188
  steps << :conflict if cpd_audit_level.conflict_of_interest?
183
189
 
184
- if conflicted?
185
- return steps + [:waiting, :submit, :complete]
186
- end
187
-
188
190
  steps << :exemption if cpd_audit_level.can_request_exemption?
189
191
 
190
192
  unless exemption_requested?
@@ -232,20 +234,13 @@ module Effective
232
234
  started!
233
235
  end
234
236
 
235
- # Auditee wizard action
236
- def conflict!
237
- return started! unless conflict_of_interest?
238
-
239
- update!(status: :conflicted)
240
- send_email(:cpd_audit_conflicted)
241
- end
242
-
243
237
  # Admin action
244
238
  def resolve_conflict!
245
239
  wizard_steps[:conflict] = nil # Have them complete the conflict step again.
246
240
 
247
241
  assign_attributes(conflict_of_interest: false, conflict_of_interest_reason: nil)
248
242
  conflicted_resolved!
243
+ submitted!
249
244
 
250
245
  send_email(:cpd_audit_conflict_resolved)
251
246
  true
@@ -334,9 +329,17 @@ module Effective
334
329
 
335
330
  # Auditee wizard action
336
331
  def submit!
337
- submitted!
338
- cpd_audit_reviews.each { |cpd_audit_review| cpd_audit_review.ready! }
339
- send_email(:cpd_audit_submitted)
332
+ if conflict_of_interest?
333
+ conflicted!
334
+ send_email(:cpd_audit_conflicted)
335
+ else
336
+ submitted!
337
+
338
+ cpd_audit_reviews.each { |cpd_audit_review| cpd_audit_review.ready! }
339
+ send_email(:cpd_audit_submitted)
340
+ end
341
+
342
+ true
340
343
  end
341
344
 
342
345
  # Called in a before_save. Intended for applicant_review to call in its submit! method
@@ -16,6 +16,7 @@ module Effective
16
16
 
17
17
  acts_as_email_form
18
18
  acts_as_tokened
19
+ acts_as_reportable if respond_to?(:acts_as_reportable)
19
20
 
20
21
  acts_as_wizard(
21
22
  start: 'Start',
@@ -72,6 +73,11 @@ module Effective
72
73
  scope :available, -> { where(submitted_at: nil) }
73
74
  scope :completed, -> { where.not(submitted_at: nil) }
74
75
 
76
+ # effective_reports
77
+ def reportable_scopes
78
+ { available: nil, completed: nil }
79
+ end
80
+
75
81
  before_validation(if: -> { new_record? }) do
76
82
  self.cpd_audit_level ||= cpd_audit&.cpd_audit_level
77
83
  self.due_date ||= deadline_to_review()
@@ -16,9 +16,8 @@ module Effective
16
16
 
17
17
  has_many_attached :files
18
18
 
19
- if respond_to?(:log_changes)
20
- log_changes(to: :cpd_statement)
21
- end
19
+ acts_as_reportable if respond_to?(:acts_as_reportable)
20
+ log_changes(to: :cpd_statement) if respond_to?(:log_changes)
22
21
 
23
22
  effective_resource do
24
23
  amount :decimal
@@ -44,6 +43,11 @@ module Effective
44
43
  scope :draft, -> { where(cpd_statement_id: EffectiveCpd.CpdStatement.draft) }
45
44
  scope :completed, -> { where(cpd_statement_id: EffectiveCpd.CpdStatement.completed) }
46
45
 
46
+ # effective_reports
47
+ def reportable_scopes
48
+ { draft: nil, completed: nil }
49
+ end
50
+
47
51
  validates :original, presence: true, if: -> { (carry_over || 0) > 0 }
48
52
  validates :description, presence: true
49
53
 
@@ -1,5 +1,5 @@
1
1
  = render('layout') do
2
- - raise('expected a submitted cpd_audit') unless resource.was_submitted? || resource.closed?
2
+ - raise('expected a submitted or conflicted cpd_audit') unless (resource.was_submitted? || resource.was_conflicted? || resource.closed?)
3
3
 
4
4
  - if resource.was_submitted?
5
5
  .text-center
@@ -20,4 +20,6 @@
20
20
  = f.show_if :conflict_of_interest, false do
21
21
  = f.hidden_field :conflict_of_interest_reason, value: ''
22
22
 
23
+ %p A new auditor will be selected if there is a conflict of interest.
24
+
23
25
  = f.submit 'Save and Continue', center: true
@@ -1,3 +1,3 @@
1
1
  module EffectiveCpd
2
- VERSION = '0.6.5'
2
+ VERSION = '0.6.7'
3
3
  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.6.5
4
+ version: 0.6.7
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-12-06 00:00:00.000000000 Z
11
+ date: 2023-01-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails