effective_polls 0.6.3 → 0.7.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: 1a20ad391dc3c9332c540ddf58f76004950099c17f9305af1919c7f541251019
4
- data.tar.gz: b6c5b6688300174b7f836b5572707006cc08b81e6c50bf131ca6127fedb48342
3
+ metadata.gz: 8f18ce3f4be236e848fdaf1f0cbc5964f1c7d0f4d1f89efcb0d4fd565b1d1d21
4
+ data.tar.gz: df60d1d96ad211ad97237165bcc366e1787dc03f3f938c1c4df7614184d34d6c
5
5
  SHA512:
6
- metadata.gz: 2b624b1d4005ea65626a2d82fe33bff3640f4696670a8575f7c3aced34506e0b8fb21c8cfd201ffcdd5e72d1da4b7d2a50cbc5d0ee7f802fe0b3089e1fa24feb
7
- data.tar.gz: 7b1b714ceafa0e11c52ded569ac091ca32b045a5d9fd2f5f6c1bd7915d6ba8baf3532f400a2588b040eb8ceb28470158c1a886198eb5851bc1e120da6ef1f2ae
6
+ metadata.gz: fbbad665eaaecdb8d975e63d44daa8846acedb2b601c5669c61d506b9fbf002e2b83cd9a6c3a5e3a8f26bd419c43cfb4280694dd6d36d9d04a61646090b4221f
7
+ data.tar.gz: 3bec1b83924572a0895ec8b3e499ad0d8ba590bbc58cf4bd429c22232fd9681d0f123d4bdd42e65776abfbd50c634b5185ed948ceffad948780c64741352319c
@@ -13,6 +13,10 @@ class Admin::EffectivePollNotificationsDatatable < Effective::Datatable
13
13
  col :poll
14
14
  col :category
15
15
 
16
+ col :from, visible: false do |notification|
17
+ ERB::Util.html_escape_once(notification.from)
18
+ end
19
+
16
20
  col :reminder do |poll_notification|
17
21
  case poll_notification.category
18
22
  when 'When poll starts'
@@ -36,6 +40,10 @@ class Admin::EffectivePollNotificationsDatatable < Effective::Datatable
36
40
  simple_format(notification.body.to_s)
37
41
  end
38
42
 
43
+ col :cc, visible: false
44
+ col :bcc, visible: false
45
+ col :content_type, visible: false
46
+
39
47
  col :started_at, visible: false
40
48
  col :completed_at
41
49
 
@@ -21,6 +21,7 @@ module EffectivePollsUser
21
21
 
22
22
  # The list of all available audience scopes for the Poll Selected Users
23
23
  def poll_audience_scopes
24
+ default_poll_audience_scopes()
24
25
  end
25
26
 
26
27
  def default_poll_audience_scopes
@@ -1,8 +1,10 @@
1
1
  module Effective
2
2
  class PollNotification < ActiveRecord::Base
3
- belongs_to :poll
3
+ acts_as_email_notification # effective_resources
4
4
  log_changes(to: :poll) if respond_to?(:log_changes)
5
5
 
6
+ belongs_to :poll
7
+
6
8
  CATEGORIES = ['Upcoming reminder', 'When poll starts', 'Reminder', 'Before poll ends', 'When poll ends']
7
9
  EMAIL_TEMPLATE_VARIABLES = ['available_date', 'title', 'url', 'user.name', 'user.email']
8
10
 
@@ -49,6 +51,10 @@ module Effective
49
51
  subject :string
50
52
  body :text
51
53
 
54
+ cc :string
55
+ bcc :string
56
+ content_type :string
57
+
52
58
  # Tracking background jobs email send out
53
59
  started_at :datetime
54
60
  completed_at :datetime
@@ -68,13 +74,6 @@ module Effective
68
74
  validates :poll, presence: true
69
75
  validates :category, presence: true, inclusion: { in: CATEGORIES }
70
76
 
71
- validates :from, presence: true
72
- validates :subject, presence: true
73
- validates :body, presence: true
74
-
75
- validates :body, liquid: true
76
- validates :subject, liquid: true
77
-
78
77
  validates :reminder, if: -> { reminder? || upcoming_reminder? || before_poll_ends? },
79
78
  presence: true, uniqueness: { scope: [:poll_id, :category], message: 'already exists' }
80
79
 
@@ -86,6 +85,10 @@ module Effective
86
85
  'poll_' + category.to_s.parameterize.underscore
87
86
  end
88
87
 
88
+ def email_template_variables
89
+ EMAIL_TEMPLATE_VARIABLES
90
+ end
91
+
89
92
  def upcoming_reminder?
90
93
  category == 'Upcoming reminder'
91
94
  end
@@ -148,7 +151,8 @@ module Effective
148
151
  Effective::PollsMailer.public_send(email_template, self, user).deliver_now
149
152
  rescue => e
150
153
  EffectiveLogger.error(e.message, associated: self) if defined?(EffectiveLogger)
151
- ExceptionNotifier.notify_exception(e, data: { user_id: user.id }) if defined?(ExceptionNotifier)
154
+ ExceptionNotifier.notify_exception(e, data: { user_id: user.id, poll_notification_id: id }) if defined?(ExceptionNotifier)
155
+ raise(e) if Rails.env.test? || Rails.env.development?
152
156
  end
153
157
 
154
158
  end
@@ -13,25 +13,6 @@
13
13
 
14
14
  = f.show_if :category, category do
15
15
  .my-3= render "/admin/poll_notifications/form_#{template}", f: f
16
-
17
- - if f.object.category == category && f.object.persisted?
18
- = f.select :from, mailer_froms_collection(), label: 'From'
19
- = f.text_field :subject
20
- = f.text_area :body, rows: 10
21
- - else
22
- - email_template = Effective::EmailTemplate.where(template_name: template).first!
23
- - from_value = email_template.from || EffectiveResources.mailer_froms.first
24
-
25
- = f.select :from, mailer_froms_collection(), label: 'From', value: from_value
26
- = f.text_field :subject, value: email_template.subject
27
- = f.text_area :body, rows: 10, value: email_template.body
28
-
29
- %p The available variables are:
30
-
31
- %ul
32
- - Effective::PollNotification::EMAIL_TEMPLATE_VARIABLES.each do |variable|
33
- %li {{ #{variable} }}
34
-
35
- %small.text-muted Please contact us to add additional variables
16
+ = email_notification_fields(f, template, variables: Effective::PollNotification::EMAIL_TEMPLATE_VARIABLES)
36
17
 
37
18
  = effective_submit(f)
@@ -6,7 +6,7 @@
6
6
  = f.datetime_field :end_at
7
7
 
8
8
  - if f.object.poll_notifications.present?
9
- .alert.alert-info
9
+ .alert.alert-info.mb-3
10
10
  Please be aware of the existing #{ets(f.object.poll_notifications)} when changing the start or end availability date.
11
11
 
12
12
  = f.check_box :hide_results,
@@ -29,6 +29,10 @@ class CreateEffectivePolls < ActiveRecord::Migration[6.0]
29
29
  t.string :subject
30
30
  t.text :body
31
31
 
32
+ t.string :cc
33
+ t.string :bcc
34
+ t.string :content_type
35
+
32
36
  t.datetime :started_at
33
37
  t.datetime :completed_at
34
38
 
@@ -1,3 +1,3 @@
1
1
  module EffectivePolls
2
- VERSION = '0.6.3'
2
+ VERSION = '0.7.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.6.3
4
+ version: 0.7.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-05-22 00:00:00.000000000 Z
11
+ date: 2024-06-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails