effective_cpd 0.6.8 → 1.1.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.
Files changed (91) hide show
  1. checksums.yaml +4 -4
  2. data/app/controllers/admin/cpd_audit_levels_controller.rb +7 -1
  3. data/app/controllers/admin/cpd_audit_reviews_controller.rb +7 -1
  4. data/app/controllers/admin/cpd_audits_controller.rb +21 -1
  5. data/app/controllers/admin/cpd_statements_controller.rb +1 -1
  6. data/app/controllers/effective/cpd_audit_reviews_controller.rb +3 -39
  7. data/app/controllers/effective/cpd_audits_controller.rb +3 -41
  8. data/app/datatables/admin/effective_cpd_audit_levels_datatable.rb +1 -1
  9. data/app/datatables/admin/effective_cpd_audit_reviews_datatable.rb +4 -2
  10. data/app/datatables/admin/effective_cpd_audits_datatable.rb +12 -10
  11. data/app/datatables/effective_cpd_available_audit_reviews_datatable.rb +4 -4
  12. data/app/datatables/effective_cpd_available_audits_datatable.rb +1 -1
  13. data/app/datatables/effective_cpd_completed_audit_reviews_datatable.rb +3 -3
  14. data/app/datatables/effective_cpd_completed_audits_datatable.rb +2 -2
  15. data/app/helpers/effective_cpd_audits_helper.rb +0 -32
  16. data/app/mailers/effective/cpd_mailer.rb +37 -24
  17. data/app/models/concerns/effective_cpd_audit.rb +594 -0
  18. data/app/models/concerns/effective_cpd_audit_level.rb +111 -0
  19. data/app/models/concerns/effective_cpd_audit_review.rb +297 -0
  20. data/app/models/concerns/effective_cpd_user.rb +16 -11
  21. data/app/models/effective/cpd_audit.rb +1 -397
  22. data/app/models/effective/cpd_audit_level.rb +1 -83
  23. data/app/models/effective/cpd_audit_level_question.rb +1 -1
  24. data/app/models/effective/cpd_audit_level_section.rb +4 -3
  25. data/app/models/effective/cpd_audit_response.rb +4 -2
  26. data/app/models/effective/cpd_audit_review.rb +1 -224
  27. data/app/models/effective/cpd_audit_review_item.rb +1 -1
  28. data/app/views/admin/cpd_audit_levels/_form_content_audit.html.haml +1 -1
  29. data/app/views/admin/cpd_audit_levels/_form_content_audit_review.html.haml +1 -1
  30. data/app/views/admin/cpd_audit_levels/_form_cpd_audit_level.html.haml +7 -1
  31. data/app/views/admin/cpd_audit_levels/_form_cpd_audit_level_section.html.haml +2 -0
  32. data/app/views/admin/cpd_audit_reviews/_form.html.haml +4 -1
  33. data/app/views/admin/cpd_audits/_form.html.haml +1 -49
  34. data/app/views/admin/cpd_audits/{_form_determination.html.haml → _form_close.html.haml} +1 -1
  35. data/app/views/admin/cpd_audits/_form_complete.html.haml +17 -0
  36. data/app/views/admin/cpd_audits/_form_cpd_audit.html.haml +56 -0
  37. data/app/views/admin/cpd_audits/_form_deadlines.html.haml +8 -9
  38. data/app/views/admin/cpd_audits/_form_exemption.html.haml +1 -1
  39. data/app/views/admin/cpd_audits/_form_extension.html.haml +1 -1
  40. data/app/views/admin/cpd_audits/_form_files.html.haml +6 -0
  41. data/app/views/admin/cpd_audits/_form_missing_info.html.haml +11 -0
  42. data/app/views/admin/cpd_audits/_form_new.html.haml +3 -1
  43. data/app/views/admin/cpd_audits/_form_process.html.haml +18 -0
  44. data/app/views/admin/cpd_audits/_status.html.haml +48 -6
  45. data/app/views/effective/cpd/_dashboard.html.haml +15 -12
  46. data/app/views/effective/cpd_audit_level_questions/_cpd_audit_level_question.html.haml +2 -1
  47. data/app/views/effective/cpd_audit_reviews/_conflict.html.haml +1 -1
  48. data/app/views/effective/cpd_audit_reviews/_cpd_audit_level_section.html.haml +3 -3
  49. data/app/views/effective/cpd_audit_reviews/_cpd_audit_review.html.haml +3 -1
  50. data/app/views/effective/cpd_audit_reviews/_cpd_statement.html.haml +3 -3
  51. data/app/views/effective/cpd_audit_reviews/_feedback.html.haml +9 -0
  52. data/app/views/effective/cpd_audit_reviews/_files.html.haml +12 -0
  53. data/app/views/effective/cpd_audit_reviews/_layout.html.haml +3 -0
  54. data/app/views/effective/cpd_audit_reviews/_recommendation.html.haml +6 -2
  55. data/app/views/effective/cpd_audit_reviews/_summary.html.haml +41 -14
  56. data/app/views/effective/cpd_audit_reviews/conflict.html.haml +5 -1
  57. data/app/views/effective/cpd_audit_reviews/cpd_audit_level_section.html.haml +2 -2
  58. data/app/views/effective/cpd_audit_reviews/feedback.html.haml +16 -0
  59. data/app/views/effective/cpd_audit_reviews/files.html.haml +17 -0
  60. data/app/views/effective/cpd_audit_reviews/recommendation.html.haml +5 -3
  61. data/app/views/effective/cpd_audit_reviews/start.html.haml +10 -3
  62. data/app/views/effective/cpd_audit_reviews/statements.html.haml +4 -5
  63. data/app/views/effective/cpd_audit_reviews/submit.html.haml +1 -1
  64. data/app/views/effective/cpd_audit_reviews/submitted.html.haml +20 -0
  65. data/app/views/effective/cpd_audit_reviews/waiting.html.haml +1 -1
  66. data/app/views/effective/cpd_audits/_conflict.html.haml +1 -1
  67. data/app/views/effective/cpd_audits/_cpd.html.haml +1 -1
  68. data/app/views/effective/cpd_audits/_cpd_audit.html.haml +3 -1
  69. data/app/views/effective/cpd_audits/_cpd_audit_level_section.html.haml +1 -1
  70. data/app/views/effective/cpd_audits/_exemption.html.haml +1 -1
  71. data/app/views/effective/cpd_audits/_extension.html.haml +1 -1
  72. data/app/views/effective/cpd_audits/_files.html.haml +1 -1
  73. data/app/views/effective/cpd_audits/_missing_info.html.haml +19 -0
  74. data/app/views/effective/cpd_audits/_summary.html.haml +30 -12
  75. data/app/views/effective/cpd_audits/_waiting.html.haml +1 -1
  76. data/app/views/effective/cpd_audits/conflict.html.haml +5 -1
  77. data/app/views/effective/cpd_audits/cpd_audit_level_section.html.haml +1 -0
  78. data/app/views/effective/cpd_audits/start.html.haml +10 -4
  79. data/app/views/effective/cpd_audits/submit.html.haml +5 -2
  80. data/app/views/effective/cpd_audits/{complete.html.haml → submitted.haml} +13 -8
  81. data/app/views/effective/cpd_audits/waiting.html.haml +1 -1
  82. data/app/views/effective/cpd_mailer/cpd_audit_missing_info.liquid +15 -0
  83. data/app/views/effective/cpd_mailer/cpd_audit_review_ready.liquid +1 -1
  84. data/app/views/effective/cpd_mailer/cpd_audit_submitted.liquid +3 -1
  85. data/config/effective_cpd.rb +5 -2
  86. data/db/migrate/01_create_effective_cpd.rb.erb +36 -7
  87. data/lib/effective_cpd/engine.rb +4 -0
  88. data/lib/effective_cpd/version.rb +1 -1
  89. data/lib/effective_cpd.rb +13 -1
  90. metadata +19 -5
  91. data/app/views/effective/cpd_audit_reviews/complete.html.haml +0 -20
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ad66762dab7f12d782284fec08de4d8346ce61a8ef4404ef3dc5500b4a8fca1f
4
- data.tar.gz: d5b215d2d01940ed502ecf6cce06ff829f94defedb0ba55a8108c9525dcd01b3
3
+ metadata.gz: ce8f5f1c83904eecbd1cc49e84720ec7ed6d51aa39773354666b0e07e9bda56a
4
+ data.tar.gz: 3a69c509409f5d33427f19c223a4803d8b1a8a49aa1d8e9addc03ee4f16cefce
5
5
  SHA512:
6
- metadata.gz: 39749020879a1a6cb8b79860dd59658541d967968d115bc80d8074d85e269e7d915807eaaf89c31c207b40b6b5337153581296badf6c3722315d19383bc2e5e9
7
- data.tar.gz: 561847197e10cc191b670d13564539b21c5b152e51c005843e6c41723da3b737cf639c320608a15c7735168b2b409d5a5c69cb4a81f870c0338d3b510639609a
6
+ metadata.gz: 0dfbe56c0a27a8743663d3ae374a62c1f0c674d46b189a2636b144d8f3bfe12c1ccc19fd8163e63d0b92010aeedc8b62856a5f87558ce231842093279b2404d3
7
+ data.tar.gz: '0864c315be7007b31a19dc76b934618ffd6bf678f547a063d9e6bdd0c62b491b13fccf62b264a69dadb7652cd527bdc27e3a1832bc0aa6fd798a2105feef7bbf'
@@ -5,8 +5,14 @@ module Admin
5
5
 
6
6
  include Effective::CrudController
7
7
 
8
+ resource_scope -> { EffectiveCpd.CpdAuditLevel.deep.all }
9
+ datatable -> { EffectiveResources.best('Admin::EffectiveCpdAuditLevelsDatatable').new }
10
+
11
+ private
12
+
8
13
  def permitted_params
9
- params.require(:effective_cpd_audit_level).permit!
14
+ model = (params.key?(:effective_cpd_audit_level) ? :effective_cpd_audit_level : :cpd_audit_level)
15
+ params.require(model).permit!
10
16
  end
11
17
 
12
18
  end
@@ -5,8 +5,14 @@ module Admin
5
5
 
6
6
  include Effective::CrudController
7
7
 
8
+ resource_scope -> { EffectiveCpd.CpdAuditReview.deep.all }
9
+ datatable -> { EffectiveResources.best('Admin::EffectiveCpdAuditReviewsDatatable').new }
10
+
11
+ private
12
+
8
13
  def permitted_params
9
- params.require(:effective_cpd_audit_review).permit!
14
+ model = (params.key?(:effective_cpd_audit_review) ? :effective_cpd_audit_review : :cpd_audit_review)
15
+ params.require(model).permit!
10
16
  end
11
17
 
12
18
  end
@@ -5,6 +5,9 @@ module Admin
5
5
 
6
6
  include Effective::CrudController
7
7
 
8
+ resource_scope -> { EffectiveCpd.CpdAudit.deep.all }
9
+ datatable -> { EffectiveResources.best('Admin::EffectiveCpdAuditsDatatable').new }
10
+
8
11
  submit :resolve_conflict, 'Resolve Conflict of Interest', success: -> {
9
12
  [
10
13
  "Successfully resolved #{resource}",
@@ -33,8 +36,25 @@ module Admin
33
36
  ].compact.join(' ')
34
37
  }
35
38
 
39
+ submit :complete, 'Complete Audit', success: -> {
40
+ [
41
+ "Successfully completed #{resource}",
42
+ ("and sent reviewers an audit ready notification" unless resource.email_form_skip)
43
+ ].compact.join(' ')
44
+ }
45
+
46
+ submit :missing, 'Missing Info', success: -> {
47
+ [
48
+ "Successfully marked #{resource} as missing info",
49
+ ("and sent #{resource.user.email} a notification" unless resource.email_form_skip)
50
+ ].compact.join(' ')
51
+ }
52
+
53
+ private
54
+
36
55
  def permitted_params
37
- params.require(:effective_cpd_audit).permit!
56
+ model = (params.key?(:effective_cpd_audit) ? :effective_cpd_audit : :cpd_audit)
57
+ params.require(model).permit!
38
58
  end
39
59
 
40
60
  end
@@ -6,7 +6,7 @@ module Admin
6
6
  include Effective::CrudController
7
7
 
8
8
  resource_scope -> { EffectiveCpd.CpdStatement.deep.all }
9
- datatable -> { Admin::EffectiveCpdStatementsDatatable.new }
9
+ datatable -> { EffectiveResources.best('Admin::EffectiveCpdStatementsDatatable').new }
10
10
 
11
11
  page_title(only: :index) { "#{EffectiveCpd.program_label} Statements" }
12
12
 
@@ -5,56 +5,20 @@ module Effective
5
5
  include Effective::WizardController
6
6
 
7
7
  resource_scope do
8
- Effective::CpdAuditReview.deep.where(user: current_user)
8
+ EffectiveCpd.CpdAuditReview.deep.where(user: current_user)
9
9
  end
10
10
 
11
11
  # Reuse the same view for all cpd_audit_level_section steps
12
12
  # https://github.com/zombocom/wicked/blob/v1.3.4/lib/wicked/controller/concerns/render_redirect.rb#L32
13
13
  def render_step(the_step, options = {}, params = {})
14
14
  if resource.dynamic_wizard_statement_steps.keys.include?(the_step)
15
- render('cpd_statement', options)
15
+ render('effective/cpd_audit_reviews/cpd_statement', options)
16
16
  elsif resource.dynamic_wizard_questionnaire_steps.keys.include?(the_step)
17
- render('cpd_audit_level_section', options)
17
+ render('effective/cpd_audit_reviews/cpd_audit_level_section', options)
18
18
  else
19
19
  super
20
20
  end
21
21
  end
22
22
 
23
- def permitted_params
24
- case step
25
- when :start
26
- params.require(:effective_cpd_audit_review).permit(:current_step, :comments)
27
- when :information
28
- params.require(:effective_cpd_audit_review).permit(:current_step, :comments)
29
- when :instructions
30
- params.require(:effective_cpd_audit_review).permit(:current_step, :comments)
31
- when :conflict
32
- params.require(:effective_cpd_audit_review)
33
- .permit(:current_step, :comments, :conflict_of_interest, :conflict_of_interest_reason)
34
- when :statements
35
- params.require(:effective_cpd_audit_review).permit(:current_step, :comments)
36
- when :questionnaire
37
- params.require(:effective_cpd_audit_review).permit(:current_step, :comments)
38
- when :recommendation
39
- params.require(:effective_cpd_audit_review).permit(:current_step, :comments, :recommendation)
40
- when :submit
41
- params.require(:effective_cpd_audit_review).permit(:current_step)
42
- when :complete
43
- raise('unexpected post to complete')
44
- else
45
- if step.to_s.start_with?('statement')
46
- params.require(:effective_cpd_audit_review).permit(:current_step, :comments,
47
- cpd_audit_review_items_attributes: [:id, :item_id, :item_type, :recommendation, :comments]
48
- )
49
- elsif step.to_s.start_with?('section')
50
- params.require(:effective_cpd_audit_review).permit(:current_step, :comments,
51
- cpd_audit_review_items_attributes: [:id, :item_id, :item_type, :recommendation, :comments]
52
- )
53
- else
54
- raise('unexpected step')
55
- end
56
- end
57
- end
58
-
59
23
  end
60
24
  end
@@ -4,9 +4,9 @@ module Effective
4
4
 
5
5
  include Effective::WizardController
6
6
 
7
- resource_scope do
8
- Effective::CpdAudit.deep.where(user: current_user)
9
- end
7
+ resource_scope -> { EffectiveCpd.CpdAudit.deep.where(user: current_user) }
8
+
9
+ submit :resubmit, 'Resubmit Audit'
10
10
 
11
11
  # Reuse the same view for all cpd_audit_level_section steps
12
12
  # https://github.com/zombocom/wicked/blob/v1.3.4/lib/wicked/controller/concerns/render_redirect.rb#L32
@@ -15,43 +15,5 @@ module Effective
15
15
  render('cpd_audit_level_section', options)
16
16
  end
17
17
 
18
- def permitted_params
19
- case step
20
- when :start
21
- params.require(:effective_cpd_audit).permit(:current_step)
22
- when :information
23
- params.require(:effective_cpd_audit).permit(:current_step)
24
- when :instructions
25
- params.require(:effective_cpd_audit).permit(:current_step)
26
- when :conflict
27
- params.require(:effective_cpd_audit)
28
- .permit(:current_step, :conflict_of_interest, :conflict_of_interest_reason)
29
- when :exemption
30
- params.require(:effective_cpd_audit)
31
- .permit(:current_step, :exemption_request, :exemption_request_reason)
32
- when :extension
33
- params.require(:effective_cpd_audit)
34
- .permit(:current_step, :extension_request, :extension_request_date, :extension_request_reason)
35
- when :cpd
36
- params.require(:effective_cpd_audit).permit(:current_step)
37
- when :questionnaire
38
- params.require(:effective_cpd_audit).permit(:current_step)
39
- when :files
40
- params.require(:effective_cpd_audit).permit(:current_step, files: [])
41
- when :submit
42
- params.require(:effective_cpd_audit).permit(:current_step)
43
- when :complete
44
- raise('unexpected post to complete')
45
- else
46
- raise('unexpected step') unless step.to_s.start_with?('section')
47
-
48
- params.require(:effective_cpd_audit).permit(:current_step,
49
- cpd_audit_responses_attributes: [
50
- :id, :cpd_audit_id, :cpd_audit_level_question_id, :date, :email, :number, :long_answer, :short_answer, :upload_file, cpd_audit_level_question_option_ids: []
51
- ]
52
- )
53
- end
54
- end
55
-
56
18
  end
57
19
  end
@@ -28,7 +28,7 @@ module Admin
28
28
  end
29
29
 
30
30
  collection do
31
- Effective::CpdAuditLevel.all.deep
31
+ EffectiveCpd.CpdAuditLevel.all.deep
32
32
  end
33
33
  end
34
34
  end
@@ -12,10 +12,12 @@ module Admin
12
12
  col :id, visible: false
13
13
 
14
14
  col :cpd_audit
15
+ col :cpd_audit_level, search: EffectiveCpd.CpdAuditLevel.all.sorted
15
16
 
16
17
  col :auditee do |cpd_audit_review|
17
18
  user = cpd_audit_review.cpd_audit.user
18
- link_to(user, edit_admin_user_path(user))
19
+ url = "/admin/users/#{user.to_param}/edit"
20
+ link_to(user, url)
19
21
  end
20
22
 
21
23
  col :user, label: 'Audit Reviewer'
@@ -30,7 +32,7 @@ module Admin
30
32
  end
31
33
 
32
34
  collection do
33
- Effective::CpdAuditReview.all.deep
35
+ EffectiveCpd.CpdAuditReview.all.deep
34
36
  end
35
37
  end
36
38
  end
@@ -1,41 +1,41 @@
1
1
  module Admin
2
2
  class EffectiveCpdAuditsDatatable < Effective::Datatable
3
+
3
4
  filters do
4
5
  scope :all
5
6
  scope :available, label: 'In Progress'
6
- scope :completed
7
+ scope :done
7
8
  scope :waiting_on_admin
8
9
  scope :waiting_on_auditee
9
10
  scope :waiting_on_reviewers
10
11
  end
11
12
 
12
13
  datatable do
14
+ order :updated_at
15
+
13
16
  col :id, visible: false
14
17
  col :created_at, visible: false
15
18
  col :updated_at, visible: false
16
19
 
17
20
  col :token, visible: false
18
21
 
19
- col :cpd_audit_level, label: 'Audit Level'
22
+ col :cpd_audit_level, label: 'Audit Level', search: EffectiveCpd.CpdAuditLevel.sorted.all
20
23
 
21
24
  col :user, search: :string, label: 'Auditee'
22
25
 
23
26
  col(:cpd_audit_reviews, label: 'Auditor Reviewers', search: :string) do |cpd_audit|
24
27
  cpd_audit.cpd_audit_reviews.map(&:user).map do |user|
25
28
  content_tag(:div, class: 'col-resource_item') do
26
- if view.respond_to?(:edit_admin_user_path)
27
- link_to(user.to_s, edit_admin_user_path(user))
28
- else
29
- user.to_s
30
- end
29
+ url = view.respond_to?(:edit_admin_user_path) ? edit_admin_user_path(user) : "/admin/users/#{user.to_param}/edit"
30
+ link_to(user.to_s, url)
31
31
  end
32
32
  end.join.html_safe
33
33
  end.search do |collection, term, column, sql_column|
34
- user_klass = Effective::CpdAudit.first.user&.class
34
+ user_klass = EffectiveCpd.CpdAudit.first.user&.class
35
35
 
36
36
  if user_klass.present?
37
37
  users = Effective::Resource.new(user_klass).search_any(term)
38
- cpd_audit_reviews = Effective::CpdAuditReview.where(user_id: users)
38
+ cpd_audit_reviews = EffectiveCpd.CpdAuditReview.where(user_id: users)
39
39
  collection.where(id: cpd_audit_reviews.select('cpd_audit_id AS id'))
40
40
  else
41
41
  collection.where(id: nil)
@@ -90,11 +90,13 @@ module Admin
90
90
  col :extension_request_date, visible: false
91
91
  col :extension_request_reason, visible: false
92
92
 
93
+ col :files, visible: false
94
+
93
95
  actions_col
94
96
  end
95
97
 
96
98
  collection do
97
- Effective::CpdAudit.all.deep
99
+ EffectiveCpd.CpdAudit.all.deep
98
100
  end
99
101
  end
100
102
  end
@@ -8,10 +8,10 @@ class EffectiveCpdAvailableAuditReviewsDatatable < Effective::Datatable
8
8
 
9
9
  col :cpd_audit_level, label: 'Audit'
10
10
  col :due_date
11
- col :user, label: 'Auditee', action: false
11
+ col :name, label: 'Auditee', action: false
12
12
 
13
13
  col :ready_to_review do |cpd_audit|
14
- cpd_audit.was_submitted? ? 'Yes' : 'No'
14
+ cpd_audit.ready_to_review? ? 'Yes' : 'No'
15
15
  end
16
16
 
17
17
  actions_col(actions: []) do |cpd_audit|
@@ -28,9 +28,9 @@ class EffectiveCpdAvailableAuditReviewsDatatable < Effective::Datatable
28
28
  collection do
29
29
  raise('expected a current_user') unless current_user.present?
30
30
 
31
- reviews = Effective::CpdAuditReview.available.where(user: current_user)
31
+ reviews = EffectiveCpd.CpdAuditReview.available.where(user: current_user)
32
32
 
33
- Effective::CpdAudit.available.includes(:cpd_audit_reviews)
33
+ EffectiveCpd.CpdAudit.available.includes(:cpd_audit_reviews)
34
34
  .where(id: reviews.select('cpd_audit_id as id'))
35
35
  end
36
36
 
@@ -24,7 +24,7 @@ class EffectiveCpdAvailableAuditsDatatable < Effective::Datatable
24
24
 
25
25
  collection do
26
26
  raise('expected a current_user') unless current_user.present?
27
- Effective::CpdAudit.available.where(user: current_user)
27
+ EffectiveCpd.CpdAudit.available.where(user: current_user)
28
28
  end
29
29
 
30
30
  end
@@ -8,7 +8,7 @@ class EffectiveCpdCompletedAuditReviewsDatatable < Effective::Datatable
8
8
 
9
9
  col :cpd_audit_level, label: 'Audit'
10
10
  col :notification_date, label: 'Date of Notification'
11
- col :user, label: 'Auditee', action: false
11
+ col :name, label: 'Auditee', action: false
12
12
 
13
13
  col :recommendation do |cpd_audit|
14
14
  cpd_audit.cpd_audit_reviews.find { |r| r.user_id == current_user.id }.recommendation
@@ -23,9 +23,9 @@ class EffectiveCpdCompletedAuditReviewsDatatable < Effective::Datatable
23
23
  collection do
24
24
  raise('expected a current_user') unless current_user.present?
25
25
 
26
- reviews = Effective::CpdAuditReview.completed.where(user: current_user)
26
+ reviews = EffectiveCpd.CpdAuditReview.completed.where(user: current_user)
27
27
 
