effective_cpd 1.6.0 → 1.6.1
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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 89acef6977a76e2072c93505be5f2e140df846d7a4c811cf9c6ae6f71b8f7cf5
|
4
|
+
data.tar.gz: a3bd58305e0e7ae3667ce9039944dbeba4f4c7a4f4299e48caaf723debc97db3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: da56f6fa2fe0699f60f071abf0b694621398efaa71979d8d9efdc07974010497d95d20529222609446b0a79f02aebd0527af3b321706a787471e439f98c06693
|
7
|
+
data.tar.gz: 297d83fdad2dbf217a16148fd624ce0411db56a937555ec1afb4efa043aeccdcfbb88f0acb713c8f8b46bf98698d21a358d6a9525d4d1c50f88dc5a95ba50c79
|
@@ -26,8 +26,8 @@ class EffectiveCpdAvailableCyclesDatatable < Effective::Datatable
|
|
26
26
|
|
27
27
|
collection do
|
28
28
|
raise('expected a current_user') unless current_user.present?
|
29
|
+
|
29
30
|
completed = EffectiveCpd.CpdStatement.completed.where(user: current_user)
|
30
31
|
Effective::CpdCycle.available.where.not(id: completed.select('cpd_cycle_id as id'))
|
31
32
|
end
|
32
|
-
|
33
33
|
end
|
@@ -1,3 +1,6 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
# rubocop:disable all
|
3
|
+
|
1
4
|
module Effective
|
2
5
|
class CpdScorer
|
3
6
|
include EffectiveResourcesHelper
|
@@ -9,9 +12,9 @@ module Effective
|
|
9
12
|
|
10
13
|
if from.present?
|
11
14
|
raise('expected from to be a CpdStatement') unless from.class.respond_to?(:effective_cpd_statement?)
|
15
|
+
|
12
16
|
@statements = @statements.where('cpd_cycle_id >= ?', from.cpd_cycle_id)
|
13
17
|
end
|
14
|
-
|
15
18
|
end
|
16
19
|
|
17
20
|
def score!
|
@@ -156,7 +159,11 @@ module Effective
|
|
156
159
|
|
157
160
|
def save_carry_forward_activity(existing, statement)
|
158
161
|
activity = statement.cpd_statement_activities.find { |a| a.original == (existing.original || existing) }
|
159
|
-
|
162
|
+
|
163
|
+
return if activity.blank? && statement.completed?
|
164
|
+
return if activity.blank? && !statement.cpd_cycle.available?
|
165
|
+
|
166
|
+
activity ||= statement.cpd_statement_activities.build
|
160
167
|
|
161
168
|
activity.assign_attributes(
|
162
169
|
cpd_category: existing.cpd_category,
|
@@ -57,8 +57,8 @@ module Effective
|
|
57
57
|
end
|
58
58
|
|
59
59
|
validate(if: -> { new_record? && cpd_statement.present? }, unless: -> { importing }) do
|
60
|
-
|
61
|
-
|
60
|
+
errors.add(:base, 'statement has already been completed') if cpd_statement.completed?
|
61
|
+
errors.add(:base, 'cycle is unavailable') unless cpd_statement.cpd_cycle.available?
|
62
62
|
end
|
63
63
|
|
64
64
|
def to_s
|
@@ -85,6 +85,5 @@ module Effective
|
|
85
85
|
def to_debug
|
86
86
|
"id=#{id}, score=#{score}, carry_foward=#{carry_forward}, carry_from_last=#{carry_over}, original=#{original&.id}"
|
87
87
|
end
|
88
|
-
|
89
88
|
end
|
90
89
|
end
|