effective_cpd 1.0.0 → 1.1.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (95) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +12 -6
  3. data/app/controllers/admin/cpd_audit_levels_controller.rb +2 -2
  4. data/app/controllers/admin/cpd_audit_reviews_controller.rb +2 -2
  5. data/app/controllers/admin/cpd_audits_controller.rb +15 -1
  6. data/app/controllers/admin/cpd_statements_controller.rb +1 -1
  7. data/app/controllers/effective/cpd_audit_reviews_controller.rb +5 -39
  8. data/app/controllers/effective/cpd_audits_controller.rb +5 -41
  9. data/app/datatables/admin/effective_cpd_audit_reviews_datatable.rb +3 -1
  10. data/app/datatables/admin/effective_cpd_audits_datatable.rb +11 -9
  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 +257 -66
  18. data/app/models/concerns/effective_cpd_audit_level.rb +7 -4
  19. data/app/models/concerns/effective_cpd_audit_review.rb +121 -65
  20. data/app/models/concerns/effective_cpd_statement.rb +1 -0
  21. data/app/models/concerns/effective_cpd_user.rb +10 -5
  22. data/app/models/effective/cpd_audit_level_question.rb +1 -1
  23. data/app/models/effective/cpd_audit_level_section.rb +4 -3
  24. data/app/models/effective/cpd_audit_response.rb +3 -2
  25. data/app/models/effective/cpd_audit_review_item.rb +1 -1
  26. data/app/views/admin/cpd_audit_levels/_form_content_audit.html.haml +1 -1
  27. data/app/views/admin/cpd_audit_levels/_form_content_audit_review.html.haml +1 -1
  28. data/app/views/admin/cpd_audit_levels/_form_cpd_audit_level.html.haml +7 -1
  29. data/app/views/admin/cpd_audit_levels/_form_cpd_audit_level_section.html.haml +2 -0
  30. data/app/views/admin/cpd_audit_reviews/_form.html.haml +4 -1
  31. data/app/views/admin/cpd_audits/_form.html.haml +1 -49
  32. data/app/views/admin/cpd_audits/_form_chat.html.haml +4 -0
  33. data/app/views/admin/cpd_audits/{_form_determination.html.haml → _form_close.html.haml} +1 -1
  34. data/app/views/admin/cpd_audits/_form_complete.html.haml +17 -0
  35. data/app/views/admin/cpd_audits/_form_cpd_audit.html.haml +60 -0
  36. data/app/views/admin/cpd_audits/_form_deadlines.html.haml +8 -9
  37. data/app/views/admin/cpd_audits/_form_exemption.html.haml +1 -1
  38. data/app/views/admin/cpd_audits/_form_extension.html.haml +1 -1
  39. data/app/views/admin/cpd_audits/_form_files.html.haml +6 -0
  40. data/app/views/admin/cpd_audits/_form_missing_info.html.haml +11 -0
  41. data/app/views/admin/cpd_audits/_form_new.html.haml +3 -1
  42. data/app/views/admin/cpd_audits/_form_process.html.haml +18 -0
  43. data/app/views/admin/cpd_audits/_status.html.haml +48 -6
  44. data/app/views/admin/users/_form_cpd.html.haml +7 -0
  45. data/app/views/admin/users/_form_cpd_audits.html.haml +8 -0
  46. data/app/views/effective/cpd/_dashboard.html.haml +15 -12
  47. data/app/views/effective/cpd_audit_level_questions/_cpd_audit_level_question.html.haml +2 -1
  48. data/app/views/effective/cpd_audit_reviews/_conflict.html.haml +1 -1
  49. data/app/views/effective/cpd_audit_reviews/_cpd_audit_level_section.html.haml +3 -3
  50. data/app/views/effective/cpd_audit_reviews/_cpd_audit_review.html.haml +3 -1
  51. data/app/views/effective/cpd_audit_reviews/_cpd_statement.html.haml +3 -3
  52. data/app/views/effective/cpd_audit_reviews/_feedback.html.haml +9 -0
  53. data/app/views/effective/cpd_audit_reviews/_files.html.haml +12 -0
  54. data/app/views/effective/cpd_audit_reviews/_layout.html.haml +11 -1
  55. data/app/views/effective/cpd_audit_reviews/_recommendation.html.haml +6 -2
  56. data/app/views/effective/cpd_audit_reviews/_summary.html.haml +41 -14
  57. data/app/views/effective/cpd_audit_reviews/chat.html.haml +4 -0
  58. data/app/views/effective/cpd_audit_reviews/conflict.html.haml +5 -1
  59. data/app/views/effective/cpd_audit_reviews/cpd_audit_level_section.html.haml +2 -2
  60. data/app/views/effective/cpd_audit_reviews/feedback.html.haml +16 -0
  61. data/app/views/effective/cpd_audit_reviews/files.html.haml +17 -0
  62. data/app/views/effective/cpd_audit_reviews/recommendation.html.haml +5 -3
  63. data/app/views/effective/cpd_audit_reviews/start.html.haml +10 -3
  64. data/app/views/effective/cpd_audit_reviews/statements.html.haml +4 -5
  65. data/app/views/effective/cpd_audit_reviews/submit.html.haml +1 -1
  66. data/app/views/effective/cpd_audit_reviews/submitted.html.haml +20 -0
  67. data/app/views/effective/cpd_audit_reviews/waiting.html.haml +1 -1
  68. data/app/views/effective/cpd_audits/_conflict.html.haml +1 -1
  69. data/app/views/effective/cpd_audits/_cpd.html.haml +1 -1
  70. data/app/views/effective/cpd_audits/_cpd_audit.html.haml +3 -1
  71. data/app/views/effective/cpd_audits/_cpd_audit_level_section.html.haml +1 -1
  72. data/app/views/effective/cpd_audits/_exemption.html.haml +1 -1
  73. data/app/views/effective/cpd_audits/_extension.html.haml +2 -2
  74. data/app/views/effective/cpd_audits/_files.html.haml +1 -1
  75. data/app/views/effective/cpd_audits/_layout.html.haml +18 -6
  76. data/app/views/effective/cpd_audits/_missing_info.html.haml +19 -0
  77. data/app/views/effective/cpd_audits/_summary.html.haml +30 -12
  78. data/app/views/effective/cpd_audits/_waiting.html.haml +1 -1
  79. data/app/views/effective/cpd_audits/chat.html.haml +4 -0
  80. data/app/views/effective/cpd_audits/conflict.html.haml +5 -1
  81. data/app/views/effective/cpd_audits/cpd_audit_level_section.html.haml +1 -0
  82. data/app/views/effective/cpd_audits/start.html.haml +10 -4
  83. data/app/views/effective/cpd_audits/submit.html.haml +5 -2
  84. data/app/views/effective/cpd_audits/{complete.html.haml → submitted.haml} +13 -8
  85. data/app/views/effective/cpd_audits/waiting.html.haml +1 -1
  86. data/app/views/effective/cpd_mailer/cpd_audit_missing_info.liquid +15 -0
  87. data/app/views/effective/cpd_mailer/cpd_audit_review_ready.liquid +1 -1
  88. data/app/views/effective/cpd_mailer/cpd_audit_submitted.liquid +3 -1
  89. data/config/effective_cpd.rb +6 -2
  90. data/config/routes.rb +2 -0
  91. data/db/migrate/01_create_effective_cpd.rb.erb +25 -7
  92. data/lib/effective_cpd/version.rb +1 -1
  93. data/lib/effective_cpd.rb +5 -0
  94. metadata +34 -5
  95. 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: 5b9ef412f128415399ade394ba5ee59d6799d9f13a600904bccfc6c88aa80fd6
4
- data.tar.gz: 3c193fe0263c126908e9e2029ea303cfc9842b41d80de7e0bd29761afd97d870
3
+ metadata.gz: deb0da2dfd0958689944cea459a4e237ac5f765cecb2b5fc081e513b1b648f38
4
+ data.tar.gz: 913951e4a77ffa9fa00c22fb8c153702c7b05d3a9aefdeb4eaa90d3af0495a7d
5
5
  SHA512:
6
- metadata.gz: b8f785d86dedc5821fb7118a7e8ea2e7c5baedc29abcd470e0c420c8e1352e51aaa4bcd364a0822e75d013778fcfdd21ad20ab5337ee55223f12cda03bf7bcee
7
- data.tar.gz: 8a817518db9ab7b7a7104f3d6eb4991e9422bce880a4d5817bf9dd6e8917a6fd4070f96fdae059bd978bb6b6f6888faf781e0ee8c84ea959fb39ed9be6d0c129
6
+ metadata.gz: '08548deb0cbcbb5ad26f4f7d962b06ebda9d63e1e230ec7950c212f39ee83b97805bd133e1a9a807e77da7b8173e0e7443c60b3a19c86a93bb1bfa19c411c7ca'
7
+ data.tar.gz: 9180db8bd3c9cb84fbf13bc136cda24a4996822ff8217b0a3ddfd88501e646160209698ecde6734f32ab2a831aae1e11ec5cbacea96bdc43c973750c983f2c44
data/README.md CHANGED
@@ -186,8 +186,8 @@ if user.persisted?
186
186
  end
187
187
 
188
188
  if user.reviewer?
189
- can [:index], Effective::CpdAudit
190
- can [:index, :show, :update], Effective::CpdAuditReview, user_id: user.id
189
+ can [:index], EffectiveCpd.CpdAudit
190
+ can [:index, :show, :update], EffectiveCpd.CpdAuditReview, user_id: user.id
191
191
  end
192
192
 
193
193
  if user.admin?