28
- Effective::CpdAudit.includes(:cpd_audit_reviews)
28
+ EffectiveCpd.CpdAudit.includes(:cpd_audit_reviews)
29
29
  .where(id: reviews.select('cpd_audit_id as id'))
30
30
  end
31
31
 
@@ -12,13 +12,13 @@ class EffectiveCpdCompletedAuditsDatatable < Effective::Datatable
12
12
  col :determination
13
13
 
14
14
  actions_col(actions: []) do |cpd_audit|
15
- dropdown_link_to('Show', effective_cpd.cpd_audit_build_path(cpd_audit, cpd_audit.last_completed_step))
15
+ dropdown_link_to('Show', effective_cpd.cpd_audit_build_path(cpd_audit, cpd_audit.last_completed_step || :start))
16
16
  end
17
17
  end
18
18
 
19
19
  collection do
20
20
  raise('expected a current_user') unless current_user.present?
21
- Effective::CpdAudit.completed.where(user: current_user)
21
+ EffectiveCpd.CpdAudit.completed.where(user: current_user)
22
22
  end
23
23
 
24
24
  end
@@ -12,37 +12,5 @@ module EffectiveCpdAuditsHelper
12
12
  [['Yes, I would like to request an extension', true], ['No extension request', false]]
13
13
  end
14
14
 
15
- def cpd_audit_summary_text(cpd_audit)
16
- case cpd_audit.status
17
- when 'opened'
18
- "The audit has been opened. The auditee and audit reviewers have been notified. Waiting for the auditee to submit their audit questionnaire."
19
- when 'started'
20
- "The auditee has begun their audit questionnaire. Waiting for the auditee to submit their audit questionnaire."
21
- when 'conflicted'
22
- "The auditee has declared a conflict of interest. Waiting for a new reviewer to be assigned or otherwise resolved."
23
- when 'conflicted_resolved'
24
- "The auditee had declared a conflict of interest. This has been resolved. Waiting for the auditee to submit their audit questionnaire."
25
- when 'exemption_requested'
26
- "The auditee has requested an exemption. Waiting for request to be granted or denied."
27
- when 'exemption_granted'
28
- "The exemption request has been granted. This audit may now be closed."
29
- when 'exemption_denied'
30
- "The exemption request has been denied. The audit will continue. Waiting for the auditee to submit their audit questionnaire."
31
- when 'extension_requested'
32
- "The auditee has requested an extension. Waiting for request to be granted or denied."
33
- when 'extension_granted'
34
- "The extension request has been granted. There is a new deadline. Waiting for the auditee to submit their audit questionnaire."
35
- when 'extension_denied'
36
- "The extension request has been denied. The deadline remains. Waiting for the auditee to submit their audit questionnaire."
37
- when 'submitted'
38
- "The auditee has submitted their audit questionnaire. Waiting on review."
39
- when 'reviewed'
40
- "The audit has been reviewed and is ready for the final determination to be made."
41
- when 'closed'
42
- "This audit has been closed with a final determination. All done."
43
- else
44
- raise("unexpected cpd audit status: #{cpd_audit.status}")
45
- end
46
- end
47
15
 
48
16
  end
@@ -6,7 +6,7 @@ module Effective
6
6
 
7
7
  # CPD Audit
8
8
  def cpd_audit_opened(resource, opts = {})
9
- raise('expected an Effective::CpdAudit') unless resource.kind_of?(Effective::CpdAudit)
9
+ raise('expected an EffectiveCpd.CpdAudit') unless resource.kind_of?(EffectiveCpd.CpdAudit)
10
10
 
11
11
  @assigns = assigns_for(resource).merge(url: effective_cpd.cpd_audit_url(resource))
12
12
  @cpd_audit = resource
@@ -18,7 +18,7 @@ module Effective
18
18
  end
19
19
 
20
20
  def cpd_audit_conflicted(resource, opts = {})
21
- raise('expected an Effective::CpdAudit') unless resource.kind_of?(Effective::CpdAudit)
21
+ raise('expected an EffectiveCpd.CpdAudit') unless resource.kind_of?(EffectiveCpd.CpdAudit)
22
22
 
23
23
  @assigns = assigns_for(resource).merge(url: effective_cpd.edit_admin_cpd_audit_url(resource))
24
24
  @cpd_audit = resource
@@ -30,7 +30,7 @@ module Effective
30
30
  end
31
31
 
32
32
  def cpd_audit_conflict_resolved(resource, opts = {})
33
- raise('expected an Effective::CpdAudit') unless resource.kind_of?(Effective::CpdAudit)
33
+ raise('expected an EffectiveCpd.CpdAudit') unless resource.kind_of?(EffectiveCpd.CpdAudit)
34
34
 
35
35
  @assigns = assigns_for(resource).merge(url: effective_cpd.cpd_audit_url(resource))
36
36
  @cpd_audit = resource
@@ -42,7 +42,7 @@ module Effective
42
42
  end
43
43
 
44
44
  def cpd_audit_exemption_request(resource, opts = {})
45
- raise('expected an Effective::CpdAudit') unless resource.kind_of?(Effective::CpdAudit)
45
+ raise('expected an EffectiveCpd.CpdAudit') unless resource.kind_of?(EffectiveCpd.CpdAudit)
46
46
 
47
47
  @assigns = assigns_for(resource).merge(url: effective_cpd.edit_admin_cpd_audit_url(resource))
48
48
  @cpd_audit = resource
@@ -54,7 +54,7 @@ module Effective
54
54
  end
55
55
 
56
56
  def cpd_audit_exemption_denied(resource, opts = {})
57
- raise('expected an Effective::CpdAudit') unless resource.kind_of?(Effective::CpdAudit)
57
+ raise('expected an EffectiveCpd.CpdAudit') unless resource.kind_of?(EffectiveCpd.CpdAudit)
58
58
 
59
59
  @assigns = assigns_for(resource).merge(url: effective_cpd.cpd_audit_url(resource))
60
60
  @cpd_audit = resource
@@ -66,7 +66,7 @@ module Effective
66
66
  end
67
67
 
68
68
  def cpd_audit_exemption_granted(resource, opts = {})
69
- raise('expected an Effective::CpdAudit') unless resource.kind_of?(Effective::CpdAudit)
69
+ raise('expected an EffectiveCpd.CpdAudit') unless resource.kind_of?(EffectiveCpd.CpdAudit)
70
70
 
71
71
  @assigns = assigns_for(resource).merge(url: effective_cpd.cpd_audit_url(resource))
72
72
  @cpd_audit = resource
@@ -78,7 +78,7 @@ module Effective
78
78
  end
79
79
 
80
80
  def cpd_audit_extension_request(resource, opts = {})
81
- raise('expected an Effective::CpdAudit') unless resource.kind_of?(Effective::CpdAudit)
81
+ raise('expected an EffectiveCpd.CpdAudit') unless resource.kind_of?(EffectiveCpd.CpdAudit)
82
82
 
83
83
  @assigns = assigns_for(resource).merge(url: effective_cpd.edit_admin_cpd_audit_url(resource))
84
84
  @cpd_audit = resource
@@ -90,7 +90,7 @@ module Effective
90
90
  end
91
91
 
92
92
  def cpd_audit_extension_denied(resource, opts = {})
93
- raise('expected an Effective::CpdAudit') unless resource.kind_of?(Effective::CpdAudit)
93
+ raise('expected an EffectiveCpd.CpdAudit') unless resource.kind_of?(EffectiveCpd.CpdAudit)
94
94
 
95
95
  @assigns = assigns_for(resource).merge(url: effective_cpd.cpd_audit_url(resource))
96
96
  @cpd_audit = resource
@@ -102,7 +102,7 @@ module Effective
102
102
  end
103
103
 
104
104
  def cpd_audit_extension_granted(resource, opts = {})
105
- raise('expected an Effective::CpdAudit') unless resource.kind_of?(Effective::CpdAudit)
105
+ raise('expected an EffectiveCpd.CpdAudit') unless resource.kind_of?(EffectiveCpd.CpdAudit)
106
106
 
107
107
  @assigns = assigns_for(resource).merge(url: effective_cpd.cpd_audit_url(resource))
108
108
  @cpd_audit = resource
@@ -114,7 +114,7 @@ module Effective
114
114
  end
115
115
 
116
116
  def cpd_audit_submitted(resource, opts = {})
117
- raise('expected an Effective::CpdAudit') unless resource.kind_of?(Effective::CpdAudit)
117
+ raise('expected an EffectiveCpd.CpdAudit') unless resource.kind_of?(EffectiveCpd.CpdAudit)
118
118
 
119
119
  @assigns = assigns_for(resource).merge(url: effective_cpd.edit_admin_cpd_audit_url(resource))
120
120
  @cpd_audit = resource
@@ -125,8 +125,20 @@ module Effective
125
125
  mail(to: mailer_admin, subject: subject, **headers)
126
126
  end
127
127
 
128
+ def cpd_audit_missing_info(resource, opts = {})
129
+ raise('expected an EffectiveCpd.CpdAudit') unless resource.kind_of?(EffectiveCpd.CpdAudit)
130
+
131
+ @assigns = assigns_for(resource).merge(url: effective_cpd.cpd_audit_url(resource))
132
+ @cpd_audit = resource
133
+
134
+ subject = subject_for(__method__, 'CPD Audit Missing Info', resource, opts)
135
+ headers = headers_for(resource, opts)
136
+
137
+ mail(to: resource.user.email, subject: subject, **headers)
138
+ end
139
+
128
140
  def cpd_audit_reviewed(resource, opts = {})
129
- raise('expected an Effective::CpdAudit') unless resource.kind_of?(Effective::CpdAudit)
141
+ raise('expected an EffectiveCpd.CpdAudit') unless resource.kind_of?(EffectiveCpd.CpdAudit)
130
142
 
