effective_polls 0.5.6 → 0.6.1

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: 2de40c717cb2296f4a0a7aed128811bd1991899d579c26e538f68c9ad70fee4a
4
- data.tar.gz: a2815292003805d8174c9e7ff7996b311162157b92b07fa164b7087dee9082d2
3
+ metadata.gz: 6f0bb62aded7cf4461b6ac474f751db47c9709b0079e39ebfced3aac50327beb
4
+ data.tar.gz: 43c9c7448edee9b0ec1d913187bd28f28c7ca9222494a13f34790ce66f36d40d
5
5
  SHA512:
6
- metadata.gz: 3601f0b8098f681b375e6982f594893c12d49ff7cec643ab6d7f286bcbf15a3dda38b808d76ac977a53a66207b83f07dce74a3b4d4f075d8f63389d424677794
7
- data.tar.gz: e69034e422902663ef2607bca59378aef46233b9df1486feb0566e50f6c80a9a810e98559d1b4044231fd53cfb78029a2c21afcede2867ad0c7224ba2ed0e080
6
+ metadata.gz: 911327063e49263e213ff7a35243a655e955eacbb9c37d432c9677ab2fc96e2b49066bef2514bd13351c8902691f086e4c00c2f33fed9890223fb3499889fc27
7
+ data.tar.gz: 8bb1b75e904a57867e0f0392be9e8f897c81a9b528f41cc7814f3f99feca0be06503ab0f5b8fd0ca8e2266a974c9722520e2c39b6c5a53cec14661e4750cff5c
@@ -21,6 +21,9 @@ class Admin::EffectivePollsDatatable < Effective::Datatable
21
21
  col :poll_notifications
22
22
  col :poll_questions, visible: false
23
23
 
24
+ col :hide_results, visible: false
25
+ col :skip_logging, visible: false
26
+
24
27
  actions_col
25
28
  end
26
29
 
@@ -11,7 +11,8 @@ module Effective
11
11
  to: user.email,
12
12
  from: poll_notification.from,
13
13
  body: poll_notification.body,
14
- subject: poll_notification.subject
14
+ subject: poll_notification.subject,
15
+ message_stream: 'broadcast-stream'
15
16
  )
16
17
  end
17
18
 
@@ -22,7 +23,8 @@ module Effective
22
23
  to: user.email,
23
24
  from: poll_notification.from,
24
25
  body: poll_notification.body,
25
- subject: poll_notification.subject
26
+ subject: poll_notification.subject,
27
+ message_stream: 'broadcast-stream'
26
28
  )
27
29
  end
28
30
 
@@ -33,7 +35,8 @@ module Effective
33
35
  to: user.email,
34
36
  from: poll_notification.from,
35
37
  body: poll_notification.body,
36
- subject: poll_notification.subject
38
+ subject: poll_notification.subject,
39
+ message_stream: 'broadcast-stream'
37
40
  )
38
41
  end
39
42
 
@@ -44,7 +47,8 @@ module Effective
44
47
  to: user.email,
45
48
  from: poll_notification.from,
46
49
  body: poll_notification.body,
47
- subject: poll_notification.subject
50
+ subject: poll_notification.subject,
51
+ message_stream: 'broadcast-stream'
48
52
  )
49
53
  end
50
54
 
@@ -55,7 +59,8 @@ module Effective
55
59
  to: user.email,
56
60
  from: poll_notification.from,
57
61
  body: poll_notification.body,
58
- subject: poll_notification.subject
62
+ subject: poll_notification.subject,
63
+ message_stream: 'broadcast-stream'
59
64
  )
60
65
  end
61
66
 
@@ -60,6 +60,12 @@ module Effective
60
60
  model_name.human
61
61
  end
62
62
 
63
+ # Disable effective_logging log_changes for this resource
64
+ def log_changes?
65
+ return false if poll&.skip_logging?
66
+ true
67
+ end
68
+
63
69
  # Find or build
64
70
  def ballot_response(poll_question)
65
71
  ballot_response = ballot_responses.find { |br| br.poll_question_id == poll_question.id }
@@ -37,6 +37,9 @@ module Effective
37
37
  start_at :datetime
38
38
  end_at :datetime
39
39
 
40
+ hide_results :boolean, default: false
41
+ skip_logging :boolean, default: false
42
+
40
43
  audience :string
41
44
  audience_class_name :string
42
45
  audience_scope :text # An Array of user_ids or named scopes on the User model
@@ -129,7 +129,9 @@ module Effective
129
129
  end
130
130
  end
131
131
 
132
- def notify!(force: false)
132
+ def notify!(force: false, except: [])
133
+ raise('expected an Array of user IDs') if except.present? && !except.kind_of?(Array)
134
+
133
135
  return false unless (notify_now? || force)
134
136
 
135
137
  # We send to all users, except for the 'Reminder' that exclude completed users
@@ -138,7 +140,17 @@ module Effective
138
140
  update_column(:started_at, Time.zone.now)
139
141
 
140
142
  users.find_each do |user|
141
- Effective::PollsMailer.public_send(email_template, self, user).deliver_now
143
+ print '.'
144
+
145
+ next if except.include?(user.id)
146
+
147
+ begin
148
+ Effective::PollsMailer.public_send(email_template, self, user).deliver_now
149
+ rescue => e
150
+ EffectiveLogger.error(e.message, associated: self) if defined?(EffectiveLogger)
151
+ ExceptionNotifier.notify_exception(e, data: { user_id: user.id }) if defined?(ExceptionNotifier)
152
+ end
153
+
142
154
  end
143
155
 
144
156
  update_column(:completed_at, Time.zone.now)
@@ -9,6 +9,14 @@
9
9
  .alert.alert-info
10
10
  Please be aware of the existing #{ets(f.object.poll_notifications)} when changing the start or end availability date.
11
11
 
12
+ = f.check_box :hide_results,
13
+ label: 'Hide results until the poll has ended',
14
+ hint: 'If checked, admin users will be unable to view the poll results until the poll has ended.'
15
+
16
+ = f.check_box :skip_logging,
17
+ label: 'Skip logging of ballots',
18
+ hint: 'If checked, no logs of who has submitted or completed ballots will be kept.'
19
+
12
20
  -# Audience
13
21
  - f.object.audience_class_name ||= current_user.class.name
14
22
 
@@ -1,5 +1,8 @@
1
1
  = render 'effective/poll_results/results', poll: @poll
2
2
 
3
3
  = card('Raw Data') do
4
- - datatable = Admin::EffectivePollResultsDatatable.new(poll: @poll)
5
- = render_datatable(datatable)
4
+ - if poll.hide_results? && !poll.ended?
5
+ %p The raw data for this poll will be displayed once it has ended.
6
+ - else
7
+ - datatable = Admin::EffectivePollResultsDatatable.new(poll: @poll)
8
+ = render_datatable(datatable)
@@ -20,23 +20,26 @@
20
20
  .card-body
21
21
  %h5.card-title Question Results
22
22
 
23
- .effective-ballot
24
- %table.table.table-hover
25
- %thead
26
- %tr
27
- %th Question
28
- %th Results
23
+ - if poll.hide_results? && !poll.ended?
24
+ %p The results of this poll will be displayed once it has ended.
25
+ - else
26
+ .effective-ballot
27
+ %table.table.table-hover
28
+ %thead
29
+ %tr
30
+ %th Question
31
+ %th Results
29
32
 
30
- %tbody
31
- - ballots = poll.ballots
33
+ %tbody
34
+ - ballots = poll.ballots
32
35
 
33
- - poll.poll_questions.each_with_index do |poll_question, index|
34
- - ballot_responses = poll.poll_results(poll_question: poll_question)
36
+ - poll.poll_questions.each_with_index do |poll_question, index|
37
+ - ballot_responses = poll.poll_results(poll_question: poll_question)
35
38
 
36
- %tr
37
- %td
38
- #{poll_question.position + 1}. #{poll_question}
39
- %br
40
- %small.text-muted= poll_question.category
39
+ %tr
40
+ %td
41
+ #{poll_question.position + 1}. #{poll_question}
42
+ %br
43
+ %small.text-muted= poll_question.category
41
44
 
42
- %td= render('effective/poll_results/poll_result', poll_question: poll_question, ballot_responses: ballot_responses)
45
+ %td= render('effective/poll_results/poll_result', poll_question: poll_question, ballot_responses: ballot_responses)
@@ -12,6 +12,9 @@ class CreateEffectivePolls < ActiveRecord::Migration[6.0]
12
12
  t.string :audience_class_name
13
13
  t.text :audience_scope
14
14
 
15
+ t.boolean :hide_results, default: false
16
+ t.boolean :skip_logging, default: false
17
+
15
18
  t.datetime :updated_at
16
19
  t.datetime :created_at
17
20
  end
@@ -1,3 +1,3 @@
1
1
  module EffectivePolls
2
- VERSION = '0.5.6'
2
+ VERSION = '0.6.1'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: effective_polls
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.6
4
+ version: 0.6.1
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: 2024-01-26 00:00:00.000000000 Z
11
+ date: 2024-02-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails