effective_cpd 0.1.14 → 0.1.18

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 2653c7ce3493be3cd984924514326ab6e899d2cf45f56d4551c1c649db81431c
4
- data.tar.gz: cc4b83b1930e70c5a0ed9df43eaf199e936103edfd43835323e95a8df9c5273b
3
+ metadata.gz: c4f27b1163b09341852b3e9a136eebeffa80e30dc20662fb396e736d41a5b016
4
+ data.tar.gz: a6dac2da3b6a5e808cab6a225d7cc575541543103f5baa19a2ed732b143d71ea
5
5
  SHA512:
6
- metadata.gz: fe5e11e6d7341491c05646e2e680fa10b1d3f203958816640469d1e03763f00deaaccadd56f39f90172ae3bda06ed65768c20a6110ff6d82bec46e08cd540b70
7
- data.tar.gz: 0f867cee33de484ad41a3d8f7f0d9f4b57c8023ea3791429bc7cc77e305e950945084f56905527f256fe58c94d9bb850d304952d43b70856eb8e02cdf1a6f9b2
6
+ metadata.gz: c6f824e59e41b7b36284caaf1b6afd53692aca36b42671faf4fbe0b54e0f17748f03406e8e359f30be00d68fd15c9fa16deaa8dc72bf2608d446381fc7ab22d5
7
+ data.tar.gz: 3629eeb492a02a5645773d8412c9d301182e2ccf95548303a469d7c9783f36a36e087b60368b11ed42ae8bd65e0f02b6c05f796fbfaf171097210b3f7aa33ac8
@@ -3,6 +3,7 @@ module Effective
3
3
  before_action(:authenticate_user!) if defined?(Devise)
4
4
 
5
5
  include Effective::WizardController
6
+ include EffectiveCpdHelper
6
7
 
7
8
  resource_scope do
8
9
  cycle = Effective::CpdCycle.find(params[:cpd_cycle_id])
@@ -18,11 +19,7 @@ module Effective
18
19
  cycle = Effective::CpdCycle.find(params[:cpd_cycle_id])
19
20
  existing = Effective::CpdStatement.where(cpd_cycle: cycle, user: current_user).where.not(id: resource).first
20
21
 
21
- if existing&.completed?
22
- flash[:danger] = "You have already completed a statement for this #{cpd_cycle_label}."
23
- redirect_to(root_path)
24
- elsif existing.present?
25
- flash[:success] = "You have been redirected to the #{resource_wizard_step_title(existing, existing.next_step)} step."
22
+ if existing.present?
26
23
  redirect_to effective_cpd.cpd_cycle_cpd_statement_build_path(existing.cpd_cycle, existing, existing.next_step)
27
24
  end
28
25
  end
@@ -30,6 +30,16 @@ module Admin
30
30
  end
31
31
  end
32
32
  end.join.html_safe
33
+ end.search do |collection, term, column, sql_column|
34
+ user_klass = Effective::CpdAudit.first.user&.class
35
+
36
+ if user_klass.present?
37
+ users = Effective::Resource.new(user_klass).search_any(term)
38
+ cpd_audit_reviews = Effective::CpdAuditReview.where(user_id: users)
39
+ collection.where(id: cpd_audit_reviews.select('cpd_audit_id AS id'))
40
+ else
41
+ collection.where(id: nil)
42
+ end
33
43
  end
34
44
 
35
45
  col :notification_date, label: 'Date of Notification'
@@ -161,7 +161,10 @@ module Effective
161
161
  description: existing.description,
162
162
  )
163
163
 
164
- existing.files.each { |file| activity.files.attach(file.blob) }
164
+ existing.files.each do |file|
165
+ blob = EffectiveResources.clone_blob(file.blob)
166
+ activity.files.attach(blob)
167
+ end
165
168
 
166
169
  activity.assign_attributes(
167
170
  carry_over: existing.carry_forward,
@@ -38,7 +38,7 @@ module Effective
38
38
  validates :original, presence: true, if: -> { carry_over.to_i > 0 }
39
39
  validates :description, presence: true
40
40
 
41
- validate(if: -> { cpd_statement.present? }) do
41
+ validate(if: -> { new_record? && cpd_statement.present? }) do
42
42
  self.errors.add(:base, "statement has already been completed") if cpd_statement.completed?
43
43
  self.errors.add(:base, "cycle is unavailable") unless cpd_statement.cpd_cycle.available?
44
44
  end
@@ -1,3 +1,3 @@
1
1
  module EffectiveCpd
2
- VERSION = '0.1.14'
2
+ VERSION = '0.1.18'
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.1.14
4
+ version: 0.1.18
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: 2021-06-21 00:00:00.000000000 Z
11
+ date: 2021-10-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails