effective_polls 0.1.6 → 0.2.0

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: 75f0f5786c67293ac7c6e5d8758334fe217c3d2b6361185ec36a8792fe751eaf
4
- data.tar.gz: '08c11bd2988f3cf8c8ab81b3ffaa2fda3d445b7460004cd25d329ba984a81db5'
3
+ metadata.gz: 57df19aaa933dd133ba655525265e129ca1c2bd7a60a78a5a8f2fe89ec1aa5cc
4
+ data.tar.gz: 86fe4a6defeef051e4ff9c8543480fd6db703e213d80cf100781f4c71cc60e4b
5
5
  SHA512:
6
- metadata.gz: acfb2e71deb5da69bb9f37ccc6889cb93aee01624854e37537cadae80c19f49569fbc1d63080ca32c343595158e99a75833a9393efd1d9c311408151e2b4392d
7
- data.tar.gz: 1adb90d91b12bed10d2eb7260080487eac8e5e2c689f171b0032a8dce139e4ddd7fe1e3f1a779826032cef0234b8b0fd1f7247c125e0c0a0c97364ac56c87056
6
+ metadata.gz: 1b6f6ace193a55d55b49184f8a2b9a1a0766b0e1249c5c3daa65bfac034a7bb7b8ae1920b66ed04d1605137a88798d749951f0f714e2289774f63dfc5d820ca4
7
+ data.tar.gz: e0b94cefd83a9af17f232cedc37369615ed0042543b886a496174fd807a3117cab3a876bcb6eb34d61f2ca50a70ede2c2c92d965df67d4b0619dc9a3fd05f052
@@ -1,9 +1,7 @@
1
1
  module Admin
2
2
  class PollNotificationsController < ApplicationController
3
- layout EffectivePolls.layout[:admin]
4
-
5
3
  before_action(:authenticate_user!) if defined?(Devise)
6
- before_action { EffectivePolls.authorize!(self, :admin, :effective_polls) }
4
+ before_action { EffectiveResources.authorize!(self, :admin, :effective_polls) }
7
5
 
8
6
  include Effective::CrudController
9
7
 
@@ -1,9 +1,7 @@
1
1
  module Admin
2
2
  class PollQuestionsController < ApplicationController
3
- layout EffectivePolls.layout[:admin]
4
-
5
3
  before_action(:authenticate_user!) if defined?(Devise)
6
- before_action { EffectivePolls.authorize!(self, :admin, :effective_polls) }
4
+ before_action { EffectiveResources.authorize!(self, :admin, :effective_polls) }
7
5
 
8
6
  include Effective::CrudController
9
7
 
@@ -1,15 +1,13 @@
1
1
  module Admin
2
2
  class PollsController < ApplicationController
3
- layout EffectivePolls.layout[:admin]
4
-
5
3
  before_action(:authenticate_user!) if defined?(Devise)
6
- before_action { EffectivePolls.authorize!(self, :admin, :effective_polls) }
4
+ before_action { EffectiveResources.authorize!(self, :admin, :effective_polls) }
7
5
 
8
6
  include Effective::CrudController
9
7
 
10
8
  def results
11
9
  @poll = Effective::Poll.find(params[:id])
12
- EffectivePolls.authorize!(self, :results, @poll)
10
+ EffectiveResources.authorize!(self, :results, @poll)
13
11
 
14
12
  @datatable = Admin::EffectivePollResultsDatatable.new(poll_token: @poll.token)
15
13
  @page_title = "#{@poll} Results"
@@ -1,8 +1,7 @@
1
1
  module Effective
2
2
  class BallotsController < ApplicationController
3
- layout EffectivePolls.layout[:polls]
4
-
5
3
  before_action(:authenticate_user!) if defined?(Devise)
4
+
6
5
  include Effective::WizardController
7
6
 
8
7
  resource_scope do
@@ -4,7 +4,8 @@ module Effective
4
4
 
5
5
  def show
6
6
  poll = Effective::Poll.find(params[:id])
7
- EffectivePolls.authorize!(self, :show, poll)
7
+
8
+ EffectiveResources.authorize!(self, :show, poll)
8
9
 
9
10
  ballot = Effective::Ballot.where(poll: poll, user: current_user).first
10
11
 
@@ -1,6 +1,8 @@
1
1
  module Effective
2
- class PollsMailer < EffectivePolls.mailer_class
3
- layout EffectivePolls.mailer[:layout].presence || 'effective_polls_mailer_layout'
2
+ class PollsMailer < EffectivePolls.parent_mailer_class
3
+
4
+ include EffectiveMailer
5
+ include EffectiveEmailTemplatesMailer if EffectivePolls.use_effective_email_templates
4
6
 
5
7
  def poll_upcoming_reminder(poll_notification, user)
6
8
  @assigns = effective_email_templates_assigns(poll_notification, user)
@@ -68,6 +70,7 @@ module Effective
68
70
  raise('expected poll to be persisted') unless poll&.persisted?
69
71
 
