effective_polls 0.0.2 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (34) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +1 -7
  3. data/app/datatables/admin/effective_polls_datatable.rb +2 -2
  4. data/app/mailers/effective/polls_mailer.rb +58 -10
  5. data/app/models/effective/poll.rb +5 -18
  6. data/app/models/effective/poll_notification.rb +17 -18
  7. data/app/views/admin/poll_notifications/_form.html.haml +24 -37
  8. data/app/views/admin/poll_notifications/_form_poll_reminder.html.haml +8 -0
  9. data/app/views/admin/poll_notifications/_form_poll_upcoming_reminder.html.haml +8 -0
  10. data/app/views/admin/poll_notifications/_form_poll_when_poll_ends.html.haml +3 -0
  11. data/app/views/admin/poll_notifications/_form_poll_when_poll_starts.html.haml +3 -0
  12. data/app/views/admin/polls/_form.html.haml +1 -1
  13. data/app/views/admin/polls/_form_poll.html.haml +2 -5
  14. data/app/views/effective/ballot_responses/fields/_date.html.haml +2 -1
  15. data/app/views/effective/ballot_responses/fields/_email.html.haml +2 -1
  16. data/app/views/effective/ballot_responses/fields/_number.html.haml +2 -1
  17. data/app/views/effective/ballots/_ballot.html.haml +2 -2
  18. data/app/views/effective/ballots/start.html.haml +1 -1
  19. data/app/views/effective/ballots/submit.html.haml +1 -1
  20. data/app/views/effective/ballots/vote.html.haml +1 -1
  21. data/app/views/effective/poll_results/_results.html.haml +1 -1
  22. data/app/views/effective/polls_mailer/poll_reminder.liquid +13 -0
  23. data/app/views/effective/polls_mailer/poll_upcoming_reminder.liquid +11 -0
  24. data/app/views/effective/polls_mailer/poll_when_poll_ends.liquid +9 -0
  25. data/app/views/effective/polls_mailer/poll_when_poll_starts.liquid +13 -0
  26. data/config/effective_polls.rb +5 -0
  27. data/db/migrate/01_create_effective_polls.rb.erb +1 -0
  28. data/lib/effective_polls.rb +8 -3
  29. data/lib/effective_polls/version.rb +1 -1
  30. data/lib/tasks/effective_polls_tasks.rake +5 -6
  31. metadata +10 -75
  32. data/app/views/admin/polls/_poll.html.haml +0 -2
  33. data/app/views/effective/polls/_form.html.haml +0 -10
  34. 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: 68d305ba395a3d2414ebca82cd907b4e15831390d406bc963f491ebb982c76d3
4
- data.tar.gz: 46418fe6dc4c690c64e29800ce3cc3710ece9375e057f2fbdf2f47521b637bde
3
+ metadata.gz: 6a33a47c986c2f82da08218e53437b46481c94bfe71e725857e718be7bdccb1e
4
+ data.tar.gz: 48ca1df31f1cda3895a080e80b2b055b1adffca83bbb203868ee5d5b90d28d89
5
5
  SHA512:
6
- metadata.gz: '0379c829ce46c31baa169a070c7023d2ae4f013770667725d14f9a309b1a940cf474afef85e1717de3ffad9cdbe114e1ed676895013ff865eee3afe4aeed8d58'
7
- data.tar.gz: 8ff57a27c6baae02974c31c43d2067759b895f1f90fdf258c573b606acb6fa5ee26871f52b6ffda86713b63bc96785d1138e74d776c6f595b5264e64e649ae5c
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 :id, visible: false
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 < ActionMailer::Base
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, bcc)
7
- mail(bcc: bcc, body: poll_notification.body, subject: poll_notification.subject)
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 poll_start(poll_notification, bcc)
11
- mail(bcc: bcc, body: poll_notification.body, subject: poll_notification.subject)
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, bcc)
15
- mail(bcc: bcc, body: poll_notification.body, subject: poll_notification.subject)
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 poll_end(poll_notification, bcc)
19
- mail(bcc: bcc, body: poll_notification.body, subject: poll_notification.subject)
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
- def emails(exclude_completed: false)
113
- if exclude_completed
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.pluck(:email)
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 email addresses, except for the 'Reminder' that exclude completed users
120
- emails = poll.emails(exclude_completed: (category == 'Reminder'))
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
- emails.in_groups_of(BATCHSIZE, false).each do |emails|
125
- mail = case category
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.editable.all
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
- = f.show_if :category, 'Upcoming reminder' do
10
+ - # Render email templates
11
+ - Effective::PollNotification::CATEGORIES.each do |category|
12
+ - template = 'poll_' + category.parameterize.underscore
11
13
 
12
- = f.select :reminder, Effective::PollNotification::UPCOMING_REMINDERS, label: false,
13
- hint: "before the poll starts on #{f.object.poll&.start_at&.strftime('%F')}."
14
+ = f.show_if :category, category do
15
+ = render "/admin/poll_notifications/form_#{template}", f: f
14
16
 
15
- .alert.alert-warning
16
- %strong Upcoming Reminders
17
- are sent to the entire audience before the poll starts.
18
- %br
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
- = f.show_if :category, 'When poll starts' do
22
- .alert.alert-warning
23
- %strong When poll starts
24
- notifications will be sent within 10 minutes of the poll start time.
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
- = f.show_if :category, 'Reminder' do
27
+ - else
28
+ - email_template = Effective::EmailTemplate.where(template_name: template).first!
27
29
 
28
- = f.select :reminder, Effective::PollNotification::REMINDERS, label: false,
29
- hint: "after the poll starts on #{f.object.poll&.start_at&.strftime('%F')}."
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
- .alert.alert-warning
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
- = f.show_if :category, 'When poll ends' do
38
- .alert.alert-warning
39
- %strong When poll ends
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
- = f.text_field :subject, label: 'Email Subject'
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.
@@ -0,0 +1,3 @@
1
+ .alert.alert-warning
2
+ %strong When poll ends
3
+ notifications will be sent within 10 minutes of the poll end time.
@@ -0,0 +1,3 @@
1
+ .alert.alert-warning
2
+ %strong When poll starts
3
+ notifications will be sent within 10 minutes of the poll start time.
@@ -12,7 +12,7 @@
12
12
 
13
13
  = tab 'Notifications' do
14
14
  %p
15
- The following email notification will be sent to all
15
+ The following email notifications will be sent to
16
16
  = pluralize(poll.users.count, 'users')
17
17
  in the audience.
18
18
 
@@ -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: [f.object.start_at.presence, Time.zone.now].compact.min.strftime('%F') }
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
- = f.date_field :date, label: false, required: poll_question.required?
1
+ .row
2
+ .col-sm-6= f.date_field :date, label: false, required: poll_question.required?
@@ -1 +1,2 @@
1
- = f.email_field :email, label: false, required: poll_question.required?
1
+ .row
2
+ .col-sm-6= f.email_field :email, label: false, required: poll_question.required?
@@ -1 +1,2 @@
1
- = f.number_field :number, label: false, required: poll_question.required?
1
+ .row
2
+ .col-sm-6= f.number_field :number, label: false, required: poll_question.required?
@@ -2,8 +2,8 @@
2
2
  %table.table.table-hover
3
3
  %thead
4
4
  %tr
5
- %th Poll Question
6
- %th Ballot Response
5
+ %th Question
6
+ %th Response
7
7
 
8
8
  %tbody
9
9
  - ballot.poll.poll_questions.each_with_index do |poll_question, index|
@@ -1,5 +1,5 @@
1
1
  = render_wizard_sidebar(resource) do
2
- %h1 Poll: #{resource.poll}
2
+ %h1= resource.poll
3
3
 
4
4
  .alert.alert-warning
5
5
  This is a <strong>Secret Ballot</strong>.
@@ -1,5 +1,5 @@
1
1
  = render_wizard_sidebar(resource) do
2
- %h1 Review: #{resource.poll}
2
+ %h1= resource.poll
3
3
 
4
4
  - if resource.poll.all_steps_content.present?
5
5
  .mb-2= resource.poll.all_steps_content
@@ -1,5 +1,5 @@
1
1
  = render_wizard_sidebar(resource) do
2
- %h1 Ballot: #{resource.poll}
2
+ %h1= resource.poll
3
3
 
4
4
  - if resource.poll.all_steps_content.present?
5
5
  .mb-2= resource.poll.all_steps_content
@@ -20,7 +20,7 @@
20
20
  %table.table.table-hover
21
21
  %thead
22
22
  %tr
23
- %th Poll Question
23
+ %th Question
24
24
  %th Results
25
25
 
26
26
  %tbody
@@ -0,0 +1,13 @@
1
+ ---
2
+ subject: 'Reminder - Please submit your ballot for {{ title }}'
3
+ from: 'admin@example.com'
4
+ ---
5
+ Hello {{ user.name }},
6
+
7
+ The {{ title }} poll has already started.
8
+
9
+ Please remember to submit your ballot.
10
+
11
+ {{ url }}
12
+
13
+ Thank you
@@ -0,0 +1,11 @@
1
+ ---
2
+ subject: '{{ title }} is upcoming'
3
+ from: 'admin@example.com'
4
+ ---
5
+ Hello {{ user.name }},
6
+
7
+ The {{ title }} poll is upcoming.
8
+
9
+ It will be available {{ available_date }}.
10
+
11
+ Thank you
@@ -0,0 +1,9 @@
1
+ ---
2
+ subject: '{{ title }} has ended'
3
+ from: 'admin@example.com'
4
+ ---
5
+ Hello {{ user.name }},
6
+
7
+ The {{ title }} poll has ended.
8
+
9
+ Thank you
@@ -0,0 +1,13 @@
1
+ ---
2
+ subject: '{{ title }} has started'
3
+ from: 'admin@example.com'
4
+ ---
5
+ Hello {{ user.name }},
6
+
7
+ The {{ title }} poll has started.
8
+
9
+ Please click below to submit your ballot.
10
+
11
+ {{ url }}
12
+
13
+ Thank you
@@ -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
@@ -20,6 +20,7 @@ class CreateEffectivePolls < ActiveRecord::Migration[6.0]
20
20
  t.string :category
21
21
  t.integer :reminder
22
22
 
23
+ t.string :from
23
24
  t.string :subject
24
25
  t.text :body
25
26
 
@@ -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.permitted_params
47
- raise('todo')
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
@@ -1,3 +1,3 @@
1
1
  module EffectivePolls
2
- VERSION = '0.0.2'
2
+ VERSION = '0.1.0'
3
3
  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 |poll_notification|
8
+ poll_notifications.find_each do |notification|
9
9
  begin
10
- notified = poll_notification.notify!
11
- puts "Sent #{poll_notification.category} for #{poll_notification.poll}" if notified
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 = { poll_notification_id: poll_notification.id, poll_id: poll_notification.poll_id }
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 #{poll_notification.id}: #{e.errors.inspect}"
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.2
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-20 00:00:00.000000000 Z
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/polls/_form.html.haml
242
- - app/views/effective/polls/_poll.html.haml
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,2 +0,0 @@
1
- %p= poll.title
2
- %p= poll.body
@@ -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)
@@ -1,2 +0,0 @@
1
- %p= poll.title
2
- %p= poll.body