@@ -197,15 +197,21 @@ if user.admin?
197
197
  can :manage, Effective::CpdCycle
198
198
  can :manage, Effective::CpdRule
199
199
 
200
- can([:index, :show], Effective::CpdStatement)
201
- can(:unsubmit, Effective::CpdStatement) { |statement| statement.completed? }
200
+ can([:index, :show], EffectiveCpd.CpdStatement)
201
+ can(:unsubmit, EffectiveCpd.CpdStatement) { |statement| statement.completed? }
202
202
 
203
203
  can :manage, Effective::CpdAuditLevel
204
204
  can :manage, Effective::CpdAuditLevelSection
205
205
  can :manage, Effective::CpdAuditLevelQuestion
206
206
 
207
- can :manage, Effective::CpdAudit
208
- can :manage, Effective::CpdAuditReview
207
+ can(crud - [:destroy], EffectiveCpd.CpdAudit)
208
+ can(:destroy, EffectiveCpd.CpdAudit) { |audit| audit.draft? }
209
+
210
+ can(:missing, EffectiveCpd.CpdAudit) { |audit| audit.was_submitted? && !audit.missing_info? }
211
+ can(:complete, EffectiveCpd.CpdAudit) { |audit| audit.was_submitted? && !audit.was_completed? }
212
+ can(:close, EffectiveCpd.CpdAudit) { |audit| audit.was_submitted? && !audit.closed? }
213
+
214
+ can(crud - [:edit, :update], EffectiveCpd.CpdAuditReview)
209
215
  end
210
216
  ```
211
217
 
@@ -5,8 +5,8 @@ module Admin
5
5
 
6
6
  include Effective::CrudController
7
7
 
8
- resource_scope -> { EffectiveCpd.AuditLevel.deep.all }
9
- datatable -> { Admin::EffectiveCpdAuditLevelsDatatable.new }
8
+ resource_scope -> { EffectiveCpd.CpdAuditLevel.deep.all }
9
+ datatable -> { EffectiveResources.best('Admin::EffectiveCpdAuditLevelsDatatable').new }
10
10
 
11
11
  private
12
12
 
@@ -5,8 +5,8 @@ module Admin
5
5
 
6
6
  include Effective::CrudController
7
7
 
8
- resource_scope -> { EffectiveCpd.AuditReview.deep.all }
9
- datatable -> { Admin::EffectiveCpdAuditReviewsDatatable.new }
8
+ resource_scope -> { EffectiveCpd.CpdAuditReview.deep.all }
9
+ datatable -> { EffectiveResources.best('Admin::EffectiveCpdAuditReviewsDatatable').new }
10
10
 
11
11
  private
12
12
 
@@ -6,7 +6,7 @@ module Admin
6
6
  include Effective::CrudController
7
7
 
8
8
  resource_scope -> { EffectiveCpd.CpdAudit.deep.all }
9
- datatable -> { Admin::EffectiveCpdAuditsDatatable.new }
9
+ datatable -> { EffectiveResources.best('Admin::EffectiveCpdAuditsDatatable').new }
10
10
 
11
11
  submit :resolve_conflict, 'Resolve Conflict of Interest', success: -> {
12
12
  [
@@ -36,6 +36,20 @@ module Admin
36
36
  ].compact.join(' ')
37
37
  }
38
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
+
39
53
  private
40
54
 
41
55
  def permitted_params
@@ -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,22 @@ 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
+ page_title 'Chat', only: [:chat]
12
+
11
13
  # Reuse the same view for all cpd_audit_level_section steps
12
14
  # https://github.com/zombocom/wicked/blob/v1.3.4/lib/wicked/controller/concerns/render_redirect.rb#L32
13
15
  def render_step(the_step, options = {}, params = {})
14
16
  if resource.dynamic_wizard_statement_steps.keys.include?(the_step)
15
- render('cpd_statement', options)
17
+ render('effective/cpd_audit_reviews/cpd_statement', options)
16
18
  elsif resource.dynamic_wizard_questionnaire_steps.keys.include?(the_step)
17
- render('cpd_audit_level_section', options)
19
+ render('effective/cpd_audit_reviews/cpd_audit_level_section', options)
18
20
  else
19
21
  super
20
22
  end
21
23
  end
22
24
 
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
25
  end
60
26
  end
@@ -4,9 +4,11 @@ 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
+
11
+ page_title 'Chat', only: [:chat]
10
12
 
11
13
  # Reuse the same view for all cpd_audit_level_section steps
12
14
  # https://github.com/zombocom/wicked/blob/v1.3.4/lib/wicked/controller/concerns/render_redirect.rb#L32
@@ -15,43 +17,5 @@ module Effective
15
17
  render('cpd_audit_level_section', options)
16
18
  end
17
19
 
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
20
  end
57
21
  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'
@@ -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,6 +90,8 @@ 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
 
@@ -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