effective_polls 0.1.6 → 0.2.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/app/controllers/admin/poll_notifications_controller.rb +1 -3
- data/app/controllers/admin/poll_questions_controller.rb +1 -3
- data/app/controllers/admin/polls_controller.rb +2 -4
- data/app/controllers/effective/ballots_controller.rb +1 -2
- data/app/controllers/effective/polls_controller.rb +2 -1
- data/app/mailers/effective/polls_mailer.rb +5 -2
- data/config/effective_polls.rb +15 -35
- data/lib/effective_polls/version.rb +1 -1
- data/lib/effective_polls.rb +9 -41
- metadata +2 -3
- data/app/views/layouts/effective_polls_mailer_layout.html.haml +0 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 57df19aaa933dd133ba655525265e129ca1c2bd7a60a78a5a8f2fe89ec1aa5cc
|
4
|
+
data.tar.gz: 86fe4a6defeef051e4ff9c8543480fd6db703e213d80cf100781f4c71cc60e4b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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 {
|
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 {
|
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 {
|
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
|
-
|
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,6 +1,8 @@
|
|
1
1
|
module Effective
|
2
|
-
class PollsMailer < EffectivePolls.
|
3
|
-
|
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),
|
data/config/effective_polls.rb
CHANGED
@@ -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
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
#
|
60
|
-
#
|
61
|
-
#
|
62
|
-
config.
|
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
|
data/lib/effective_polls.rb
CHANGED
@@ -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
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
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
|
-
|
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
|
-
|
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.
|
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:
|
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
|