effective_cpd 1.2.2 → 1.2.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +8 -0
- data/app/models/concerns/effective_cpd_audit.rb +40 -3
- data/app/views/admin/cpd_audits/_form_chat.html.haml +9 -0
- data/app/views/effective/cpd/_dashboard.html.haml +4 -0
- data/app/views/effective/cpd_audit_reviews/_feedback.html.haml +1 -1
- data/app/views/effective/cpd_audit_reviews/_summary.html.haml +1 -1
- data/db/migrate/01_create_effective_cpd.rb.erb +2 -0
- data/lib/effective_cpd/version.rb +1 -1
- data/lib/tasks/effective_cpd_tasks.rake +23 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c0c18c1af80311c6e645ea9f7846924dd85a35e4ed11605f0791d1f9c7e73511
|
4
|
+
data.tar.gz: a216123cafd45efafcd9f85e53230799cb6a051006e7307dd7a629091cfa6082
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 62f18ca3ad8b0b07cd5a60aa1435e047f6ec9c80d03f361c23024753202cecb1720cf773af88b1232732ea1f5b2c814554ce0104ff39a818746e7ff6399113f8
|
7
|
+
data.tar.gz: 2347e808fc551c592bd09c902d5e73bf4c2f1accb2c2ad66a0fc4f6b4cdec0671ef316931d0072259e9d7a584ae5a9e1b2302a73c13616569f5f7f48d71d19d1
|
data/README.md
CHANGED
@@ -167,6 +167,14 @@ def cpd_statement_required_score(cpd_statement)
|
|
167
167
|
end
|
168
168
|
```
|
169
169
|
|
170
|
+
## Rake Tasks
|
171
|
+
|
172
|
+
You can use
|
173
|
+
|
174
|
+
`bundle exec rake effective_cpd:notify_auditees`
|
175
|
+
|
176
|
+
to send the cpd_audit_opened notification to all opened (but not yet started) auditees.
|
177
|
+
|
170
178
|
## Authorization
|
171
179
|
|
172
180
|
All authorization checks are handled via the effective_resources gem found in the `config/initializers/effective_resources.rb` file.
|
@@ -36,6 +36,10 @@ module EffectiveCpdAudit
|
|
36
36
|
[:opened, :started, :conflicted_resolved, :exemption_denied, :extension_granted, :extension_denied]
|
37
37
|
end
|
38
38
|
|
39
|
+
def chat_permissions
|
40
|
+
['Can send messages until closed', 'Always send messages', 'Never send messages']
|
41
|
+
end
|
42
|
+
|
39
43
|
end
|
40
44
|
|
41
45
|
included do
|
@@ -150,6 +154,9 @@ module EffectiveCpdAudit
|
|
150
154
|
reviewed_at :datetime, permitted: false
|
151
155
|
closed_at :datetime, permitted: false
|
152
156
|
|
157
|
+
# To control permission of sending messages
|
158
|
+
chat_permission :string, permitted: false
|
159
|
+
|
153
160
|
# Acts as tokyyened
|
154
161
|
token :string, permitted: false
|
155
162
|
|
@@ -181,6 +188,7 @@ module EffectiveCpdAudit
|
|
181
188
|
before_validation(if: -> { new_record? }) do
|
182
189
|
self.notification_date ||= Time.zone.now
|
183
190
|
self.due_date ||= deadline_to_submit()
|
191
|
+
self.chat_permission ||= self.class.chat_permissions.first
|
184
192
|
end
|
185
193
|
|
186
194
|
with_options(if: -> { cpd_audit_level&.anonymous? }) do
|
@@ -222,13 +230,17 @@ module EffectiveCpdAudit
|
|
222
230
|
end
|
223
231
|
end
|
224
232
|
|
233
|
+
validate(if: -> { chat_permission.present? }) do
|
234
|
+
unless self.class.chat_permissions.include?(chat_permission)
|
235
|
+
self.errors.add(:chat_permission, 'is invalid')
|
236
|
+
end
|
237
|
+
end
|
238
|
+
|
225
239
|
# If we're submitted. Check if we can go into reviewed?
|
226
240
|
before_save(if: -> { submitted? }) { try_complete! }
|
227
241
|
before_save(if: -> { completed? }) { try_review! }
|
228
242
|
|
229
|
-
after_commit(on: :create)
|
230
|
-
send_email(:cpd_audit_opened)
|
231
|
-
end
|
243
|
+
after_commit(on: :create) { notify! }
|
232
244
|
|
233
245
|
def dynamic_wizard_steps
|
234
246
|
cpd_audit_level.cpd_audit_level_sections.each_with_object({}) do |section, h|
|
@@ -289,6 +301,14 @@ module EffectiveCpdAudit
|
|
289
301
|
chat
|
290
302
|
end
|
291
303
|
|
304
|
+
def chat_url(chat:, user:, root_url:)
|
305
|
+
resource = if user.try(:cpd_audit_reviewer?)
|
306
|
+
cpd_audit_reviews.find { |review| review.user == user } || raise('expected to find existing reviewer')
|
307
|
+
end || self
|
308
|
+
|
309
|
+
[root_url.chomp('/'), resource.class.table_name, resource.to_param, 'chat'].join('/')
|
310
|
+
end
|
311
|
+
|
292
312
|
end
|
293
313
|
|
294
314
|
def to_s
|
@@ -323,6 +343,18 @@ module EffectiveCpdAudit
|
|
323
343
|
was_completed?
|
324
344
|
end
|
325
345
|
|
346
|
+
def chat_until_closed?
|
347
|
+
chat_permission == 'Can send messages until closed'
|
348
|
+
end
|
349
|
+
|
350
|
+
def chat_always?
|
351
|
+
chat_permission == 'Always send messages'
|
352
|
+
end
|
353
|
+
|
354
|
+
def chat_never?
|
355
|
+
chat_permission == 'Never send messages'
|
356
|
+
end
|
357
|
+
|
326
358
|
def status_label
|
327
359
|
(status_was || status).to_s.gsub('_', ' ')
|
328
360
|
end
|
@@ -379,6 +411,11 @@ module EffectiveCpdAudit
|
|
379
411
|
cpd_audit_response ||= cpd_audit_responses.build(cpd_audit: self, cpd_audit_level_question: cpd_audit_level_question)
|
380
412
|
end
|
381
413
|
|
414
|
+
def notify!
|
415
|
+
send_email(:cpd_audit_opened)
|
416
|
+
true
|
417
|
+
end
|
418
|
+
|
382
419
|
# Auditee wizard action
|
383
420
|
def start!
|
384
421
|
started!
|
@@ -1,3 +1,12 @@
|
|
1
|
+
= card('Chat Permission') do
|
2
|
+
= effective_form_with(model: [:admin, cpd_audit], engine: true) do |f|
|
3
|
+
%p By default, auditees and reviewers can send messages until the audit is closed.
|
4
|
+
|
5
|
+
.row
|
6
|
+
.col-sm-6
|
7
|
+
= f.select :chat_permission, cpd_audit.class.chat_permissions, label: false
|
8
|
+
= f.submit 'Save', center: true, border: false
|
9
|
+
|
1
10
|
- if cpd_audit.chat.present?
|
2
11
|
= render('effective/chats/chat', chat: cpd_audit.chat)
|
3
12
|
- else
|
@@ -40,6 +40,10 @@
|
|
40
40
|
%p You have completed these past statements:
|
41
41
|
= render_datatable(completed, simple: true)
|
42
42
|
|
43
|
+
- unless current_user.try(:cpd_audit_reviewer?)
|
44
|
+
- if auditing.blank? && audited.blank? && available.blank? && completed.blank?
|
45
|
+
%p There are no activities available right now. When there are, we'll show them here.
|
46
|
+
|
43
47
|
- if current_user.try(:cpd_audit_reviewer?)
|
44
48
|
- # Auditor / Audit reviewer datatables (2)
|
45
49
|
- reviewing = EffectiveCpdAvailableAuditReviewsDatatable.new(self)
|
@@ -1,6 +1,28 @@
|
|
1
|
-
# bundle exec rake effective_cpd:seed
|
2
1
|
namespace :effective_cpd do
|
2
|
+
|
3
|
+
# bundle exec rake effective_cpd:seed
|
3
4
|
task seed: :environment do
|
4
5
|
load "#{__dir__}/../../db/seeds.rb"
|
5
6
|
end
|
7
|
+
|
8
|
+
# bundle exec rake effective_cpd:notify_auditees
|
9
|
+
desc 'Send cpd_audit_opened email notifications for effective cpd'
|
10
|
+
task notify_auditees: :environment do
|
11
|
+
audits = EffectiveCpd.CpdAudit.opened.sorted
|
12
|
+
|
13
|
+
audits.find_each do |audit|
|
14
|
+
begin
|
15
|
+
audit.notify!
|
16
|
+
puts "Sent #{audit} notification to #{audit.user.email}"
|
17
|
+
rescue => e
|
18
|
+
if defined?(ExceptionNotifier)
|
19
|
+
ExceptionNotifier.notify_exception(e, data: { audit_id: audit.id })
|
20
|
+
end
|
21
|
+
|
22
|
+
puts "Error with audit #{auditee.id}: #{e.errors.inspect}"
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
puts 'All done'
|
27
|
+
end
|
6
28
|
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: 1.2.
|
4
|
+
version: 1.2.4
|
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: 2023-
|
11
|
+
date: 2023-02-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|