70
72
  {
73
+ subject: poll_notification.subject,
71
74
  available_date: poll.available_date,
72
75
  title: poll.title,
73
76
  url: effective_polls.poll_url(poll),
@@ -7,34 +7,9 @@ EffectivePolls.setup do |config|
7
7
  config.ballot_responses_table_name = :ballot_responses
8
8
  config.ballot_response_options_table_name = :ballot_response_options
9
9
 
10
- # Authorization Method
11
- #
12
- # This method is called by all controller actions with the appropriate action and resource
13
- # If it raises an exception or returns false, an Effective::AccessDenied Error will be raised
14
- #
15
- # Use via Proc:
16
- # Proc.new { |controller, action, resource| authorize!(action, resource) } # CanCan
17
- # Proc.new { |controller, action, resource| can?(action, resource) } # CanCan with skip_authorization_check
18
- # Proc.new { |controller, action, resource| authorize "#{action}?", resource } # Pundit
19
- # Proc.new { |controller, action, resource| current_user.is?(:admin) } # Custom logic
20
- #
21
- # Use via Boolean:
22
- # config.authorization_method = true # Always authorized
23
- # config.authorization_method = false # Always unauthorized
24
- #
25
- # Use via Method (probably in your application_controller.rb):
26
- # config.authorization_method = :my_authorization_method
27
- # def my_authorization_method(resource, action)
28
- # true
29
- # end
30
- config.authorization_method = Proc.new { |controller, action, resource| authorize!(action, resource) }
31
-
32
10
  # Layout Settings
33
11
  # Configure the Layout per controller, or all at once
34
- config.layout = {
35
- polls: 'application',
36
- admin: 'admin'
37
- }
12
+ # config.layout = { application: 'application', admin: 'admin' }
38
13
 
39
14
  # Audience Scope Collection
40
15
  #
@@ -51,14 +26,19 @@ EffectivePolls.setup do |config|
51
26
  # Schedule rake effective_polls:notify to run every 10 minutes
52
27
  # to send out email poll notifications
53
28
  #
54
- config.mailer = {
55
- layout: 'effective_polls_mailer_layout',
56
- default_from: 'no-reply@example.com'
57
- }
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
29
+ # Please see config/initializers/effective_resources.rb for default effective_* gem mailer settings
30
+ #
31
+ # Configure the class responsible to send e-mails.
32
+ # config.mailer = 'Effective::EventsMailer'
33
+ #
34
+ # Override effective_resource mailer defaults
35
+ #
36
+ # config.parent_mailer = nil # The parent class responsible for sending emails
37
+ # config.deliver_method = nil # The deliver method, deliver_later or deliver_now
38
+ # config.mailer_layout = nil # Default mailer layout
39
+ # config.mailer_sender = nil # Default From value
40
+ # config.mailer_admin = nil # Default To value for Admin correspondence
63
41
 
42
+ # Use effective email templates for event notifications
43
+ config.use_effective_email_templates = true
64
44
  end
@@ -1,3 +1,3 @@
1
1
  module EffectivePolls
2
- VERSION = '0.1.6'
2
+ VERSION = '0.2.0'
3
3
  end
@@ -4,52 +4,20 @@ require 'effective_polls/engine'
4
4
  require 'effective_polls/version'
5
5
 
6
6
  module EffectivePolls
7
- mattr_accessor :polls_table_name
8
- mattr_accessor :poll_notifications_table_name
9
- mattr_accessor :poll_questions_table_name
10
- mattr_accessor :poll_question_options_table_name
11
- mattr_accessor :ballots_table_name
12
- mattr_accessor :ballot_responses_table_name
13
- mattr_accessor :ballot_response_options_table_name
14
7
 
15
- mattr_accessor :authorization_method
16
-
17
- mattr_accessor :layout
18
-
19
- mattr_accessor :audience_user_scopes
20
-
21
- # Hashes of configs
22
- mattr_accessor :use_effective_email_templates
23
- mattr_accessor :mailer
24
-
25
- def self.setup
26
- yield self
8
+ def self.config_keys
9
+ [
10
+ :polls_table_name, :poll_notifications_table_name, :poll_questions_table_name, :poll_question_options_table_name,
11
+ :ballots_table_name, :ballot_responses_table_name, :ballot_response_options_table_name,
12
+ :layout, :audience_user_scopes,
13
+ :mailer, :parent_mailer, :deliver_method, :mailer_layout, :mailer_sender, :mailer_admin, :mailer_subject, :use_effective_email_templates
14
+ ]
27
15
  end
28
16
 
29
- def self.authorized?(controller, action, resource)
30
- @_exceptions ||= [Effective::AccessDenied, (CanCan::AccessDenied if defined?(CanCan)), (Pundit::NotAuthorizedError if defined?(Pundit))].compact
31
-
32
- return !!authorization_method unless authorization_method.respond_to?(:call)
33
- controller = controller.controller if controller.respond_to?(:controller)
34
-
35
- begin
36
- !!(controller || self).instance_exec((controller || self), action, resource, &authorization_method)
37
- rescue *@_exceptions
38
- false
39
- end
40
- end
41
-
42
- def self.authorize!(controller, action, resource)
43
- raise Effective::AccessDenied.new('Access Denied', action, resource) unless authorized?(controller, action, resource)
44
- end
17
+ include EffectiveGem
45
18
 
46
19
  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
20
+ mailer&.constantize || Effective::PollsMailer
53
21
  end
54
22
 
55
23
  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.1.6
4
+ version: 0.2.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-07-06 00:00:00.000000000 Z
11
+ date: 2022-03-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -176,7 +176,6 @@ files:
176
176
  - app/views/effective/polls_mailer/poll_upcoming_reminder.liquid
177
177
  - app/views/effective/polls_mailer/poll_when_poll_ends.liquid
178
178
  - app/views/effective/polls_mailer/poll_when_poll_starts.liquid
179
- - app/views/layouts/effective_polls_mailer_layout.html.haml
180
179
  - config/effective_polls.rb
181
180
  - config/routes.rb
182
181
  - db/migrate/01_create_effective_polls.rb.erb
@@ -1,7 +0,0 @@
1
- !!!
2
- %html{style: 'background: #fff;'}
3
- %head
4
- %meta{:content => 'text/html; charset=UTF-8', 'http-equiv' => 'Content-Type'}
5
-
6
- %body{style: 'background: #fff;'}
7
- = yield