effective_polls 0.0.2 → 0.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.
- checksums.yaml +4 -4
- data/README.md +1 -7
- data/app/datatables/admin/effective_polls_datatable.rb +2 -2
- data/app/mailers/effective/polls_mailer.rb +58 -10
- data/app/models/effective/poll.rb +5 -18
- data/app/models/effective/poll_notification.rb +17 -18
- data/app/views/admin/poll_notifications/_form.html.haml +24 -37
- data/app/views/admin/poll_notifications/_form_poll_reminder.html.haml +8 -0
- data/app/views/admin/poll_notifications/_form_poll_upcoming_reminder.html.haml +8 -0
- data/app/views/admin/poll_notifications/_form_poll_when_poll_ends.html.haml +3 -0
- data/app/views/admin/poll_notifications/_form_poll_when_poll_starts.html.haml +3 -0
- data/app/views/admin/polls/_form.html.haml +1 -1
- data/app/views/admin/polls/_form_poll.html.haml +2 -5
- data/app/views/effective/ballot_responses/fields/_date.html.haml +2 -1
- data/app/views/effective/ballot_responses/fields/_email.html.haml +2 -1
- data/app/views/effective/ballot_responses/fields/_number.html.haml +2 -1
- data/app/views/effective/ballots/_ballot.html.haml +2 -2
- data/app/views/effective/ballots/start.html.haml +1 -1
- data/app/views/effective/ballots/submit.html.haml +1 -1
- data/app/views/effective/ballots/vote.html.haml +1 -1
- data/app/views/effective/poll_results/_results.html.haml +1 -1
- data/app/views/effective/polls_mailer/poll_reminder.liquid +13 -0
- data/app/views/effective/polls_mailer/poll_upcoming_reminder.liquid +11 -0
- data/app/views/effective/polls_mailer/poll_when_poll_ends.liquid +9 -0
- data/app/views/effective/polls_mailer/poll_when_poll_starts.liquid +13 -0
- data/config/effective_polls.rb +5 -0
- data/db/migrate/01_create_effective_polls.rb.erb +1 -0
- data/lib/effective_polls.rb +8 -3
- data/lib/effective_polls/version.rb +1 -1
- data/lib/tasks/effective_polls_tasks.rake +5 -6
- metadata +10 -75
- data/app/views/admin/polls/_poll.html.haml +0 -2
- data/app/views/effective/polls/_form.html.haml +0 -10
- data/app/views/effective/polls/_poll.html.haml +0 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 6a33a47c986c2f82da08218e53437b46481c94bfe71e725857e718be7bdccb1e
|
|
4
|
+
data.tar.gz: 48ca1df31f1cda3895a080e80b2b055b1adffca83bbb203868ee5d5b90d28d89
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 4cd220d1b2967235d42c9dbfd25b8ba4fb004e1f65e71eb4351e4cb483ca7f7f3f11972868a4a33d783f5b0243e42a02e3c90881f1f2d8b769d3daa1a8ce8cdb
|
|
7
|
+
data.tar.gz: 12a61a54e03a10160cfd379934441406c39f360b8c76e88073778e9f695850fa86e4102e2fa13fc948e6970c5e63671e3f151203f96d10d3e30c582be37261d4
|
data/README.md
CHANGED
|
@@ -75,14 +75,8 @@ if user.admin?
|
|
|
75
75
|
|
|
76
76
|
can :manage, Effective::Poll
|
|
77
77
|
can :manage, Effective::PollNotification
|
|
78
|
-
|
|
79
|
-
can :index, Effective::PollQuestion
|
|
78
|
+
can :manage, Effective::PollQuestion
|
|
80
79
|
can :index, Admin::EffectivePollResultsDatatable
|
|
81
|
-
|
|
82
|
-
can([:new, :create, :edit, :update, :destroy], Effective::PollQuestion) do |pq|
|
|
83
|
-
pq.poll.present? && !pq.poll.started?
|
|
84
|
-
end
|
|
85
|
-
|
|
86
80
|
end
|
|
87
81
|
```
|
|
88
82
|
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
class Admin::EffectivePollsDatatable < Effective::Datatable
|
|
2
2
|
filters do
|
|
3
|
+
scope :all
|
|
3
4
|
scope :upcoming
|
|
4
5
|
scope :available
|
|
5
6
|
scope :completed
|
|
6
|
-
scope :all
|
|
7
7
|
end
|
|
8
8
|
|
|
9
9
|
datatable do
|
|
10
10
|
order :start_at, :desc
|
|
11
11
|
|
|
12
|
-
col :
|
|
12
|
+
col :token, visible: false
|
|
13
13
|
col :created_at, visible: false
|
|
14
14
|
col :updated_at, visible: false
|
|
15
15
|
|
|
@@ -1,22 +1,70 @@
|
|
|
1
1
|
module Effective
|
|
2
|
-
class PollsMailer <
|
|
3
|
-
default from: EffectivePolls.mailer[:default_from]
|
|
2
|
+
class PollsMailer < EffectivePolls.mailer_class
|
|
4
3
|
layout EffectivePolls.mailer[:layout].presence || 'effective_polls_mailer_layout'
|
|
5
4
|
|
|
6
|
-
def poll_upcoming_reminder(poll_notification,
|
|
7
|
-
|
|
5
|
+
def poll_upcoming_reminder(poll_notification, user)
|
|
6
|
+
@assigns = effective_email_templates_assigns(poll_notification, user)
|
|
7
|
+
|
|
8
|
+
mail(
|
|
9
|
+
to: user.email,
|
|
10
|
+
from: poll_notification.from,
|
|
11
|
+
body: poll_notification.body,
|
|
12
|
+
subject: poll_notification.subject
|
|
13
|
+
)
|
|
8
14
|
end
|
|
9
15
|
|
|
10
|
-
def
|
|
11
|
-
|
|
16
|
+
def poll_when_poll_starts(poll_notification, user)
|
|
17
|
+
@assigns = effective_email_templates_assigns(poll_notification, user)
|
|
18
|
+
|
|
19
|
+
mail(
|
|
20
|
+
to: user.email,
|
|
21
|
+
from: poll_notification.from,
|
|
22
|
+
body: poll_notification.body,
|
|
23
|
+
subject: poll_notification.subject
|
|
24
|
+
)
|
|
12
25
|
end
|
|
13
26
|
|
|
14
|
-
def poll_reminder(poll_notification,
|
|
15
|
-
|
|
27
|
+
def poll_reminder(poll_notification, user)
|
|
28
|
+
@assigns = effective_email_templates_assigns(poll_notification, user)
|
|
29
|
+
|
|
30
|
+
mail(
|
|
31
|
+
to: user.email,
|
|
32
|
+
from: poll_notification.from,
|
|
33
|
+
body: poll_notification.body,
|
|
34
|
+
subject: poll_notification.subject
|
|
35
|
+
)
|
|
16
36
|
end
|
|
17
37
|
|
|
18
|
-
def
|
|
19
|
-
|
|
38
|
+
def poll_when_poll_ends(poll_notification, user)
|
|
39
|
+
@assigns = effective_email_templates_assigns(poll_notification, user)
|
|
40
|
+
|
|
41
|
+
mail(
|
|
42
|
+
to: user.email,
|
|
43
|
+
from: poll_notification.from,
|
|
44
|
+
body: poll_notification.body,
|
|
45
|
+
subject: poll_notification.subject
|
|
46
|
+
)
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
private
|
|
50
|
+
|
|
51
|
+
# Only relevant if the effective_email_templates gem is present
|
|
52
|
+
def effective_email_templates_assigns(poll_notification, user)
|
|
53
|
+
raise('expected an Effective::PollNotification') unless poll_notification.kind_of?(Effective::PollNotification)
|
|
54
|
+
raise('expected a User') unless user.kind_of?(User)
|
|
55
|
+
|
|
56
|
+
poll = poll_notification.poll
|
|
57
|
+
raise('expected poll to be persisted') unless poll&.persisted?
|
|
58
|
+
|
|
59
|
+
{
|
|
60
|
+
available_date: poll.available_date,
|
|
61
|
+
title: poll.title,
|
|
62
|
+
url: effective_polls.new_poll_ballot_url(poll),
|
|
63
|
+
user: {
|
|
64
|
+
name: user.to_s,
|
|
65
|
+
email: user.email
|
|
66
|
+
}
|
|
67
|
+
}
|
|
20
68
|
end
|
|
21
69
|
|
|
22
70
|
end
|
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
module Effective
|
|
2
2
|
class Poll < ActiveRecord::Base
|
|
3
|
-
attr_accessor :skip_started_validation
|
|
4
|
-
|
|
5
3
|
has_rich_text :all_steps_content
|
|
6
4
|
has_rich_text :start_content
|
|
7
5
|
has_rich_text :vote_content
|
|
@@ -61,7 +59,6 @@ module Effective
|
|
|
61
59
|
}
|
|
62
60
|
|
|
63
61
|
scope :sorted, -> { order(:start_at) }
|
|
64
|
-
scope :editable, -> { upcoming }
|
|
65
62
|
|
|
66
63
|
scope :upcoming, -> { where('start_at > ?', Time.zone.now) }
|
|
67
64
|
scope :available, -> { where('start_at <= ? AND (end_at > ? OR end_at IS NULL)', Time.zone.now, Time.zone.now) }
|
|
@@ -73,14 +70,6 @@ module Effective
|
|
|
73
70
|
validates :audience, inclusion: { in: AUDIENCES }
|
|
74
71
|
validates :audience_scope, presence: true, unless: -> { audience == 'All Users' }
|
|
75
72
|
|
|
76
|
-
validate(if: -> { started? }, unless: -> { skip_started_validation }) do
|
|
77
|
-
self.errors.add(:base, 'has already started. a poll cannot be changed after it has started.')
|
|
78
|
-
end
|
|
79
|
-
|
|
80
|
-
validate(if: -> { start_at.present? && !started? }, unless: -> { skip_started_validation }) do
|
|
81
|
-
self.errors.add(:start_at, 'must be a future date') if start_at < Time.zone.now
|
|
82
|
-
end
|
|
83
|
-
|
|
84
73
|
validate(if: -> { start_at.present? && end_at.present? }) do
|
|
85
74
|
self.errors.add(:end_at, 'must be after the start date') unless end_at > start_at
|
|
86
75
|
end
|
|
@@ -94,8 +83,8 @@ module Effective
|
|
|
94
83
|
available? && users.include?(user)
|
|
95
84
|
end
|
|
96
85
|
|
|
97
|
-
def users
|
|
98
|
-
case audience
|
|
86
|
+
def users(except_completed: false)
|
|
87
|
+
users = case audience
|
|
99
88
|
when 'All Users'
|
|
100
89
|
User.all
|
|
101
90
|
when 'Individual Users'
|
|
@@ -107,13 +96,11 @@ module Effective
|
|
|
107
96
|
else
|
|
108
97
|
raise('unexpected audience')
|
|
109
98
|
end
|
|
110
|
-
end
|
|
111
99
|
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
users.where.not(id: completed_ballots.select('user_id as id')).pluck(:email)
|
|
100
|
+
if except_completed
|
|
101
|
+
users.where.not(id: completed_ballots.select('user_id as id'))
|
|
115
102
|
else
|
|
116
|
-
users
|
|
103
|
+
users
|
|
117
104
|
end
|
|
118
105
|
end
|
|
119
106
|
|
|
@@ -3,8 +3,8 @@ module Effective
|
|
|
3
3
|
belongs_to :poll
|
|
4
4
|
log_changes(to: :poll) if respond_to?(:log_changes)
|
|
5
5
|
|
|
6
|
-
BATCHSIZE = (Rails.env.test? ? 3 : 250)
|
|
7
6
|
CATEGORIES = ['Upcoming reminder', 'When poll starts', 'Reminder', 'When poll ends']
|
|
7
|
+
EMAIL_TEMPLATE_VARIABLES = ['available_date', 'title', 'url', 'user.name', 'user.email']
|
|
8
8
|
|
|
9
9
|
UPCOMING_REMINDERS = {
|
|
10
10
|
'1 hour before' => 1.hours.to_i,
|
|
@@ -45,6 +45,7 @@ module Effective
|
|
|
45
45
|
reminder :integer # Number of seconds before poll.start_at
|
|
46
46
|
|
|
47
47
|
# Email
|
|
48
|
+
from :string
|
|
48
49
|
subject :string
|
|
49
50
|
body :text
|
|
50
51
|
|
|
@@ -66,9 +67,16 @@ module Effective
|
|
|
66
67
|
|
|
67
68
|
validates :poll, presence: true
|
|
68
69
|
validates :category, presence: true, inclusion: { in: CATEGORIES }
|
|
70
|
+
|
|
71
|
+
validates :from, presence: true
|
|
69
72
|
validates :subject, presence: true
|
|
70
73
|
validates :body, presence: true
|
|
71
74
|
|
|
75
|
+
if EffectivePolls.use_effective_email_templates
|
|
76
|
+
validates :body, liquid: true
|
|
77
|
+
validates :subject, liquid: true
|
|
78
|
+
end
|
|
79
|
+
|
|
72
80
|
validates :reminder, if: -> { reminder? || upcoming_reminder? },
|
|
73
81
|
presence: true, uniqueness: { scope: [:poll_id, :category], message: 'already exists' }
|
|
74
82
|
|
|
@@ -76,6 +84,10 @@ module Effective
|
|
|
76
84
|
'poll notification'
|
|
77
85
|
end
|
|
78
86
|
|
|
87
|
+
def email_template
|
|
88
|
+
'poll_' + category.to_s.parameterize.underscore
|
|
89
|
+
end
|
|
90
|
+
|
|
79
91
|
def upcoming_reminder?
|
|
80
92
|
category == 'Upcoming reminder'
|
|
81
93
|
end
|
|
@@ -116,26 +128,13 @@ module Effective
|
|
|
116
128
|
def notify!
|
|
117
129
|
return false unless notify_now?
|
|
118
130
|
|
|
119
|
-
# We send to all
|
|
120
|
-
|
|
131
|
+
# We send to all users, except for the 'Reminder' that exclude completed users
|
|
132
|
+
users = poll.users(except_completed: (category == 'Reminder'))
|
|
121
133
|
|
|
122
134
|
update_column(:started_at, Time.zone.now)
|
|
123
135
|
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
when 'When poll starts'
|
|
127
|
-
Effective::PollsMailer.poll_start(self, emails)
|
|
128
|
-
when 'When poll ends'
|
|
129
|
-
Effective::PollsMailer.poll_end(self, emails)
|
|
130
|
-
when 'Upcoming reminder'
|
|
131
|
-
Effective::PollsMailer.poll_upcoming_reminder(self, emails)
|
|
132
|
-
when 'Reminder'
|
|
133
|
-
Effective::PollsMailer.poll_reminder(self, emails)
|
|
134
|
-
else
|
|
135
|
-
raise('unexpected category')
|
|
136
|
-
end
|
|
137
|
-
|
|
138
|
-
mail.deliver_now
|
|
136
|
+
users.find_each do |user|
|
|
137
|
+
Effective::PollsMailer.public_send(email_template, self, user).deliver_now
|
|
139
138
|
end
|
|
140
139
|
|
|
141
140
|
update_column(:completed_at, Time.zone.now)
|
|
@@ -2,54 +2,41 @@
|
|
|
2
2
|
- if inline_datatable?
|
|
3
3
|
= f.hidden_field :poll_id
|
|
4
4
|
- else
|
|
5
|
-
= f.select :poll_id, Effective::Poll.sorted.
|
|
5
|
+
= f.select :poll_id, Effective::Poll.sorted.all
|
|
6
6
|
|
|
7
7
|
= f.select :category, Effective::PollNotification::CATEGORIES,
|
|
8
8
|
label: 'Send an email notification'
|
|
9
9
|
|
|
10
|
-
|
|
10
|
+
- # Render email templates
|
|
11
|
+
- Effective::PollNotification::CATEGORIES.each do |category|
|
|
12
|
+
- template = 'poll_' + category.parameterize.underscore
|
|
11
13
|
|
|
12
|
-
= f.
|
|
13
|
-
|
|
14
|
+
= f.show_if :category, category do
|
|
15
|
+
= render "/admin/poll_notifications/form_#{template}", f: f
|
|
14
16
|
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
Use upcoming reminders to advertise, prepare, or communicate to your audience before the poll begins.
|
|
17
|
+
- if f.object.category == category
|
|
18
|
+
= f.email_field :from
|
|
19
|
+
= f.text_field :subject
|
|
20
|
+
= f.text_area :body, rows: 10
|
|
20
21
|
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
22
|
+
- elsif EffectivePolls.use_effective_email_templates == false
|
|
23
|
+
= f.email_field :from, value: EffectivePolls.mailer[:default_from]
|
|
24
|
+
= f.text_field :subject, value: ''
|
|
25
|
+
= f.text_area :body, rows: 10, value: ''
|
|
25
26
|
|
|
26
|
-
|
|
27
|
+
- else
|
|
28
|
+
- email_template = Effective::EmailTemplate.where(template_name: template).first!
|
|
27
29
|
|
|
28
|
-
|
|
29
|
-
|
|
30
|
+
= f.email_field :from, value: email_template.from
|
|
31
|
+
= f.text_field :subject, value: email_template.subject
|
|
32
|
+
= f.text_area :body, rows: 10, value: email_template.body
|
|
30
33
|
|
|
31
|
-
|
|
32
|
-
%strong Reminders
|
|
33
|
-
are sent to users in the audience who have not yet completed their ballot.
|
|
34
|
-
%br
|
|
35
|
-
Use reminders to boost your audience participation and remind people to vote.
|
|
34
|
+
%p The available variables are:
|
|
36
35
|
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
notifications will be sent within 10 minutes of the poll end time.
|
|
36
|
+
%ul
|
|
37
|
+
- Effective::PollNotification::EMAIL_TEMPLATE_VARIABLES.each do |variable|
|
|
38
|
+
%li {{ #{variable} }}
|
|
41
39
|
|
|
42
|
-
|
|
43
|
-
= f.text_area :body, label: 'Email Body'
|
|
44
|
-
|
|
45
|
-
.alert.alert-warning
|
|
46
|
-
Email content must not contain any personal details.
|
|
47
|
-
%br
|
|
48
|
-
This content will be sent in a mass email with hundreds of bcc'd recipients.
|
|
49
|
-
|
|
50
|
-
- if poll_notification.poll.present?
|
|
51
|
-
%br
|
|
52
|
-
The url for this poll will be:
|
|
53
|
-
= effective_polls.poll_url(poll_notification.poll)
|
|
40
|
+
%small.text-muted Only a developer can add additional variables
|
|
54
41
|
|
|
55
42
|
= effective_submit(f)
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
= f.select :reminder, Effective::PollNotification::REMINDERS, label: false,
|
|
2
|
+
hint: "after the poll starts on #{f.object.poll&.start_at&.strftime('%F')}."
|
|
3
|
+
|
|
4
|
+
.alert.alert-warning
|
|
5
|
+
%strong Reminders
|
|
6
|
+
are sent to users in the audience who have not yet completed their ballot.
|
|
7
|
+
%br
|
|
8
|
+
Use reminders to boost your audience participation and remind people to vote.
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
= f.select :reminder, Effective::PollNotification::UPCOMING_REMINDERS, label: false,
|
|
2
|
+
hint: "before the poll starts on #{f.object.poll&.start_at&.strftime('%F')}."
|
|
3
|
+
|
|
4
|
+
.alert.alert-warning
|
|
5
|
+
%strong Upcoming Reminders
|
|
6
|
+
are sent to the entire audience before the poll starts.
|
|
7
|
+
%br
|
|
8
|
+
Use upcoming reminders to advertise, prepare, or communicate to your audience before the poll begins.
|
|
@@ -1,12 +1,9 @@
|
|
|
1
1
|
= effective_form_with(model: [:admin, poll], engine: true) do |f|
|
|
2
|
-
= f.text_field :title, hint: 'The title of your poll.'
|
|
2
|
+
= f.text_field :title, hint: 'The title of your poll or election.'
|
|
3
3
|
|
|
4
|
-
= f.datetime_field :start_at, input_js: { minDate:
|
|
4
|
+
= f.datetime_field :start_at, input_js: { minDate: Time.zone.now.beginning_of_day.strftime('%F') }
|
|
5
5
|
= f.datetime_field :end_at
|
|
6
6
|
|
|
7
|
-
.alert.alert-warning
|
|
8
|
-
Once the start date has passed, this poll will become read only and you will be unable to make changes.
|
|
9
|
-
|
|
10
7
|
-# Audience
|
|
11
8
|
= f.radios :audience, Effective::Poll::AUDIENCES
|
|
12
9
|
|
|
@@ -1 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
.row
|
|
2
|
+
.col-sm-6= f.date_field :date, label: false, required: poll_question.required?
|
|
@@ -1 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
.row
|
|
2
|
+
.col-sm-6= f.email_field :email, label: false, required: poll_question.required?
|
|
@@ -1 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
.row
|
|
2
|
+
.col-sm-6= f.number_field :number, label: false, required: poll_question.required?
|
data/config/effective_polls.rb
CHANGED
|
@@ -56,4 +56,9 @@ EffectivePolls.setup do |config|
|
|
|
56
56
|
default_from: 'no-reply@example.com'
|
|
57
57
|
}
|
|
58
58
|
|
|
59
|
+
# Will work with effective_email_templates gem:
|
|
60
|
+
# - The poll notifications email content will be preopulated based off the template
|
|
61
|
+
# - Uses a EmailTemplatesMailer mailer instead of ActionMailer::Base
|
|
62
|
+
config.use_effective_email_templates = false
|
|
63
|
+
|
|
59
64
|
end
|
data/lib/effective_polls.rb
CHANGED
|
@@ -13,13 +13,13 @@ module EffectivePolls
|
|
|
13
13
|
mattr_accessor :ballot_response_options_table_name
|
|
14
14
|
|
|
15
15
|
mattr_accessor :authorization_method
|
|
16
|
-
mattr_accessor :permitted_params
|
|
17
16
|
|
|
18
17
|
mattr_accessor :layout
|
|
19
18
|
|
|
20
19
|
mattr_accessor :audience_user_scopes
|
|
21
20
|
|
|
22
21
|
# Hashes of configs
|
|
22
|
+
mattr_accessor :use_effective_email_templates
|
|
23
23
|
mattr_accessor :mailer
|
|
24
24
|
|
|
25
25
|
def self.setup
|
|
@@ -43,8 +43,13 @@ module EffectivePolls
|
|
|
43
43
|
raise Effective::AccessDenied.new('Access Denied', action, resource) unless authorized?(controller, action, resource)
|
|
44
44
|
end
|
|
45
45
|
|
|
46
|
-
def self.
|
|
47
|
-
|
|
46
|
+
def self.mailer_class
|
|
47
|
+
if use_effective_email_templates
|
|
48
|
+
require 'effective_email_templates'
|
|
49
|
+
Effective::EmailTemplatesMailer
|
|
50
|
+
else
|
|
51
|
+
ActionMailer::Base
|
|
52
|
+
end
|
|
48
53
|
end
|
|
49
54
|
|
|
50
55
|
end
|
|
@@ -5,17 +5,16 @@ namespace :effective_polls do
|
|
|
5
5
|
task notify: :environment do
|
|
6
6
|
poll_notifications = Effective::PollNotification.all.deep.notifiable
|
|
7
7
|
|
|
8
|
-
poll_notifications.find_each do |
|
|
8
|
+
poll_notifications.find_each do |notification|
|
|
9
9
|
begin
|
|
10
|
-
notified =
|
|
11
|
-
puts "Sent #{
|
|
10
|
+
notified = notification.notify!
|
|
11
|
+
puts "Sent #{notification.category} for #{notification.poll}" if notified
|
|
12
12
|
rescue => e
|
|
13
13
|
if defined?(ExceptionNotifier)
|
|
14
|
-
data
|
|
15
|
-
ExceptionNotifier.notify_exception(e, data: data)
|
|
14
|
+
ExceptionNotifier.notify_exception(e, data: { poll_notification_id: notification.id, poll_id: notification.poll_id })
|
|
16
15
|
end
|
|
17
16
|
|
|
18
|
-
puts "Error with effective poll_notification #{
|
|
17
|
+
puts "Error with effective poll_notification #{notification.id}: #{e.errors.inspect}"
|
|
19
18
|
end
|
|
20
19
|
end
|
|
21
20
|
|
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.0
|
|
4
|
+
version: 0.1.0
|
|
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-01-
|
|
11
|
+
date: 2021-01-29 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: rails
|
|
@@ -80,76 +80,6 @@ dependencies:
|
|
|
80
80
|
- - ">="
|
|
81
81
|
- !ruby/object:Gem::Version
|
|
82
82
|
version: '0'
|
|
83
|
-
- !ruby/object:Gem::Dependency
|
|
84
|
-
name: sqlite3
|
|
85
|
-
requirement: !ruby/object:Gem::Requirement
|
|
86
|
-
requirements:
|
|
87
|
-
- - ">="
|
|
88
|
-
- !ruby/object:Gem::Version
|
|
89
|
-
version: '0'
|
|
90
|
-
type: :development
|
|
91
|
-
prerelease: false
|
|
92
|
-
version_requirements: !ruby/object:Gem::Requirement
|
|
93
|
-
requirements:
|
|
94
|
-
- - ">="
|
|
95
|
-
- !ruby/object:Gem::Version
|
|
96
|
-
version: '0'
|
|
97
|
-
- !ruby/object:Gem::Dependency
|
|
98
|
-
name: devise
|
|
99
|
-
requirement: !ruby/object:Gem::Requirement
|
|
100
|
-
requirements:
|
|
101
|
-
- - ">="
|
|
102
|
-
- !ruby/object:Gem::Version
|
|
103
|
-
version: '0'
|
|
104
|
-
type: :development
|
|
105
|
-
prerelease: false
|
|
106
|
-
version_requirements: !ruby/object:Gem::Requirement
|
|
107
|
-
requirements:
|
|
108
|
-
- - ">="
|
|
109
|
-
- !ruby/object:Gem::Version
|
|
110
|
-
version: '0'
|
|
111
|
-
- !ruby/object:Gem::Dependency
|
|
112
|
-
name: haml-rails
|
|
113
|
-
requirement: !ruby/object:Gem::Requirement
|
|
114
|
-
requirements:
|
|
115
|
-
- - ">="
|
|
116
|
-
- !ruby/object:Gem::Version
|
|
117
|
-
version: '0'
|
|
118
|
-
type: :development
|
|
119
|
-
prerelease: false
|
|
120
|
-
version_requirements: !ruby/object:Gem::Requirement
|
|
121
|
-
requirements:
|
|
122
|
-
- - ">="
|
|
123
|
-
- !ruby/object:Gem::Version
|
|
124
|
-
version: '0'
|
|
125
|
-
- !ruby/object:Gem::Dependency
|
|
126
|
-
name: wicked
|
|
127
|
-
requirement: !ruby/object:Gem::Requirement
|
|
128
|
-
requirements:
|
|
129
|
-
- - ">="
|
|
130
|
-
- !ruby/object:Gem::Version
|
|
131
|
-
version: '0'
|
|
132
|
-
type: :development
|
|
133
|
-
prerelease: false
|
|
134
|
-
version_requirements: !ruby/object:Gem::Requirement
|
|
135
|
-
requirements:
|
|
136
|
-
- - ">="
|
|
137
|
-
- !ruby/object:Gem::Version
|
|
138
|
-
version: '0'
|
|
139
|
-
- !ruby/object:Gem::Dependency
|
|
140
|
-
name: pry-byebug
|
|
141
|
-
requirement: !ruby/object:Gem::Requirement
|
|
142
|
-
requirements:
|
|
143
|
-
- - ">="
|
|
144
|
-
- !ruby/object:Gem::Version
|
|
145
|
-
version: '0'
|
|
146
|
-
type: :development
|
|
147
|
-
prerelease: false
|
|
148
|
-
version_requirements: !ruby/object:Gem::Requirement
|
|
149
|
-
requirements:
|
|
150
|
-
- - ">="
|
|
151
|
-
- !ruby/object:Gem::Version
|
|
152
|
-
version: '0'
|
|
153
83
|
description: Online polls and user voting.
|
|
154
84
|
email:
|
|
155
85
|
- info@codeandeffect.com
|
|
@@ -183,11 +113,14 @@ files:
|
|
|
183
113
|
- app/models/effective/poll_question.rb
|
|
184
114
|
- app/models/effective/poll_question_option.rb
|
|
185
115
|
- app/views/admin/poll_notifications/_form.html.haml
|
|
116
|
+
- app/views/admin/poll_notifications/_form_poll_reminder.html.haml
|
|
117
|
+
- app/views/admin/poll_notifications/_form_poll_upcoming_reminder.html.haml
|
|
118
|
+
- app/views/admin/poll_notifications/_form_poll_when_poll_ends.html.haml
|
|
119
|
+
- app/views/admin/poll_notifications/_form_poll_when_poll_starts.html.haml
|
|
186
120
|
- app/views/admin/poll_questions/_form.html.haml
|
|
187
121
|
- app/views/admin/polls/_form.html.haml
|
|
188
122
|
- app/views/admin/polls/_form_content.html.haml
|
|
189
123
|
- app/views/admin/polls/_form_poll.html.haml
|
|
190
|
-
- app/views/admin/polls/_poll.html.haml
|
|
191
124
|
- app/views/admin/polls/results.html.haml
|
|
192
125
|
- app/views/effective/ballot_responses/_ballot_response.html.haml
|
|
193
126
|
- app/views/effective/ballot_responses/_fields.html.haml
|
|
@@ -238,8 +171,10 @@ files:
|
|
|
238
171
|
- app/views/effective/poll_results/results/_select_upto_5.html.haml
|
|
239
172
|
- app/views/effective/poll_results/results/_short_answer.html.haml
|
|
240
173
|
- app/views/effective/poll_results/results/_upload_file.html.haml
|
|
241
|
-
- app/views/effective/
|
|
242
|
-
- app/views/effective/
|
|
174
|
+
- app/views/effective/polls_mailer/poll_reminder.liquid
|
|
175
|
+
- app/views/effective/polls_mailer/poll_upcoming_reminder.liquid
|
|
176
|
+
- app/views/effective/polls_mailer/poll_when_poll_ends.liquid
|
|
177
|
+
- app/views/effective/polls_mailer/poll_when_poll_starts.liquid
|
|
243
178
|
- app/views/layouts/effective_polls_mailer_layout.html.haml
|
|
244
179
|
- config/effective_polls.rb
|
|
245
180
|
- config/routes.rb
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
= effective_form_with(model: poll, engine: true) do |f|
|
|
2
|
-
= f.text_field :title, hint: 'The title of your poll.'
|
|
3
|
-
= f.text_area :body
|
|
4
|
-
|
|
5
|
-
= f.datetime_field :start_at
|
|
6
|
-
= f.datetime_field :end_at
|
|
7
|
-
|
|
8
|
-
= f.check_box :draft, hint: 'Save this poll as a draft. It will not be accessible on the website.'
|
|
9
|
-
|
|
10
|
-
= effective_submit(f)
|