131
143
  @assigns = assigns_for(resource).merge(url: effective_cpd.edit_admin_cpd_audit_url(resource))
132
144
  @cpd_audit = resource
@@ -138,7 +150,7 @@ module Effective
138
150
  end
139
151
 
140
152
  def cpd_audit_closed(resource, opts = {})
141
- raise('expected an Effective::CpdAudit') unless resource.kind_of?(Effective::CpdAudit)
153
+ raise('expected an EffectiveCpd.CpdAudit') unless resource.kind_of?(EffectiveCpd.CpdAudit)
142
154
 
143
155
  @assigns = assigns_for(resource).merge(url: effective_cpd.cpd_audit_url(resource))
144
156
  @cpd_audit = resource
@@ -151,7 +163,7 @@ module Effective
151
163
 
152
164
  # CPD Audit Review
153
165
  def cpd_audit_review_opened(resource, opts = {})
154
- raise('expected an Effective::CpdAuditReview') unless resource.kind_of?(Effective::CpdAuditReview)
166
+ raise('expected an EffectiveCpd.CpdAuditReview') unless resource.kind_of?(EffectiveCpd.CpdAuditReview)
155
167
 
156
168
  @assigns = assigns_for(resource).merge(url: effective_cpd.cpd_audit_review_url(resource))
157
169
  @cpd_audit_review = resource
@@ -163,7 +175,7 @@ module Effective
163
175
  end
164
176
 
165
177
  def cpd_audit_review_ready(resource, opts = {})
166
- raise('expected an Effective::CpdAuditReview') unless resource.kind_of?(Effective::CpdAuditReview)
178
+ raise('expected an EffectiveCpd.CpdAuditReview') unless resource.kind_of?(EffectiveCpd.CpdAuditReview)
167
179
 
168
180
  @assigns = assigns_for(resource).merge(url: effective_cpd.cpd_audit_review_url(resource))
169
181
  @cpd_audit_review = resource
@@ -175,7 +187,7 @@ module Effective
175
187
  end
176
188
 
177
189
  def cpd_audit_review_submitted(resource, opts = {})
178
- raise('expected an Effective::CpdAuditReview') unless resource.kind_of?(Effective::CpdAuditReview)
190
+ raise('expected an EffectiveCpd.CpdAuditReview') unless resource.kind_of?(EffectiveCpd.CpdAuditReview)
179
191
 
180
192
  @assigns = assigns_for(resource).merge(url: effective_cpd.edit_admin_cpd_audit_url(resource.cpd_audit))
181
193
  @cpd_audit_review = resource
@@ -189,12 +201,12 @@ module Effective
189
201
  protected
190
202
 
191
203
  def assigns_for(resource)
192
- unless resource.kind_of?(Effective::CpdAudit) || resource.kind_of?(Effective::CpdAuditReview)
193
- raise('expected an Effective::CpdAudit or Effective::CpdAuditReview')
204
+ unless resource.kind_of?(EffectiveCpd.CpdAudit) || resource.kind_of?(EffectiveCpd.CpdAuditReview)
205
+ raise('expected an EffectiveCpd.CpdAudit or EffectiveCpd.CpdAuditReview')
194
206
  end
195
207
 
196
- @cpd_audit = (resource.kind_of?(Effective::CpdAudit) ? resource : resource.cpd_audit)
197
- @cpd_audit_review = (resource if resource.kind_of?(Effective::CpdAuditReview))
208
+ @cpd_audit = (resource.kind_of?(EffectiveCpd.CpdAudit) ? resource : resource.cpd_audit)
209
+ @cpd_audit_review = (resource if resource.kind_of?(EffectiveCpd.CpdAuditReview))
198
210
 
199
211
  @auditee = @cpd_audit.user
200
212
  @reviewer = @cpd_audit_review.user if @cpd_audit_review.present?
@@ -203,11 +215,12 @@ module Effective
203
215
  audit: {
204
216
  title: @cpd_audit.to_s,
205
217
  level: @cpd_audit.cpd_audit_level.to_s,
206
- determination: @cpd_audit.determination.to_s
218
+ determination: @cpd_audit.determination.to_s,
219
+ missing_info_reason: @cpd_audit.missing_info_reason.to_s
207
220
  },
208
221
  auditee: {
209
- name: @auditee.to_s,
210
- email: @auditee.email
222
+ name: @cpd_audit.name,
223
+ email: (@cpd_audit.user.email unless @cpd_audit.anonymous?).to_s
211
224
  }
212
225
  }
213
226
 
@@ -218,8 +231,8 @@ module Effective
218
231
  recommendation: @cpd_audit_review.recommendation.to_s
219
232
  },
220
233
  reviewer: {
221
- name: @reviewer.to_s,
222
- email: @reviewer.email
234
+ name: @cpd_audit_review.name,
235
+ email: (@cpd_audit_review.user.email unless @cpd_audit_review.anonymous?).to_s
223
236
  }
224
237
  }
225
238
  end