effective_cpd 0.4.1 → 0.4.2

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: df7d2dbe808caefa87a85d090eba1d4b965b70bf968aa9531871b0d516d789a8
4
- data.tar.gz: a216335a0dd7f11b9401e62fba037e6ddca712f6d783ef23b255de0262e4971d
3
+ metadata.gz: 9945aa741b29b6997f437ba5eb0b7d9fc4d838c5f1c5c45f23d7588e13d28dfe
4
+ data.tar.gz: 503cf57539255dc4b2af5e3ef8b0cd590ca06dc1e12d651eeadbc3a3746e9600
5
5
  SHA512:
6
- metadata.gz: b89ca9e4f87072ce55077b1a5ba3549a9c14d55d382b1061bd1bb766ef4bcbce941294f257715381e651efd87d05e6caa310dd0bb39ee655968d872127b8d565
7
- data.tar.gz: 4f9d6bc3fb1079f9799eb0c5ad25a7c301ea3cccfe281878cd795de4b3bd748365268d8b06e683d52b3dd24f431e914c904da4c9b733bc11745a58b7de822e79
6
+ metadata.gz: 1d37582e54373eaaba6ffd9a35145a896fd85d25e7fcd44fb493f9979ce8ac82e5de7d2ee85e72f9dd95f4ff0995c949ea551704fb5413d1446b482b12ba49a5
7
+ data.tar.gz: 30ea4652b91215b6ff969d17fe0316771b75ebe8fd0f1dcd5800e686fb47013de4d21b77f63cca5dfdbb19ffe57218e8a3482b3d39664e45c0bcbd72530c716b
@@ -13,9 +13,11 @@ module EffectiveCpdUser
13
13
  end
14
14
 
15
15
  included do
16
- has_many :cpd_statements, -> { Effective::CpdStatement.sorted }, class_name: 'Effective::CpdStatement'
16
+ has_many :cpd_statements, -> { Effective::CpdStatement.sorted }, inverse_of: :user, class_name: 'Effective::CpdStatement'
17
17
  has_many :cpd_audits, -> { Effective::CpdAudit.sorted }, inverse_of: :user, class_name: 'Effective::CpdAudit'
18
18
  has_many :cpd_audit_reviews, -> { Effective::CpdAuditReview.sorted }, inverse_of: :user, class_name: 'Effective::CpdAuditReview'
19
+
20
+ accepts_nested_attributes_for :cpd_statements
19
21
  end
20
22
 
21
23
  def cpd_statement_required_score(cpd_statement)
@@ -26,6 +28,18 @@ module EffectiveCpdUser
26
28
  true
27
29
  end
28
30
 
31
+ def cpd_statement(cpd_cycle:)
32
+ raise('expected an Effective::CpdCycle') unless cpd_cycle.kind_of?(Effective::CpdCycle)
33
+ cpd_statements.find { |cpd_statement| cpd_statement.cpd_cycle_id == cpd_cycle.id }
34
+ end
35
+
36
+ # Find or build
37
+ def build_cpd_statement(cpd_cycle:)
38
+ raise('expected an Effective::CpdCycle') unless cpd_cycle.kind_of?(Effective::CpdCycle)
39
+
40
+ cpd_statement(cpd_cycle: cpd_cycle) || cpd_statements.build(cpd_cycle: cpd_cycle)
41
+ end
42
+
29
43
  module ClassMethods
30
44
  def effective_cpd_user?; true; end
31
45
  end
@@ -72,6 +72,16 @@ module Effective
72
72
  cpd_cycle.present? ? "#{cpd_cycle} Statement" : 'statement'
73
73
  end
74
74
 
75
+ def import!(date: nil)
76
+ date ||= Time.zone.now
77
+
78
+ wizard_steps[:start] ||= date
79
+ wizard_steps[:activities] ||= date
80
+ cpd_statement_activities.each { |activity| activity.importing = true }
81
+
82
+ save!
83
+ end
84
+
75
85
  # This is the review step where they click Submit Ballot
76
86
  def submit!
77
87
  wizard_steps[:complete] ||= Time.zone.now
@@ -1,6 +1,7 @@
1
1
  module Effective
2
2
  class CpdStatementActivity < ActiveRecord::Base
3
3
  attr_accessor :max_score
4
+ attr_accessor :importing
4
5
 
5
6
  belongs_to :cpd_statement
6
7
  belongs_to :cpd_category
@@ -38,7 +39,7 @@ module Effective
38
39
  validates :original, presence: true, if: -> { (carry_over || 0) > 0 }
39
40
  validates :description, presence: true
40
41
 
41
- validate(if: -> { new_record? && cpd_statement.present? }) do
42
+ validate(if: -> { new_record? && cpd_statement.present? }, unless: -> { importing }) do
42
43
  self.errors.add(:base, "statement has already been completed") if cpd_statement.completed?
43
44
  self.errors.add(:base, "cycle is unavailable") unless cpd_statement.cpd_cycle.available?
44
45
  end
@@ -1,7 +1,11 @@
1
1
  = effective_form_with(model: [:admin, cpd_audit_level], engine: true) do |f|
2
2
  = f.fields_for :cpd_audit_level_sections, cpd_audit_level_section do |fas|
3
- = fas.rich_text_area :top_content
4
- = fas.rich_text_area :bottom_content
3
+ - if defined?(EffectiveArticleEditor)
4
+ = fas.article_editor :top_content
5
+ = fas.article_editor :bottom_content
6
+ - else
7
+ = fas.rich_text_area :top_content
8
+ = fas.rich_text_area :bottom_content
5
9
 
6
10
  = f.submit
7
11
 
@@ -16,8 +16,10 @@
16
16
  = fc.select :cpd_special_rule_ids, cpd_cycle.cpd_special_rules, multiple: true,
17
17
  label: 'Special Rules', hint: "Special rules operate on more than one category at a time"
18
18
 
19
- = fc.rich_text_area :category_credit_description,
20
- hint: "A description of the maximum #{cpd_credits_label} and carry forward policy of activities for this category"
19
+ - if defined?(EffectiveArticleEditor)
20
+ = fc.article_editor :category_credit_description, hint: "A description of the maximum #{cpd_credits_label} and carry forward policy of activities for this category"
21
+ - else
22
+ = fc.rich_text_area :category_credit_description, hint: "A description of the maximum #{cpd_credits_label} and carry forward policy of activities for this category"
21
23
 
22
24
  = fc.check_box :unavailable, label: "Unavailable in this #{cpd_cycle_label}"
23
25
 
@@ -1,3 +1,3 @@
1
1
  module EffectiveCpd
2
- VERSION = '0.4.1'
2
+ VERSION = '0.4.2'
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.4.1
4
+ version: 0.4.2
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-09-07 00:00:00.000000000 Z
11
+ date: 2022-09-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails