effective_polls 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/MIT-LICENSE +1 -1
- data/README.md +57 -20
- data/app/controllers/admin/poll_notifications_controller.rb +1 -1
- data/app/controllers/admin/poll_questions_controller.rb +1 -1
- data/app/controllers/admin/polls_controller.rb +1 -1
- data/app/controllers/effective/ballots_controller.rb +1 -1
- data/app/models/effective/poll.rb +4 -0
- data/app/models/effective/poll_notification.rb +1 -0
- data/app/models/effective/poll_question.rb +1 -0
- data/app/views/admin/polls/_form.html.haml +4 -0
- data/app/views/admin/polls/_form_poll.html.haml +3 -0
- data/config/effective_polls.rb +1 -1
- data/lib/effective_polls/version.rb +1 -1
- data/lib/generators/effective_polls/install_generator.rb +1 -1
- data/lib/generators/templates/effective_polls_mailer_preview.rb +4 -3
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 68d305ba395a3d2414ebca82cd907b4e15831390d406bc963f491ebb982c76d3
|
4
|
+
data.tar.gz: 46418fe6dc4c690c64e29800ce3cc3710ece9375e057f2fbdf2f47521b637bde
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: '0379c829ce46c31baa169a070c7023d2ae4f013770667725d14f9a309b1a940cf474afef85e1717de3ffad9cdbe114e1ed676895013ff865eee3afe4aeed8d58'
|
7
|
+
data.tar.gz: 8ff57a27c6baae02974c31c43d2067759b895f1f90fdf258c573b606acb6fa5ee26871f52b6ffda86713b63bc96785d1138e74d776c6f595b5264e64e649ae5c
|
data/MIT-LICENSE
CHANGED
data/README.md
CHANGED
@@ -2,21 +2,24 @@
|
|
2
2
|
|
3
3
|
Online polls and user voting.
|
4
4
|
|
5
|
-
An admin creates polls with one or more poll_questions. The poll can be assigned to users
|
5
|
+
An admin creates polls with one or more poll_questions. The poll can be assigned to all users, individual users or selected users (a scope) and those users complete a 4-step wizard to submit a poll.
|
6
6
|
|
7
|
-
|
7
|
+
All results are anonymized such that the user cannot be identified from the results.
|
8
8
|
|
9
|
-
|
9
|
+
Works with action_text for content bodies, and active_storage for file uploads.
|
10
10
|
|
11
11
|
## Getting Started
|
12
12
|
|
13
|
+
This requires Rails 6+ and Twitter Bootstrap 4 and just works with Devise.
|
14
|
+
|
13
15
|
Please first install the [effective_datatables](https://github.com/code-and-effect/effective_datatables) gem.
|
14
16
|
|
15
|
-
Please download and install [Twitter Bootstrap4](http://getbootstrap.com)
|
17
|
+
Please download and install the [Twitter Bootstrap4](http://getbootstrap.com)
|
16
18
|
|
17
19
|
Add to your Gemfile:
|
18
20
|
|
19
21
|
```ruby
|
22
|
+
gem 'haml-rails' # or try using gem 'hamlit-rails'
|
20
23
|
gem 'effective_polls'
|
21
24
|
```
|
22
25
|
|
@@ -34,7 +37,7 @@ rails generate effective_polls:install
|
|
34
37
|
|
35
38
|
The generator will install an initializer which describes all configuration options and creates a database migration.
|
36
39
|
|
37
|
-
If you want to tweak the table
|
40
|
+
If you want to tweak the table names, manually adjust both the configuration file and the migration now.
|
38
41
|
|
39
42
|
Then migrate the database:
|
40
43
|
|
@@ -42,9 +45,56 @@ Then migrate the database:
|
|
42
45
|
rake db:migrate
|
43
46
|
```
|
44
47
|
|
45
|
-
|
48
|
+
Render the "available polls for current_user" datatable on your user dashboard:
|
49
|
+
|
50
|
+
```haml
|
51
|
+
%h2 Polls
|
52
|
+
%p You may submit a ballot for the following polls.
|
53
|
+
= render_datatable(EffectivePollsDatatable.new, simple: true)
|
54
|
+
```
|
55
|
+
|
56
|
+
Add a link to the admin menu:
|
57
|
+
|
58
|
+
```haml
|
59
|
+
- if can? :admin, :effective_polls
|
60
|
+
= link_to 'Polls', effective_polls.admin_polls_path
|
61
|
+
```
|
62
|
+
|
63
|
+
Set up your permissions:
|
64
|
+
|
65
|
+
```ruby
|
66
|
+
# Regular signed up user. Guest users not supported.
|
67
|
+
if user.persisted?
|
68
|
+
can [:show, :update], Effective::Ballot, user_id: user.id
|
69
|
+
can :show, Effective::Poll
|
70
|
+
can :index, EffectivePollsDatatable
|
71
|
+
end
|
72
|
+
|
73
|
+
if user.admin?
|
74
|
+
can :admin, :effective_polls
|
46
75
|
|
47
|
-
|
76
|
+
can :manage, Effective::Poll
|
77
|
+
can :manage, Effective::PollNotification
|
78
|
+
|
79
|
+
can :index, Effective::PollQuestion
|
80
|
+
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
|
+
end
|
87
|
+
```
|
88
|
+
|
89
|
+
And, if you want to use poll notifications, schedule the rake task to run every 10 minutes, or faster:
|
90
|
+
|
91
|
+
```rake
|
92
|
+
rake effective_polls:notify
|
93
|
+
```
|
94
|
+
|
95
|
+
## Usage
|
96
|
+
|
97
|
+
You can render the results with `render('effective/poll_results/results', poll: poll)`.
|
48
98
|
|
49
99
|
## Authorization
|
50
100
|
|
@@ -97,19 +147,6 @@ rescue_from Effective::AccessDenied do |exception|
|
|
97
147
|
end
|
98
148
|
```
|
99
149
|
|
100
|
-
### Permissions
|
101
|
-
|
102
|
-
The permissions you actually want to define are as follows (using CanCan):
|
103
|
-
|
104
|
-
```ruby
|
105
|
-
can [:index, :show], Effective::Poll
|
106
|
-
|
107
|
-
if user.admin?
|
108
|
-
can :manage, Effective::Poll
|
109
|
-
can :admin, :effective_polls
|
110
|
-
end
|
111
|
-
```
|
112
|
-
|
113
150
|
## License
|
114
151
|
|
115
152
|
MIT License. Copyright [Code and Effect Inc.](http://www.codeandeffect.com/)
|
@@ -1,6 +1,6 @@
|
|
1
1
|
module Admin
|
2
2
|
class PollNotificationsController < ApplicationController
|
3
|
-
layout
|
3
|
+
layout EffectivePolls.layout[:admin]
|
4
4
|
|
5
5
|
before_action(:authenticate_user!) if defined?(Devise)
|
6
6
|
before_action { EffectivePolls.authorize!(self, :admin, :effective_polls) }
|
@@ -1,6 +1,6 @@
|
|
1
1
|
module Admin
|
2
2
|
class PollQuestionsController < ApplicationController
|
3
|
-
layout
|
3
|
+
layout EffectivePolls.layout[:admin]
|
4
4
|
|
5
5
|
before_action(:authenticate_user!) if defined?(Devise)
|
6
6
|
before_action { EffectivePolls.authorize!(self, :admin, :effective_polls) }
|
@@ -1,6 +1,6 @@
|
|
1
1
|
module Admin
|
2
2
|
class PollsController < ApplicationController
|
3
|
-
layout
|
3
|
+
layout EffectivePolls.layout[:admin]
|
4
4
|
|
5
5
|
before_action(:authenticate_user!) if defined?(Devise)
|
6
6
|
before_action { EffectivePolls.authorize!(self, :admin, :effective_polls) }
|
@@ -1,6 +1,6 @@
|
|
1
1
|
module Effective
|
2
2
|
class BallotsController < ApplicationController
|
3
|
-
layout
|
3
|
+
layout EffectivePolls.layout[:polls]
|
4
4
|
|
5
5
|
before_action(:authenticate_user!) if defined?(Devise)
|
6
6
|
include Effective::WizardController
|
@@ -23,6 +23,10 @@ module Effective
|
|
23
23
|
|
24
24
|
acts_as_tokened
|
25
25
|
|
26
|
+
if respond_to?(:log_changes)
|
27
|
+
log_changes(except: [:ballots, :ballot_responses, :completed_ballots, :completed_ballot_responses])
|
28
|
+
end
|
29
|
+
|
26
30
|
AUDIENCES = ['All Users', 'Individual Users', 'Selected Users']
|
27
31
|
|
28
32
|
effective_resource do
|
@@ -18,3 +18,7 @@
|
|
18
18
|
|
19
19
|
- datatable = Admin::EffectivePollNotificationsDatatable.new(poll_id: poll.id)
|
20
20
|
= render_datatable(datatable, inline: true, simple: true)
|
21
|
+
|
22
|
+
- if poll.respond_to?(:log_changes_datatable)
|
23
|
+
= tab 'Logs' do
|
24
|
+
= render_datatable(poll.log_changes_datatable)
|
@@ -4,6 +4,9 @@
|
|
4
4
|
= f.datetime_field :start_at, input_js: { minDate: [f.object.start_at.presence, Time.zone.now].compact.min.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
|
+
|
7
10
|
-# Audience
|
8
11
|
= f.radios :audience, Effective::Poll::AUDIENCES
|
9
12
|
|
data/config/effective_polls.rb
CHANGED
@@ -26,7 +26,7 @@ module EffectivePolls
|
|
26
26
|
@poll_question_options_table_name = ':' + EffectivePolls.poll_question_options_table_name.to_s
|
27
27
|
@ballots_table_name = ':' + EffectivePolls.ballots_table_name.to_s
|
28
28
|
@ballot_responses_table_name = ':' + EffectivePolls.ballot_responses_table_name.to_s
|
29
|
-
@ballot_response_options_table_name = ':' + EffectivePolls.
|
29
|
+
@ballot_response_options_table_name = ':' + EffectivePolls.ballot_response_options_table_name.to_s
|
30
30
|
|
31
31
|
migration_template ('../' * 3) + 'db/migrate/01_create_effective_polls.rb.erb', 'db/migrate/create_effective_polls.rb'
|
32
32
|
end
|
@@ -2,8 +2,9 @@
|
|
2
2
|
|
3
3
|
class EffectivePollsMailerPreview < ActionMailer::Preview
|
4
4
|
|
5
|
-
def poll_upcoming_reminder
|
6
|
-
|
5
|
+
def poll_upcoming_reminder
|
6
|
+
poll_notification = build_poll_notification('The poll will start soon')
|
7
|
+
Effective::PollsMailer.poll_upcoming_reminder(poll_notification, bccs)
|
7
8
|
end
|
8
9
|
|
9
10
|
def poll_start
|
@@ -12,7 +13,7 @@ class EffectivePollsMailerPreview < ActionMailer::Preview
|
|
12
13
|
end
|
13
14
|
|
14
15
|
def poll_reminder
|
15
|
-
poll_notification = build_poll_notification('
|
16
|
+
poll_notification = build_poll_notification('The poll started already and you have not participated')
|
16
17
|
Effective::PollsMailer.poll_reminder(poll_notification, bccs)
|
17
18
|
end
|
18
19
|
|
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.0.2
|
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-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|