decidim-generators 0.11.2 → 0.12.0.pre
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +149 -124
- data/Rakefile +1 -30
- data/exe/decidim +6 -0
- data/lib/decidim/generators/app_generator.rb +24 -2
- data/lib/decidim/generators/app_templates/another_dummy_authorization_handler.rb +24 -0
- data/lib/decidim/generators/app_templates/carrierwave.rb +4 -1
- data/lib/decidim/generators/app_templates/database.yml.erb +3 -3
- data/lib/decidim/generators/app_templates/dummy_authorization_handler.rb +107 -0
- data/lib/decidim/generators/app_templates/verifications_initializer.rb +20 -0
- data/lib/decidim/generators/component_generator.rb +0 -2
- data/lib/decidim/generators/component_templates/lib/decidim/component/admin_engine.rb.erb +0 -6
- data/lib/decidim/generators/component_templates/lib/decidim/component/component.rb.erb +1 -1
- data/lib/decidim/generators/component_templates/lib/decidim/component/engine.rb.erb +0 -6
- data/lib/decidim/generators/component_templates/spec/spec_helper.rb.erb +1 -1
- data/lib/decidim/generators/install_generator.rb +6 -8
- data/lib/decidim/generators/version.rb +1 -1
- metadata +9 -9
- data/lib/decidim/generators/app_templates/example_authorization_handler.rb +0 -55
- data/lib/decidim/generators/component_templates/app/models/decidim/component/abilities/admin/admin_ability.rb.erb +0 -17
- data/lib/decidim/generators/component_templates/app/models/decidim/component/abilities/current_user_ability.rb.erb +0 -47
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9effb7aafdec02ac555522182684ea85952c427eabf1bf71102b44d1a2183038
|
4
|
+
data.tar.gz: f9cb22fe9baa093f45ae85597675ef83a3e24df4b3f4fdfe35cab2c66163a68d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 519c0a62e34b11fcc2276af2d5f0e446acafa7117bd65d6bc6ab107d7aea8e2642f074c3fcd54407d86e00e698b9b96249dfadf67dfc04f54260ffaaadb5c5fc
|
7
|
+
data.tar.gz: '070562268415c160b5f85d8073ff2bfc8c6f808316f3d588cce82948ec3334996efca395e5ce6e7af64c01998c676444adba3a78f319f2140083ee712441f7c3'
|
data/Gemfile.lock
CHANGED
@@ -1,69 +1,68 @@
|
|
1
1
|
PATH
|
2
2
|
remote: ..
|
3
3
|
specs:
|
4
|
-
decidim (0.
|
5
|
-
decidim-accountability (= 0.
|
6
|
-
decidim-admin (= 0.
|
7
|
-
decidim-api (= 0.
|
8
|
-
decidim-assemblies (= 0.
|
9
|
-
decidim-blogs (= 0.
|
10
|
-
decidim-budgets (= 0.
|
11
|
-
decidim-comments (= 0.
|
12
|
-
decidim-core (= 0.
|
13
|
-
decidim-debates (= 0.
|
14
|
-
decidim-generators (= 0.
|
15
|
-
decidim-meetings (= 0.
|
16
|
-
decidim-pages (= 0.
|
17
|
-
decidim-participatory_processes (= 0.
|
18
|
-
decidim-proposals (= 0.
|
19
|
-
decidim-sortitions (= 0.
|
20
|
-
decidim-surveys (= 0.
|
21
|
-
decidim-system (= 0.
|
22
|
-
decidim-verifications (= 0.
|
23
|
-
decidim-accountability (0.
|
24
|
-
decidim-comments (= 0.
|
25
|
-
decidim-core (= 0.
|
4
|
+
decidim (0.12.0.pre)
|
5
|
+
decidim-accountability (= 0.12.0.pre)
|
6
|
+
decidim-admin (= 0.12.0.pre)
|
7
|
+
decidim-api (= 0.12.0.pre)
|
8
|
+
decidim-assemblies (= 0.12.0.pre)
|
9
|
+
decidim-blogs (= 0.12.0.pre)
|
10
|
+
decidim-budgets (= 0.12.0.pre)
|
11
|
+
decidim-comments (= 0.12.0.pre)
|
12
|
+
decidim-core (= 0.12.0.pre)
|
13
|
+
decidim-debates (= 0.12.0.pre)
|
14
|
+
decidim-generators (= 0.12.0.pre)
|
15
|
+
decidim-meetings (= 0.12.0.pre)
|
16
|
+
decidim-pages (= 0.12.0.pre)
|
17
|
+
decidim-participatory_processes (= 0.12.0.pre)
|
18
|
+
decidim-proposals (= 0.12.0.pre)
|
19
|
+
decidim-sortitions (= 0.12.0.pre)
|
20
|
+
decidim-surveys (= 0.12.0.pre)
|
21
|
+
decidim-system (= 0.12.0.pre)
|
22
|
+
decidim-verifications (= 0.12.0.pre)
|
23
|
+
decidim-accountability (0.12.0.pre)
|
24
|
+
decidim-comments (= 0.12.0.pre)
|
25
|
+
decidim-core (= 0.12.0.pre)
|
26
26
|
kaminari (~> 1.0)
|
27
27
|
searchlight (~> 4.1)
|
28
|
-
decidim-admin (0.
|
28
|
+
decidim-admin (0.12.0.pre)
|
29
29
|
active_link_to (~> 1.0)
|
30
|
-
decidim-core (= 0.
|
30
|
+
decidim-core (= 0.12.0.pre)
|
31
31
|
devise (~> 4.2)
|
32
32
|
devise-i18n (~> 1.2)
|
33
33
|
devise_invitable (~> 1.7)
|
34
34
|
jquery-rails (~> 4.3)
|
35
35
|
sassc-rails (~> 1.3)
|
36
|
-
decidim-api (0.
|
36
|
+
decidim-api (0.12.0.pre)
|
37
37
|
graphiql-rails (~> 1.4)
|
38
38
|
graphql (~> 1.6)
|
39
39
|
rack-cors (~> 1.0)
|
40
40
|
sprockets-es6 (~> 0.9.2)
|
41
|
-
decidim-assemblies (0.
|
42
|
-
decidim-core (= 0.
|
43
|
-
decidim-blogs (0.
|
44
|
-
decidim-admin (= 0.
|
45
|
-
decidim-comments (= 0.
|
46
|
-
decidim-core (= 0.
|
41
|
+
decidim-assemblies (0.12.0.pre)
|
42
|
+
decidim-core (= 0.12.0.pre)
|
43
|
+
decidim-blogs (0.12.0.pre)
|
44
|
+
decidim-admin (= 0.12.0.pre)
|
45
|
+
decidim-comments (= 0.12.0.pre)
|
46
|
+
decidim-core (= 0.12.0.pre)
|
47
47
|
httparty (~> 0.16.0)
|
48
48
|
jquery-tmpl-rails (~> 1.1)
|
49
49
|
kaminari (~> 1.0)
|
50
|
-
decidim-budgets (0.
|
51
|
-
decidim-comments (= 0.
|
52
|
-
decidim-core (= 0.
|
50
|
+
decidim-budgets (0.12.0.pre)
|
51
|
+
decidim-comments (= 0.12.0.pre)
|
52
|
+
decidim-core (= 0.12.0.pre)
|
53
53
|
kaminari (~> 1.0)
|
54
54
|
searchlight (~> 4.1)
|
55
|
-
decidim-comments (0.
|
56
|
-
decidim-core (= 0.
|
55
|
+
decidim-comments (0.12.0.pre)
|
56
|
+
decidim-core (= 0.12.0.pre)
|
57
57
|
jquery-rails (~> 4.0)
|
58
|
-
decidim-core (0.
|
58
|
+
decidim-core (0.12.0.pre)
|
59
59
|
active_link_to (~> 1.0)
|
60
60
|
autoprefixer-rails (~> 8.0)
|
61
|
-
cancancan (~> 2.0)
|
62
61
|
carrierwave (~> 1.1)
|
63
62
|
cells-erb (~> 0.1.0)
|
64
|
-
cells-rails (~> 0.0.
|
63
|
+
cells-rails (~> 0.0.9)
|
65
64
|
date_validator (~> 0.9.0)
|
66
|
-
decidim-api (= 0.
|
65
|
+
decidim-api (= 0.12.0.pre)
|
67
66
|
devise (~> 4.3)
|
68
67
|
devise-i18n (~> 1.2)
|
69
68
|
doorkeeper (~> 4.3)
|
@@ -72,7 +71,6 @@ PATH
|
|
72
71
|
foundation-rails (~> 6.4, < 6.5)
|
73
72
|
foundation_rails_helper (~> 3.0)
|
74
73
|
geocoder (~> 1.4)
|
75
|
-
high_voltage (~> 3.0.0)
|
76
74
|
invisible_captcha (~> 0.10.0)
|
77
75
|
jquery-rails (~> 4.3)
|
78
76
|
loofah (~> 2.0, >= 2.2.1)
|
@@ -81,10 +79,12 @@ PATH
|
|
81
79
|
omniauth-facebook (~> 4.0)
|
82
80
|
omniauth-google-oauth2 (~> 0.5.0)
|
83
81
|
omniauth-twitter (~> 1.4)
|
84
|
-
paper_trail (~>
|
82
|
+
paper_trail (~> 9.0)
|
85
83
|
pg (>= 0.18, < 2)
|
84
|
+
pg_search (~> 2.1, >= 2.1.0)
|
86
85
|
premailer-rails (~> 1.9)
|
87
|
-
|
86
|
+
rack-attack (~> 5.2.0)
|
87
|
+
rails (>= 5.2, < 6.0.x)
|
88
88
|
rails-i18n (~> 5.0)
|
89
89
|
rectify (~> 0.11.0)
|
90
90
|
redis (~> 4.0)
|
@@ -96,20 +96,22 @@ PATH
|
|
96
96
|
uglifier (~> 4.0)
|
97
97
|
valid_email2 (~> 2.1)
|
98
98
|
wisper (~> 2.0)
|
99
|
-
decidim-debates (0.
|
100
|
-
decidim-comments (= 0.
|
101
|
-
decidim-core (= 0.
|
99
|
+
decidim-debates (0.12.0.pre)
|
100
|
+
decidim-comments (= 0.12.0.pre)
|
101
|
+
decidim-core (= 0.12.0.pre)
|
102
102
|
kaminari (~> 1.0)
|
103
103
|
searchlight (~> 4.1)
|
104
|
-
decidim-dev (0.
|
104
|
+
decidim-dev (0.12.0.pre)
|
105
105
|
byebug (~> 10.0)
|
106
|
-
capybara (~>
|
106
|
+
capybara (~> 3.0)
|
107
107
|
db-query-matchers (~> 0.9.0)
|
108
|
-
decidim (= 0.
|
108
|
+
decidim (= 0.12.0.pre)
|
109
109
|
erb_lint (~> 0.0.22)
|
110
110
|
factory_bot_rails (~> 4.8)
|
111
111
|
i18n-tasks (~> 0.9.18)
|
112
|
+
mdl (~> 0.4.0)
|
112
113
|
nokogiri (~> 1.8, >= 1.8.2)
|
114
|
+
puma (~> 3.11)
|
113
115
|
rails-controller-testing (~> 1.0)
|
114
116
|
rspec-cells (~> 0.3.4)
|
115
117
|
rspec-html-matchers (~> 0.9.1)
|
@@ -121,68 +123,70 @@ PATH
|
|
121
123
|
simplecov (~> 0.13)
|
122
124
|
webmock (~> 3.0)
|
123
125
|
wisper-rspec (~> 1.0)
|
124
|
-
decidim-generators (0.
|
125
|
-
decidim-core (= 0.
|
126
|
-
decidim-meetings (0.
|
126
|
+
decidim-generators (0.12.0.pre)
|
127
|
+
decidim-core (= 0.12.0.pre)
|
128
|
+
decidim-meetings (0.12.0.pre)
|
127
129
|
cells-erb (~> 0.1.0)
|
128
|
-
cells-rails (~> 0.0.
|
129
|
-
decidim-core (= 0.
|
130
|
+
cells-rails (~> 0.0.9)
|
131
|
+
decidim-core (= 0.12.0.pre)
|
130
132
|
httparty (~> 0.16.0)
|
131
133
|
icalendar (~> 2.4)
|
132
134
|
jquery-tmpl-rails (~> 1.1)
|
133
135
|
kaminari (~> 1.0)
|
134
136
|
searchlight (~> 4.1)
|
135
|
-
decidim-pages (0.
|
136
|
-
decidim-core (= 0.
|
137
|
-
decidim-participatory_processes (0.
|
138
|
-
decidim-core (= 0.
|
139
|
-
decidim-proposals (0.
|
140
|
-
|
141
|
-
|
137
|
+
decidim-pages (0.12.0.pre)
|
138
|
+
decidim-core (= 0.12.0.pre)
|
139
|
+
decidim-participatory_processes (0.12.0.pre)
|
140
|
+
decidim-core (= 0.12.0.pre)
|
141
|
+
decidim-proposals (0.12.0.pre)
|
142
|
+
cells-erb (~> 0.1.0)
|
143
|
+
cells-rails (~> 0.0.9)
|
144
|
+
decidim-comments (= 0.12.0.pre)
|
145
|
+
decidim-core (= 0.12.0.pre)
|
142
146
|
kaminari (~> 1.0)
|
143
147
|
ransack (~> 1.8)
|
144
148
|
social-share-button (~> 1.0)
|
145
|
-
decidim-sortitions (0.
|
146
|
-
decidim-admin (= 0.
|
147
|
-
decidim-comments (= 0.
|
148
|
-
decidim-core (= 0.
|
149
|
-
decidim-proposals (= 0.
|
149
|
+
decidim-sortitions (0.12.0.pre)
|
150
|
+
decidim-admin (= 0.12.0.pre)
|
151
|
+
decidim-comments (= 0.12.0.pre)
|
152
|
+
decidim-core (= 0.12.0.pre)
|
153
|
+
decidim-proposals (= 0.12.0.pre)
|
150
154
|
social-share-button (~> 1.0)
|
151
|
-
decidim-surveys (0.
|
152
|
-
decidim-core (= 0.
|
153
|
-
decidim-system (0.
|
155
|
+
decidim-surveys (0.12.0.pre)
|
156
|
+
decidim-core (= 0.12.0.pre)
|
157
|
+
decidim-system (0.12.0.pre)
|
154
158
|
active_link_to (~> 1.0)
|
155
|
-
decidim-core (= 0.
|
159
|
+
decidim-core (= 0.12.0.pre)
|
156
160
|
devise (~> 4.2)
|
157
161
|
devise-i18n (~> 1.2)
|
158
162
|
devise_invitable (~> 1.7)
|
159
163
|
jquery-rails (~> 4.3)
|
160
164
|
sassc-rails (~> 1.3)
|
161
|
-
decidim-verifications (0.
|
162
|
-
decidim-core (= 0.
|
165
|
+
decidim-verifications (0.12.0.pre)
|
166
|
+
decidim-core (= 0.12.0.pre)
|
163
167
|
|
164
168
|
GEM
|
165
169
|
remote: https://rubygems.org/
|
166
170
|
specs:
|
167
|
-
actioncable (5.
|
168
|
-
actionpack (= 5.
|
171
|
+
actioncable (5.2.0)
|
172
|
+
actionpack (= 5.2.0)
|
169
173
|
nio4r (~> 2.0)
|
170
|
-
websocket-driver (
|
171
|
-
actionmailer (5.
|
172
|
-
actionpack (= 5.
|
173
|
-
actionview (= 5.
|
174
|
-
activejob (= 5.
|
174
|
+
websocket-driver (>= 0.6.1)
|
175
|
+
actionmailer (5.2.0)
|
176
|
+
actionpack (= 5.2.0)
|
177
|
+
actionview (= 5.2.0)
|
178
|
+
activejob (= 5.2.0)
|
175
179
|
mail (~> 2.5, >= 2.5.4)
|
176
180
|
rails-dom-testing (~> 2.0)
|
177
|
-
actionpack (5.
|
178
|
-
actionview (= 5.
|
179
|
-
activesupport (= 5.
|
181
|
+
actionpack (5.2.0)
|
182
|
+
actionview (= 5.2.0)
|
183
|
+
activesupport (= 5.2.0)
|
180
184
|
rack (~> 2.0)
|
181
185
|
rack-test (>= 0.6.3)
|
182
186
|
rails-dom-testing (~> 2.0)
|
183
187
|
rails-html-sanitizer (~> 1.0, >= 1.0.2)
|
184
|
-
actionview (5.
|
185
|
-
activesupport (= 5.
|
188
|
+
actionview (5.2.0)
|
189
|
+
activesupport (= 5.2.0)
|
186
190
|
builder (~> 3.1)
|
187
191
|
erubi (~> 1.4)
|
188
192
|
rails-dom-testing (~> 2.0)
|
@@ -190,25 +194,29 @@ GEM
|
|
190
194
|
active_link_to (1.0.5)
|
191
195
|
actionpack
|
192
196
|
addressable
|
193
|
-
activejob (5.
|
194
|
-
activesupport (= 5.
|
197
|
+
activejob (5.2.0)
|
198
|
+
activesupport (= 5.2.0)
|
195
199
|
globalid (>= 0.3.6)
|
196
|
-
activemodel (5.
|
197
|
-
activesupport (= 5.
|
198
|
-
activerecord (5.
|
199
|
-
activemodel (= 5.
|
200
|
-
activesupport (= 5.
|
201
|
-
arel (
|
202
|
-
|
200
|
+
activemodel (5.2.0)
|
201
|
+
activesupport (= 5.2.0)
|
202
|
+
activerecord (5.2.0)
|
203
|
+
activemodel (= 5.2.0)
|
204
|
+
activesupport (= 5.2.0)
|
205
|
+
arel (>= 9.0)
|
206
|
+
activestorage (5.2.0)
|
207
|
+
actionpack (= 5.2.0)
|
208
|
+
activerecord (= 5.2.0)
|
209
|
+
marcel (~> 0.3.1)
|
210
|
+
activesupport (5.2.0)
|
203
211
|
concurrent-ruby (~> 1.0, >= 1.0.2)
|
204
212
|
i18n (>= 0.7, < 2)
|
205
213
|
minitest (~> 5.1)
|
206
214
|
tzinfo (~> 1.1)
|
207
215
|
addressable (2.5.2)
|
208
216
|
public_suffix (>= 2.0.2, < 4.0)
|
209
|
-
arel (
|
217
|
+
arel (9.0.0)
|
210
218
|
ast (2.4.0)
|
211
|
-
autoprefixer-rails (8.6.
|
219
|
+
autoprefixer-rails (8.6.0)
|
212
220
|
execjs
|
213
221
|
axiom-types (0.1.1)
|
214
222
|
descendants_tracker (~> 0.0.4)
|
@@ -230,14 +238,13 @@ GEM
|
|
230
238
|
bindex (0.5.0)
|
231
239
|
builder (3.2.3)
|
232
240
|
byebug (10.0.0)
|
233
|
-
|
234
|
-
capybara (2.18.0)
|
241
|
+
capybara (3.2.1)
|
235
242
|
addressable
|
236
243
|
mini_mime (>= 0.1.3)
|
237
|
-
nokogiri (
|
238
|
-
rack (>= 1.
|
239
|
-
rack-test (>= 0.
|
240
|
-
xpath (
|
244
|
+
nokogiri (~> 1.8)
|
245
|
+
rack (>= 1.6.0)
|
246
|
+
rack-test (>= 0.6.3)
|
247
|
+
xpath (~> 3.1)
|
241
248
|
carrierwave (1.2.2)
|
242
249
|
activemodel (>= 4.0.0)
|
243
250
|
activesupport (>= 4.0.0)
|
@@ -342,16 +349,15 @@ GEM
|
|
342
349
|
graphiql-rails (1.4.10)
|
343
350
|
railties
|
344
351
|
sprockets-rails
|
345
|
-
graphql (1.8.
|
352
|
+
graphql (1.8.1)
|
346
353
|
hashdiff (0.3.7)
|
347
354
|
hashie (3.5.7)
|
348
|
-
|
349
|
-
highline (2.0.0)
|
355
|
+
highline (1.7.10)
|
350
356
|
html_tokenizer (0.0.7)
|
351
357
|
htmlentities (4.3.4)
|
352
358
|
httparty (0.16.2)
|
353
359
|
multi_xml (>= 0.5.2)
|
354
|
-
i18n (1.0.
|
360
|
+
i18n (1.0.1)
|
355
361
|
concurrent-ruby (~> 1.0)
|
356
362
|
i18n-tasks (0.9.21)
|
357
363
|
activesupport (>= 4.0.2)
|
@@ -387,6 +393,7 @@ GEM
|
|
387
393
|
activerecord
|
388
394
|
kaminari-core (= 1.1.1)
|
389
395
|
kaminari-core (1.1.1)
|
396
|
+
kramdown (1.17.0)
|
390
397
|
launchy (2.4.3)
|
391
398
|
addressable (~> 2.3)
|
392
399
|
letter_opener (1.6.0)
|
@@ -404,14 +411,24 @@ GEM
|
|
404
411
|
nokogiri (>= 1.5.9)
|
405
412
|
mail (2.7.0)
|
406
413
|
mini_mime (>= 0.1.1)
|
414
|
+
marcel (0.3.2)
|
415
|
+
mimemagic (~> 0.3.2)
|
416
|
+
mdl (0.4.0)
|
417
|
+
kramdown (~> 1.12, >= 1.12.0)
|
418
|
+
mixlib-cli (~> 1.7, >= 1.7.0)
|
419
|
+
mixlib-config (~> 2.2, >= 2.2.1)
|
407
420
|
method_source (0.9.0)
|
408
421
|
mime-types (3.1)
|
409
422
|
mime-types-data (~> 3.2015)
|
410
423
|
mime-types-data (3.2016.0521)
|
424
|
+
mimemagic (0.3.2)
|
411
425
|
mini_magick (4.8.0)
|
412
426
|
mini_mime (1.0.0)
|
413
427
|
mini_portile2 (2.3.0)
|
414
428
|
minitest (5.11.3)
|
429
|
+
mixlib-cli (1.7.0)
|
430
|
+
mixlib-config (2.2.6)
|
431
|
+
tomlrb
|
415
432
|
multi_json (1.13.1)
|
416
433
|
multi_xml (0.6.0)
|
417
434
|
multipart-post (2.0.0)
|
@@ -444,16 +461,20 @@ GEM
|
|
444
461
|
omniauth-oauth (~> 1.1)
|
445
462
|
rack
|
446
463
|
orm_adapter (0.5.0)
|
447
|
-
paper_trail (
|
448
|
-
activerecord (>= 4.2, < 5.
|
464
|
+
paper_trail (9.1.1)
|
465
|
+
activerecord (>= 4.2, < 5.3)
|
449
466
|
request_store (~> 1.1)
|
450
467
|
parallel (1.12.1)
|
451
468
|
parser (2.5.1.0)
|
452
469
|
ast (~> 2.4.0)
|
453
470
|
pg (1.0.0)
|
471
|
+
pg_search (2.1.2)
|
472
|
+
activerecord (>= 4.2)
|
473
|
+
activesupport (>= 4.2)
|
474
|
+
arel (>= 6)
|
454
475
|
polyamorous (1.3.3)
|
455
476
|
activerecord (>= 3.0)
|
456
|
-
powerpack (0.1.
|
477
|
+
powerpack (0.1.1)
|
457
478
|
premailer (1.11.1)
|
458
479
|
addressable
|
459
480
|
css_parser (>= 1.6.0)
|
@@ -463,21 +484,24 @@ GEM
|
|
463
484
|
premailer (~> 1.7, >= 1.7.9)
|
464
485
|
public_suffix (3.0.2)
|
465
486
|
puma (3.11.3)
|
466
|
-
rack (2.0.
|
487
|
+
rack (2.0.5)
|
488
|
+
rack-attack (5.2.0)
|
489
|
+
rack
|
467
490
|
rack-cors (1.0.2)
|
468
491
|
rack-test (1.0.0)
|
469
492
|
rack (>= 1.0, < 3)
|
470
|
-
rails (5.
|
471
|
-
actioncable (= 5.
|
472
|
-
actionmailer (= 5.
|
473
|
-
actionpack (= 5.
|
474
|
-
actionview (= 5.
|
475
|
-
activejob (= 5.
|
476
|
-
activemodel (= 5.
|
477
|
-
activerecord (= 5.
|
478
|
-
|
493
|
+
rails (5.2.0)
|
494
|
+
actioncable (= 5.2.0)
|
495
|
+
actionmailer (= 5.2.0)
|
496
|
+
actionpack (= 5.2.0)
|
497
|
+
actionview (= 5.2.0)
|
498
|
+
activejob (= 5.2.0)
|
499
|
+
activemodel (= 5.2.0)
|
500
|
+
activerecord (= 5.2.0)
|
501
|
+
activestorage (= 5.2.0)
|
502
|
+
activesupport (= 5.2.0)
|
479
503
|
bundler (>= 1.3.0)
|
480
|
-
railties (= 5.
|
504
|
+
railties (= 5.2.0)
|
481
505
|
sprockets-rails (>= 2.0.0)
|
482
506
|
rails-controller-testing (1.0.2)
|
483
507
|
actionpack (~> 5.x, >= 5.0.1)
|
@@ -491,9 +515,9 @@ GEM
|
|
491
515
|
rails-i18n (5.1.1)
|
492
516
|
i18n (>= 0.7, < 2)
|
493
517
|
railties (>= 5.0, < 6)
|
494
|
-
railties (5.
|
495
|
-
actionpack (= 5.
|
496
|
-
activesupport (= 5.
|
518
|
+
railties (5.2.0)
|
519
|
+
actionpack (= 5.2.0)
|
520
|
+
activesupport (= 5.2.0)
|
497
521
|
method_source
|
498
522
|
rake (>= 0.8.7)
|
499
523
|
thor (>= 0.18.1, < 2.0)
|
@@ -556,7 +580,7 @@ GEM
|
|
556
580
|
rainbow (>= 2.2.2, < 4.0)
|
557
581
|
ruby-progressbar (~> 1.7)
|
558
582
|
unicode-display_width (~> 1.0, >= 1.0.1)
|
559
|
-
rubocop-rspec (1.
|
583
|
+
rubocop-rspec (1.25.1)
|
560
584
|
rubocop (>= 0.53.0)
|
561
585
|
ruby-ole (1.2.12.1)
|
562
586
|
ruby-progressbar (1.9.0)
|
@@ -612,6 +636,7 @@ GEM
|
|
612
636
|
thread (0.2.2)
|
613
637
|
thread_safe (0.3.6)
|
614
638
|
tilt (2.0.8)
|
639
|
+
tomlrb (1.2.6)
|
615
640
|
truncato (0.7.10)
|
616
641
|
htmlentities (~> 4.3.1)
|
617
642
|
nokogiri (~> 1.8.0, >= 1.7.0)
|
@@ -640,7 +665,7 @@ GEM
|
|
640
665
|
addressable (>= 2.3.6)
|
641
666
|
crack (>= 0.3.2)
|
642
667
|
hashdiff
|
643
|
-
websocket-driver (0.
|
668
|
+
websocket-driver (0.7.0)
|
644
669
|
websocket-extensions (>= 0.1.0)
|
645
670
|
websocket-extensions (0.1.3)
|
646
671
|
wisper (2.0.0)
|
data/Rakefile
CHANGED
@@ -1,32 +1,3 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require "
|
4
|
-
require "rspec/core/rake_task"
|
5
|
-
require_relative "../lib/decidim/gem_manager"
|
6
|
-
|
7
|
-
RSpec::Core::RakeTask.new(:spec)
|
8
|
-
|
9
|
-
task default: :spec
|
10
|
-
|
11
|
-
desc "Installs all gems locally."
|
12
|
-
task :install_all do
|
13
|
-
Decidim::GemManager.run_all(
|
14
|
-
"gem build %name && mv %name-%version.gem ..",
|
15
|
-
include_root: false
|
16
|
-
)
|
17
|
-
|
18
|
-
Decidim::GemManager.new(File.expand_path("..", __dir__)).run(
|
19
|
-
"gem build %name && gem install *.gem"
|
20
|
-
)
|
21
|
-
end
|
22
|
-
|
23
|
-
desc "Uninstalls all gems locally."
|
24
|
-
task :uninstall_all do
|
25
|
-
Decidim::GemManager.run_all(
|
26
|
-
"gem uninstall %name -v %version --executables --force"
|
27
|
-
)
|
28
|
-
|
29
|
-
Decidim::GemManager.new(File.expand_path("..", __dir__)).run(
|
30
|
-
"rm decidim-*.gem"
|
31
|
-
)
|
32
|
-
end
|
3
|
+
require "decidim/dev/common_rake"
|
data/exe/decidim
CHANGED
@@ -1,6 +1,12 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
# frozen_string_literal: true
|
3
3
|
|
4
|
+
if File.exist?(File.expand_path("../../.git", __dir__))
|
5
|
+
ENV["RUBYOPT"] = ENV["RUBYOPT"].sub("-rsimplecov ", "")
|
6
|
+
|
7
|
+
gem "decidim-core"
|
8
|
+
end
|
9
|
+
|
4
10
|
if ARGV[0] == "--component"
|
5
11
|
ARGV.replace(["component", *ARGV[1..-1]])
|
6
12
|
|
@@ -59,7 +59,7 @@ module Decidim
|
|
59
59
|
|
60
60
|
class_option :demo, type: :boolean,
|
61
61
|
default: false,
|
62
|
-
desc: "Generate
|
62
|
+
desc: "Generate demo authorization handlers"
|
63
63
|
|
64
64
|
def database_yml
|
65
65
|
template "database.yml.erb", "config/database.yml", force: true
|
@@ -115,6 +115,24 @@ module Decidim
|
|
115
115
|
Bundler.with_original_env { run "bundle install" }
|
116
116
|
end
|
117
117
|
|
118
|
+
def tweak_bootsnap
|
119
|
+
gsub_file "config/boot.rb", %r{require 'bootsnap/setup'.*$}, <<~RUBY.rstrip
|
120
|
+
require "bootsnap"
|
121
|
+
|
122
|
+
env = ENV["RAILS_ENV"] || "development"
|
123
|
+
|
124
|
+
Bootsnap.setup(
|
125
|
+
cache_dir: File.expand_path(File.join("..", "tmp", "cache"), __dir__),
|
126
|
+
development_mode: env == "development",
|
127
|
+
load_path_cache: true,
|
128
|
+
autoload_paths_cache: true,
|
129
|
+
disable_trace: true,
|
130
|
+
compile_cache_iseq: false,
|
131
|
+
compile_cache_yaml: true
|
132
|
+
)
|
133
|
+
RUBY
|
134
|
+
end
|
135
|
+
|
118
136
|
def add_ignore_uploads
|
119
137
|
append_file ".gitignore", "\n# Ignore public uploads\npublic/uploads" unless options["skip_git"]
|
120
138
|
end
|
@@ -127,7 +145,11 @@ module Decidim
|
|
127
145
|
def authorization_handler
|
128
146
|
copy_file "initializer.rb", "config/initializers/decidim.rb"
|
129
147
|
|
130
|
-
|
148
|
+
if options[:demo]
|
149
|
+
copy_file "dummy_authorization_handler.rb", "app/services/dummy_authorization_handler.rb"
|
150
|
+
copy_file "another_dummy_authorization_handler.rb", "app/services/another_dummy_authorization_handler.rb"
|
151
|
+
copy_file "verifications_initializer.rb", "config/initializers/decidim_verifications.rb"
|
152
|
+
end
|
131
153
|
end
|
132
154
|
|
133
155
|
def install
|
@@ -0,0 +1,24 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# An example implementation of an AuthorizationHandler to be used in tests.
|
4
|
+
class AnotherDummyAuthorizationHandler < Decidim::AuthorizationHandler
|
5
|
+
attribute :passport_number, String
|
6
|
+
attribute :postal_code, String
|
7
|
+
|
8
|
+
validates :passport_number, presence: true
|
9
|
+
validate :valid_passport_number
|
10
|
+
|
11
|
+
def metadata
|
12
|
+
super.merge(passport_number: passport_number, postal_code: postal_code)
|
13
|
+
end
|
14
|
+
|
15
|
+
def unique_id
|
16
|
+
passport_number
|
17
|
+
end
|
18
|
+
|
19
|
+
private
|
20
|
+
|
21
|
+
def valid_passport_number
|
22
|
+
errors.add(:passport_number, :invalid) unless passport_number.to_s.start_with?("A")
|
23
|
+
end
|
24
|
+
end
|
@@ -24,5 +24,8 @@ end
|
|
24
24
|
# }
|
25
25
|
# config.fog_directory = 'name_of_directory' # required
|
26
26
|
# config.fog_public = false # optional, defaults to true
|
27
|
-
# config.fog_attributes = {
|
27
|
+
# config.fog_attributes = {
|
28
|
+
# 'Cache-Control' => "max-age=#{365.day.to_i}",
|
29
|
+
# 'X-Content-Type-Options' => "nosniff"
|
30
|
+
# }
|
28
31
|
# end
|
@@ -1,4 +1,4 @@
|
|
1
|
-
# PostgreSQL. Versions 9.
|
1
|
+
# PostgreSQL. Versions 9.5 and up are supported.
|
2
2
|
#
|
3
3
|
# Install the pg driver:
|
4
4
|
# gem install pg
|
@@ -28,7 +28,7 @@ default: &default
|
|
28
28
|
|
29
29
|
development:
|
30
30
|
<<: *default
|
31
|
-
database:
|
31
|
+
database: <%= app_name %>_development
|
32
32
|
|
33
33
|
# The specified database role being used to connect to postgres.
|
34
34
|
# To create additional roles in postgres see `$ createuser --help`.
|
@@ -62,7 +62,7 @@ development:
|
|
62
62
|
# Do not set this db to the same as development or production.
|
63
63
|
test:
|
64
64
|
<<: *default
|
65
|
-
database:
|
65
|
+
database: <%= app_name %>_test
|
66
66
|
|
67
67
|
# As with config/secrets.yml, you never want to store sensitive information,
|
68
68
|
# like your database password, in your source code. If your source code is
|
@@ -0,0 +1,107 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# An example authorization handler used so that users can be verified against
|
4
|
+
# third party systems.
|
5
|
+
#
|
6
|
+
# You should probably rename this class and file to match your needs.
|
7
|
+
#
|
8
|
+
# If you need a custom form to be rendered, you can create a file matching the
|
9
|
+
# class name named "_form".
|
10
|
+
#
|
11
|
+
# Example:
|
12
|
+
#
|
13
|
+
# A handler named Decidim::CensusHandler would look for its partial in:
|
14
|
+
# decidim/census/form
|
15
|
+
#
|
16
|
+
# When testing your authorization handler, add this line to be sure it has a
|
17
|
+
# valid public api:
|
18
|
+
#
|
19
|
+
# it_behaves_like "an authorization handler"
|
20
|
+
#
|
21
|
+
# See Decidim::AuthorizationHandler for more documentation.
|
22
|
+
class DummyAuthorizationHandler < Decidim::AuthorizationHandler
|
23
|
+
# Define the attributes you need for this authorization handler. Attributes
|
24
|
+
# are defined using Virtus.
|
25
|
+
#
|
26
|
+
attribute :document_number, String
|
27
|
+
attribute :postal_code, String
|
28
|
+
attribute :birthday, Date
|
29
|
+
|
30
|
+
# You can (and should) also define validations on each attribute:
|
31
|
+
#
|
32
|
+
validates :document_number, presence: true
|
33
|
+
|
34
|
+
# You can also define custom validations:
|
35
|
+
#
|
36
|
+
validate :valid_document_number
|
37
|
+
|
38
|
+
# The only method that needs to be implemented for an authorization handler.
|
39
|
+
# Here you can add your business logic to check if the authorization should
|
40
|
+
# be created or not, you should return a Boolean value.
|
41
|
+
#
|
42
|
+
# Note that if you set some validations and overwrite this method, then the
|
43
|
+
# validations will not run, so it's easier to remove this method and rewrite
|
44
|
+
# your logic using ActiveModel validations.
|
45
|
+
#
|
46
|
+
# def valid?
|
47
|
+
# raise NotImplementedError
|
48
|
+
# end
|
49
|
+
|
50
|
+
# If set, enforces the handler to validate the uniqueness of the field
|
51
|
+
#
|
52
|
+
def unique_id
|
53
|
+
document_number
|
54
|
+
end
|
55
|
+
|
56
|
+
# If you need to store any of the defined attributes in the authorization you
|
57
|
+
# can do it here.
|
58
|
+
#
|
59
|
+
# You must return a Hash that will be serialized to the authorization when
|
60
|
+
# it's created, and available though authorization.metadata
|
61
|
+
#
|
62
|
+
def metadata
|
63
|
+
super.merge(document_number: document_number, postal_code: postal_code)
|
64
|
+
end
|
65
|
+
|
66
|
+
private
|
67
|
+
|
68
|
+
def valid_document_number
|
69
|
+
errors.add(:document_number, :invalid) unless document_number.to_s.end_with?("X")
|
70
|
+
end
|
71
|
+
|
72
|
+
# If you need custom authorization logic, you can implement your own action
|
73
|
+
# authorizer. In this case, it allows to set a list of valid postal codes for
|
74
|
+
# an authorization.
|
75
|
+
class ActionAuthorizer < Decidim::Verifications::DefaultActionAuthorizer
|
76
|
+
attr_reader :allowed_postal_codes
|
77
|
+
|
78
|
+
# Overrides the parent class method, but it still uses it to keep the base behavior
|
79
|
+
def authorize
|
80
|
+
# Remove the additional setting from the options hash to avoid to be considered missing.
|
81
|
+
@allowed_postal_codes ||= options.delete("allowed_postal_codes")
|
82
|
+
|
83
|
+
status_code, data = *super
|
84
|
+
|
85
|
+
if allowed_postal_codes.present?
|
86
|
+
# Does not authorize users with different postal codes
|
87
|
+
if status_code == :ok && !allowed_postal_codes.member?(authorization.metadata["postal_code"])
|
88
|
+
status_code = :unauthorized
|
89
|
+
data[:fields] = { "postal_code" => authorization.metadata["postal_code"] }
|
90
|
+
end
|
91
|
+
|
92
|
+
# Adds an extra message for inform the user the additional restriction for this authorization
|
93
|
+
data[:extra_explanation] = { key: "extra_explanation",
|
94
|
+
params: { scope: "decidim.verifications.dummy_authorization",
|
95
|
+
count: allowed_postal_codes.count,
|
96
|
+
postal_codes: allowed_postal_codes.join(", ") } }
|
97
|
+
end
|
98
|
+
|
99
|
+
[status_code, data]
|
100
|
+
end
|
101
|
+
|
102
|
+
# Adds the list of allowed postal codes to the redirect URL, to allow forms to inform about it
|
103
|
+
def redirect_params
|
104
|
+
{ "postal_codes" => allowed_postal_codes&.join("-") }
|
105
|
+
end
|
106
|
+
end
|
107
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
Decidim::Verifications.register_workflow(:dummy_authorization_handler) do |workflow|
|
4
|
+
workflow.form = "DummyAuthorizationHandler"
|
5
|
+
workflow.action_authorizer = "DummyAuthorizationHandler::ActionAuthorizer"
|
6
|
+
workflow.expires_in = 1.hour
|
7
|
+
|
8
|
+
workflow.options do |options|
|
9
|
+
options.attribute :postal_code, type: :string, default: "08001", required: false
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
Decidim::Verifications.register_workflow(:another_dummy_authorization_handler) do |workflow|
|
14
|
+
workflow.form = "AnotherDummyAuthorizationHandler"
|
15
|
+
workflow.expires_in = 1.hour
|
16
|
+
|
17
|
+
workflow.options do |options|
|
18
|
+
options.attribute :passport_number, type: :string, required: false
|
19
|
+
end
|
20
|
+
end
|
@@ -39,8 +39,6 @@ module Decidim
|
|
39
39
|
template "app/controllers/decidim/component/admin/application_controller.rb.erb", "#{app_folder}/controllers/decidim/#{component_name}/admin/application_controller.rb"
|
40
40
|
template "app/helpers/decidim/component/application_helper.rb.erb", "#{app_folder}/helpers/decidim/#{component_name}/application_helper.rb"
|
41
41
|
template "app/models/decidim/component/application_record.rb.erb", "#{app_folder}/models/decidim/#{component_name}/application_record.rb"
|
42
|
-
template "app/models/decidim/component/abilities/admin/admin_ability.rb.erb", "#{app_folder}/models/decidim/#{component_name}/abilities/admin/admin_ability.rb"
|
43
|
-
template "app/models/decidim/component/abilities/current_user_ability.rb.erb", "#{app_folder}/models/decidim/#{component_name}/abilities/current_user_ability.rb"
|
44
42
|
|
45
43
|
bin_folder = "#{component_folder}/bin"
|
46
44
|
template "bin/rails.erb", "#{bin_folder}/rails"
|
@@ -18,12 +18,6 @@ module Decidim
|
|
18
18
|
# root to: "<%= component_name %>#index"
|
19
19
|
end
|
20
20
|
|
21
|
-
initializer "decidim_<%= component_name %>.inject_abilities_to_user" do |_app|
|
22
|
-
Decidim.configure do |config|
|
23
|
-
config.admin_abilities += ["Decidim::<%= component_module_name %>::Abilities::Admin::AdminAbility"]
|
24
|
-
end
|
25
|
-
end
|
26
|
-
|
27
21
|
def load_seed
|
28
22
|
nil
|
29
23
|
end
|
@@ -24,7 +24,7 @@ Decidim.register_component(:<%= component_name %>) do |component|
|
|
24
24
|
# # Add your settings per step
|
25
25
|
# end
|
26
26
|
|
27
|
-
# component.register_resource do |resource|
|
27
|
+
# component.register_resource(:some_resource) do |resource|
|
28
28
|
# # Register a optional resource that can be references from other resources.
|
29
29
|
# resource.model_class_name = "Decidim::<%= component_module_name %>::SomeResource"
|
30
30
|
# resource.template = "decidim/<%= component_name %>/some_resources/linked_some_resources"
|
@@ -18,12 +18,6 @@ module Decidim
|
|
18
18
|
initializer "decidim_<%= component_name %>.assets" do |app|
|
19
19
|
app.config.assets.precompile += %w[decidim_<%= component_name %>_manifest.js decidim_<%= component_name %>_manifest.css]
|
20
20
|
end
|
21
|
-
|
22
|
-
initializer "decidim_<%= component_name %>.inject_abilities_to_user" do |_app|
|
23
|
-
Decidim.configure do |config|
|
24
|
-
config.abilities += ["Decidim::<%= component_module_name %>::Abilities::CurrentUserAbility"]
|
25
|
-
end
|
26
|
-
end
|
27
21
|
end
|
28
22
|
end
|
29
23
|
end
|
@@ -103,19 +103,17 @@ module Decidim
|
|
103
103
|
end
|
104
104
|
|
105
105
|
def copy_migrations
|
106
|
-
rails "
|
106
|
+
rails "decidim:upgrade"
|
107
107
|
recreate_db if options[:recreate_db]
|
108
108
|
end
|
109
109
|
|
110
110
|
def letter_opener_web
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
| end
|
116
|
-
RUBY
|
111
|
+
route <<~RUBY
|
112
|
+
if Rails.env.development?
|
113
|
+
mount LetterOpenerWeb::Engine, at: "/letter_opener"
|
114
|
+
end
|
117
115
|
|
118
|
-
|
116
|
+
RUBY
|
119
117
|
|
120
118
|
inject_into_file "config/environments/development.rb",
|
121
119
|
after: "config.action_mailer.raise_delivery_errors = false" do
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: decidim-generators
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.12.0.pre
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Josep Jaume Rey Peroy
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: exe
|
12
12
|
cert_chain: []
|
13
|
-
date: 2018-06-
|
13
|
+
date: 2018-06-06 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: decidim-core
|
@@ -18,14 +18,14 @@ dependencies:
|
|
18
18
|
requirements:
|
19
19
|
- - '='
|
20
20
|
- !ruby/object:Gem::Version
|
21
|
-
version: 0.
|
21
|
+
version: 0.12.0.pre
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
24
|
version_requirements: !ruby/object:Gem::Requirement
|
25
25
|
requirements:
|
26
26
|
- - '='
|
27
27
|
- !ruby/object:Gem::Version
|
28
|
-
version: 0.
|
28
|
+
version: 0.12.0.pre
|
29
29
|
- !ruby/object:Gem::Dependency
|
30
30
|
name: bundler
|
31
31
|
requirement: !ruby/object:Gem::Requirement
|
@@ -58,16 +58,18 @@ files:
|
|
58
58
|
- lib/decidim/generators/app_generator.rb
|
59
59
|
- lib/decidim/generators/app_templates/Dockerfile.erb
|
60
60
|
- lib/decidim/generators/app_templates/README.md.erb
|
61
|
+
- lib/decidim/generators/app_templates/another_dummy_authorization_handler.rb
|
61
62
|
- lib/decidim/generators/app_templates/cable.yml.erb
|
62
63
|
- lib/decidim/generators/app_templates/carrierwave.rb
|
63
64
|
- lib/decidim/generators/app_templates/database.yml.erb
|
64
65
|
- lib/decidim/generators/app_templates/decidim.scss.erb
|
65
66
|
- lib/decidim/generators/app_templates/decidim_controller.rb.erb
|
66
67
|
- lib/decidim/generators/app_templates/docker-compose.yml.erb
|
67
|
-
- lib/decidim/generators/app_templates/
|
68
|
+
- lib/decidim/generators/app_templates/dummy_authorization_handler.rb
|
68
69
|
- lib/decidim/generators/app_templates/initializer.rb
|
69
70
|
- lib/decidim/generators/app_templates/secrets.yml.erb
|
70
71
|
- lib/decidim/generators/app_templates/social_share_button.rb
|
72
|
+
- lib/decidim/generators/app_templates/verifications_initializer.rb
|
71
73
|
- lib/decidim/generators/component_generator.rb
|
72
74
|
- lib/decidim/generators/component_templates/Gemfile.erb
|
73
75
|
- lib/decidim/generators/component_templates/LICENSE-AGPLv3.txt
|
@@ -78,8 +80,6 @@ files:
|
|
78
80
|
- lib/decidim/generators/component_templates/app/controllers/decidim/component/admin/application_controller.rb.erb
|
79
81
|
- lib/decidim/generators/component_templates/app/controllers/decidim/component/application_controller.rb.erb
|
80
82
|
- lib/decidim/generators/component_templates/app/helpers/decidim/component/application_helper.rb.erb
|
81
|
-
- lib/decidim/generators/component_templates/app/models/decidim/component/abilities/admin/admin_ability.rb.erb
|
82
|
-
- lib/decidim/generators/component_templates/app/models/decidim/component/abilities/current_user_ability.rb.erb
|
83
83
|
- lib/decidim/generators/component_templates/app/models/decidim/component/application_record.rb.erb
|
84
84
|
- lib/decidim/generators/component_templates/bin/rails.erb
|
85
85
|
- lib/decidim/generators/component_templates/config/i18n-tasks.yml.erb
|
@@ -111,9 +111,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
111
111
|
version: '2.3'
|
112
112
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
113
113
|
requirements:
|
114
|
-
- - "
|
114
|
+
- - ">"
|
115
115
|
- !ruby/object:Gem::Version
|
116
|
-
version:
|
116
|
+
version: 1.3.1
|
117
117
|
requirements: []
|
118
118
|
rubyforge_project:
|
119
119
|
rubygems_version: 2.7.6
|
@@ -1,55 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
# An example authorization handler used so that users can be verified against
|
4
|
-
# third party systems.
|
5
|
-
#
|
6
|
-
# You should probably rename this class and file to match your needs.
|
7
|
-
#
|
8
|
-
# If you need a custom form to be rendered, you can create a file matching the
|
9
|
-
# class name named "_form".
|
10
|
-
#
|
11
|
-
# Example:
|
12
|
-
#
|
13
|
-
# A handler named Decidim::CensusHandler would look for its partial in:
|
14
|
-
# decidim/census/form
|
15
|
-
#
|
16
|
-
# When testing your authorization handler, add this line to be sure it has a
|
17
|
-
# valid public api:
|
18
|
-
#
|
19
|
-
# it_behaves_like "an authorization handler"
|
20
|
-
#
|
21
|
-
# See Decidim::AuthorizationHandler for more documentation.
|
22
|
-
class ExampleAuthorizationHandler < Decidim::AuthorizationHandler
|
23
|
-
# Define the attributes you need for this authorization handler. Attributes
|
24
|
-
# are defined using Virtus.
|
25
|
-
#
|
26
|
-
# Example:
|
27
|
-
# attribute :document_number, String
|
28
|
-
# attribute :birthday, Date
|
29
|
-
#
|
30
|
-
# You can (and should) also define validations on each attribute:
|
31
|
-
#
|
32
|
-
# validates :document_number, presence: true
|
33
|
-
# validate :custom_method_to_validate_an_attribute
|
34
|
-
|
35
|
-
# The only method that needs to be implemented for an authorization handler.
|
36
|
-
# Here you can add your business logic to check if the authorization should
|
37
|
-
# be created or not, you should return a Boolean value.
|
38
|
-
#
|
39
|
-
# Note that if you set some validations and overwrite this method, then the
|
40
|
-
# validations will not run, so it's easier to remove this method and rewrite
|
41
|
-
# your logic using ActiveModel validations.
|
42
|
-
def valid?
|
43
|
-
raise NotImplementedError
|
44
|
-
end
|
45
|
-
|
46
|
-
# If you need to store any of the defined attributes in the authorization you
|
47
|
-
# can do it here.
|
48
|
-
#
|
49
|
-
# You must return a Hash that will be serialized to the authorization when
|
50
|
-
# it's created, and available though authorization.metadata
|
51
|
-
#
|
52
|
-
# def metadata
|
53
|
-
# {}
|
54
|
-
# end
|
55
|
-
end
|
@@ -1,17 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Decidim
|
4
|
-
module <%= component_module_name %>
|
5
|
-
module Abilities
|
6
|
-
module Admin
|
7
|
-
# Defines the abilities related to <%= component_name %> for a logged in admin user.
|
8
|
-
# Intended to be used with `cancancan`.
|
9
|
-
class AdminAbility < Decidim::Abilities::AdminAbility
|
10
|
-
def define_abilities
|
11
|
-
# can :manage, SomeResource
|
12
|
-
end
|
13
|
-
end
|
14
|
-
end
|
15
|
-
end
|
16
|
-
end
|
17
|
-
end
|
@@ -1,47 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Decidim
|
4
|
-
module <%= component_module_name %>
|
5
|
-
module Abilities
|
6
|
-
# Defines the abilities related to <%= component_name %> for a logged in user.
|
7
|
-
# Intended to be used with `cancancan`.
|
8
|
-
class CurrentUserAbility
|
9
|
-
include CanCan::Ability
|
10
|
-
|
11
|
-
attr_reader :user, :context
|
12
|
-
|
13
|
-
def initialize(user, context)
|
14
|
-
return unless user
|
15
|
-
|
16
|
-
@user = user
|
17
|
-
@context = context
|
18
|
-
|
19
|
-
# can :manage, SomeResource if authorized?(:some_action)
|
20
|
-
end
|
21
|
-
|
22
|
-
private
|
23
|
-
|
24
|
-
def authorized?(action)
|
25
|
-
return unless component
|
26
|
-
|
27
|
-
ActionAuthorizer.new(user, component, action).authorize.ok?
|
28
|
-
end
|
29
|
-
|
30
|
-
def current_settings
|
31
|
-
context.fetch(:current_settings, nil)
|
32
|
-
end
|
33
|
-
|
34
|
-
def component_settings
|
35
|
-
context.fetch(:component_settings, nil)
|
36
|
-
end
|
37
|
-
|
38
|
-
def component
|
39
|
-
component = context.fetch(:current_component, nil)
|
40
|
-
return nil unless component && component.manifest.name == :<%= component_name %>
|
41
|
-
|
42
|
-
component
|
43
|
-
end
|
44
|
-
end
|
45
|
-
end
|
46
|
-
end
|
47
|
-
end
|