decidim-participatory_documents 0.2.1 → 0.2.2
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/.github/workflows/test.yml +7 -0
- data/Gemfile.lock +90 -88
- data/README.md +11 -1
- data/app/cells/decidim/participatory_documents/suggestion/admin_answer.erb +1 -1
- data/app/commands/decidim/participatory_documents/admin/create_document.rb +6 -2
- data/app/controllers/decidim/participatory_documents/admin/documents_controller.rb +1 -1
- data/app/controllers/decidim/participatory_documents/admin/suggestions_controller.rb +9 -1
- data/app/controllers/decidim/participatory_documents/admin/valuation_assignments_controller.rb +8 -2
- data/app/forms/decidim/participatory_documents/admin/document_form.rb +7 -0
- data/app/models/decidim/participatory_documents/document.rb +11 -0
- data/app/permissions/decidim/participatory_documents/admin/permissions.rb +3 -11
- data/app/views/decidim/participatory_documents/admin/documents/edit_pdf.html.erb +1 -0
- data/app/views/decidim/participatory_documents/admin/suggestions/_add_valuators.html.erb +1 -1
- data/app/views/decidim/participatory_documents/admin/suggestions/_valuators.html.erb +1 -2
- data/app/views/decidim/participatory_documents/documents/index.html.erb +2 -2
- data/config/locales/ca.yml +147 -145
- data/config/locales/de.yml +2 -0
- data/config/locales/en.yml +2 -0
- data/config/locales/es.yml +148 -146
- data/lib/decidim/participatory_documents/version.rb +2 -2
- data/lib/decidim/participatory_documents.rb +4 -0
- 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: d15ab2a26c0e881ac9828a12577a6eab25ba5bf170f19d35401c9a7c878e66e5
|
|
4
|
+
data.tar.gz: aa488aea6b962f8442807ad0d7e74f87c3a08eee861f584c0015e03dc21c13a6
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: ca9cd0de450e692d5ea0b05d2fe2f7a19ecb43fc9e3aed8b465b6a1e8a38692782f319d31828bc23b3ddd528fe880626e973a3ed1e72c4bb776a10e5686c111b
|
|
7
|
+
data.tar.gz: aac05750446931a873b85b1851b0a12d089a07c7ba07d55d21ef9abc82159a72ba1be70cdf3104388e1156ca8ab2b65fcae8ab34f26dffa4474746eb6fcf0b12
|
data/.github/workflows/test.yml
CHANGED
|
@@ -36,6 +36,13 @@ jobs:
|
|
|
36
36
|
- uses: actions/checkout@v4
|
|
37
37
|
with:
|
|
38
38
|
fetch-depth: 1
|
|
39
|
+
- uses: nanasess/setup-chromedriver@v2
|
|
40
|
+
with:
|
|
41
|
+
chromedriver-version: 119.0.6045.105
|
|
42
|
+
|
|
43
|
+
- uses: nanasess/setup-chromedriver@v2
|
|
44
|
+
with:
|
|
45
|
+
chromedriver-version: 119.0.6045.105
|
|
39
46
|
|
|
40
47
|
- uses: ruby/setup-ruby@v1
|
|
41
48
|
with:
|
data/Gemfile.lock
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
PATH
|
|
2
2
|
remote: .
|
|
3
3
|
specs:
|
|
4
|
-
decidim-participatory_documents (0.2.
|
|
4
|
+
decidim-participatory_documents (0.2.2)
|
|
5
5
|
decidim-core (>= 0.27.0, < 0.28)
|
|
6
6
|
|
|
7
7
|
GEM
|
|
8
8
|
remote: https://rubygems.org/
|
|
9
9
|
specs:
|
|
10
|
+
abbrev (0.1.2)
|
|
10
11
|
actioncable (6.1.7.6)
|
|
11
12
|
actionpack (= 6.1.7.6)
|
|
12
13
|
activesupport (= 6.1.7.6)
|
|
@@ -159,53 +160,53 @@ GEM
|
|
|
159
160
|
db-query-matchers (0.10.0)
|
|
160
161
|
activesupport (>= 4.0, < 7)
|
|
161
162
|
rspec (~> 3.0)
|
|
162
|
-
decidim (0.27.
|
|
163
|
-
decidim-accountability (= 0.27.
|
|
164
|
-
decidim-admin (= 0.27.
|
|
165
|
-
decidim-api (= 0.27.
|
|
166
|
-
decidim-assemblies (= 0.27.
|
|
167
|
-
decidim-blogs (= 0.27.
|
|
168
|
-
decidim-budgets (= 0.27.
|
|
169
|
-
decidim-comments (= 0.27.
|
|
170
|
-
decidim-core (= 0.27.
|
|
171
|
-
decidim-debates (= 0.27.
|
|
172
|
-
decidim-forms (= 0.27.
|
|
173
|
-
decidim-generators (= 0.27.
|
|
174
|
-
decidim-meetings (= 0.27.
|
|
175
|
-
decidim-pages (= 0.27.
|
|
176
|
-
decidim-participatory_processes (= 0.27.
|
|
177
|
-
decidim-proposals (= 0.27.
|
|
178
|
-
decidim-sortitions (= 0.27.
|
|
179
|
-
decidim-surveys (= 0.27.
|
|
180
|
-
decidim-system (= 0.27.
|
|
181
|
-
decidim-templates (= 0.27.
|
|
182
|
-
decidim-verifications (= 0.27.
|
|
183
|
-
decidim-accountability (0.27.
|
|
184
|
-
decidim-comments (= 0.27.
|
|
185
|
-
decidim-core (= 0.27.
|
|
186
|
-
decidim-admin (0.27.
|
|
163
|
+
decidim (0.27.5)
|
|
164
|
+
decidim-accountability (= 0.27.5)
|
|
165
|
+
decidim-admin (= 0.27.5)
|
|
166
|
+
decidim-api (= 0.27.5)
|
|
167
|
+
decidim-assemblies (= 0.27.5)
|
|
168
|
+
decidim-blogs (= 0.27.5)
|
|
169
|
+
decidim-budgets (= 0.27.5)
|
|
170
|
+
decidim-comments (= 0.27.5)
|
|
171
|
+
decidim-core (= 0.27.5)
|
|
172
|
+
decidim-debates (= 0.27.5)
|
|
173
|
+
decidim-forms (= 0.27.5)
|
|
174
|
+
decidim-generators (= 0.27.5)
|
|
175
|
+
decidim-meetings (= 0.27.5)
|
|
176
|
+
decidim-pages (= 0.27.5)
|
|
177
|
+
decidim-participatory_processes (= 0.27.5)
|
|
178
|
+
decidim-proposals (= 0.27.5)
|
|
179
|
+
decidim-sortitions (= 0.27.5)
|
|
180
|
+
decidim-surveys (= 0.27.5)
|
|
181
|
+
decidim-system (= 0.27.5)
|
|
182
|
+
decidim-templates (= 0.27.5)
|
|
183
|
+
decidim-verifications (= 0.27.5)
|
|
184
|
+
decidim-accountability (0.27.5)
|
|
185
|
+
decidim-comments (= 0.27.5)
|
|
186
|
+
decidim-core (= 0.27.5)
|
|
187
|
+
decidim-admin (0.27.5)
|
|
187
188
|
active_link_to (~> 1.0)
|
|
188
|
-
decidim-core (= 0.27.
|
|
189
|
+
decidim-core (= 0.27.5)
|
|
189
190
|
devise (~> 4.7)
|
|
190
191
|
devise-i18n (~> 1.2)
|
|
191
|
-
devise_invitable (~> 2.0)
|
|
192
|
-
decidim-api (0.27.
|
|
192
|
+
devise_invitable (~> 2.0, >= 2.0.9)
|
|
193
|
+
decidim-api (0.27.5)
|
|
193
194
|
graphql (~> 1.12, < 1.13)
|
|
194
195
|
graphql-docs (~> 2.1.0)
|
|
195
196
|
rack-cors (~> 1.0)
|
|
196
|
-
decidim-assemblies (0.27.
|
|
197
|
-
decidim-core (= 0.27.
|
|
198
|
-
decidim-blogs (0.27.
|
|
199
|
-
decidim-admin (= 0.27.
|
|
200
|
-
decidim-comments (= 0.27.
|
|
201
|
-
decidim-core (= 0.27.
|
|
202
|
-
decidim-budgets (0.27.
|
|
203
|
-
decidim-comments (= 0.27.
|
|
204
|
-
decidim-core (= 0.27.
|
|
205
|
-
decidim-comments (0.27.
|
|
206
|
-
decidim-core (= 0.27.
|
|
197
|
+
decidim-assemblies (0.27.5)
|
|
198
|
+
decidim-core (= 0.27.5)
|
|
199
|
+
decidim-blogs (0.27.5)
|
|
200
|
+
decidim-admin (= 0.27.5)
|
|
201
|
+
decidim-comments (= 0.27.5)
|
|
202
|
+
decidim-core (= 0.27.5)
|
|
203
|
+
decidim-budgets (0.27.5)
|
|
204
|
+
decidim-comments (= 0.27.5)
|
|
205
|
+
decidim-core (= 0.27.5)
|
|
206
|
+
decidim-comments (0.27.5)
|
|
207
|
+
decidim-core (= 0.27.5)
|
|
207
208
|
redcarpet (~> 3.5, >= 3.5.1)
|
|
208
|
-
decidim-core (0.27.
|
|
209
|
+
decidim-core (0.27.5)
|
|
209
210
|
active_link_to (~> 1.0)
|
|
210
211
|
acts_as_list (~> 0.9)
|
|
211
212
|
batch-loader (~> 1.2)
|
|
@@ -215,7 +216,7 @@ GEM
|
|
|
215
216
|
cells-rails (~> 0.1.3)
|
|
216
217
|
charlock_holmes (~> 0.7)
|
|
217
218
|
date_validator (~> 0.12.0)
|
|
218
|
-
decidim-api (= 0.27.
|
|
219
|
+
decidim-api (= 0.27.5)
|
|
219
220
|
devise (~> 4.7)
|
|
220
221
|
devise-i18n (~> 1.2)
|
|
221
222
|
diffy (~> 3.3)
|
|
@@ -256,15 +257,15 @@ GEM
|
|
|
256
257
|
webpacker (= 6.0.0.rc.5)
|
|
257
258
|
webpush (~> 1.1)
|
|
258
259
|
wisper (~> 2.0)
|
|
259
|
-
decidim-debates (0.27.
|
|
260
|
-
decidim-comments (= 0.27.
|
|
261
|
-
decidim-core (= 0.27.
|
|
262
|
-
decidim-dev (0.27.
|
|
260
|
+
decidim-debates (0.27.5)
|
|
261
|
+
decidim-comments (= 0.27.5)
|
|
262
|
+
decidim-core (= 0.27.5)
|
|
263
|
+
decidim-dev (0.27.5)
|
|
263
264
|
axe-core-rspec (~> 4.1.0)
|
|
264
265
|
byebug (~> 11.0)
|
|
265
266
|
capybara (~> 3.24)
|
|
266
267
|
db-query-matchers (~> 0.10.0)
|
|
267
|
-
decidim (= 0.27.
|
|
268
|
+
decidim (= 0.27.5)
|
|
268
269
|
erb_lint (~> 0.0.35)
|
|
269
270
|
factory_bot_rails (~> 4.8)
|
|
270
271
|
i18n-tasks (~> 0.9.18)
|
|
@@ -287,45 +288,45 @@ GEM
|
|
|
287
288
|
w3c_rspec_validators (~> 0.3.0)
|
|
288
289
|
webmock (~> 3.6)
|
|
289
290
|
wisper-rspec (~> 1.0)
|
|
290
|
-
decidim-forms (0.27.
|
|
291
|
-
decidim-core (= 0.27.
|
|
291
|
+
decidim-forms (0.27.5)
|
|
292
|
+
decidim-core (= 0.27.5)
|
|
292
293
|
wicked_pdf (~> 2.1)
|
|
293
294
|
wkhtmltopdf-binary (~> 0.12)
|
|
294
|
-
decidim-generators (0.27.
|
|
295
|
-
decidim-core (= 0.27.
|
|
296
|
-
decidim-meetings (0.27.
|
|
297
|
-
decidim-core (= 0.27.
|
|
298
|
-
decidim-forms (= 0.27.
|
|
295
|
+
decidim-generators (0.27.5)
|
|
296
|
+
decidim-core (= 0.27.5)
|
|
297
|
+
decidim-meetings (0.27.5)
|
|
298
|
+
decidim-core (= 0.27.5)
|
|
299
|
+
decidim-forms (= 0.27.5)
|
|
299
300
|
icalendar (~> 2.5)
|
|
300
|
-
decidim-pages (0.27.
|
|
301
|
-
decidim-core (= 0.27.
|
|
302
|
-
decidim-participatory_processes (0.27.
|
|
303
|
-
decidim-core (= 0.27.
|
|
304
|
-
decidim-proposals (0.27.
|
|
305
|
-
decidim-comments (= 0.27.
|
|
306
|
-
decidim-core (= 0.27.
|
|
301
|
+
decidim-pages (0.27.5)
|
|
302
|
+
decidim-core (= 0.27.5)
|
|
303
|
+
decidim-participatory_processes (0.27.5)
|
|
304
|
+
decidim-core (= 0.27.5)
|
|
305
|
+
decidim-proposals (0.27.5)
|
|
306
|
+
decidim-comments (= 0.27.5)
|
|
307
|
+
decidim-core (= 0.27.5)
|
|
307
308
|
doc2text (~> 0.4.5)
|
|
308
309
|
redcarpet (~> 3.5, >= 3.5.1)
|
|
309
|
-
decidim-sortitions (0.27.
|
|
310
|
-
decidim-admin (= 0.27.
|
|
311
|
-
decidim-comments (= 0.27.
|
|
312
|
-
decidim-core (= 0.27.
|
|
313
|
-
decidim-proposals (= 0.27.
|
|
314
|
-
decidim-surveys (0.27.
|
|
315
|
-
decidim-core (= 0.27.
|
|
316
|
-
decidim-forms (= 0.27.
|
|
317
|
-
decidim-templates (= 0.27.
|
|
318
|
-
decidim-system (0.27.
|
|
310
|
+
decidim-sortitions (0.27.5)
|
|
311
|
+
decidim-admin (= 0.27.5)
|
|
312
|
+
decidim-comments (= 0.27.5)
|
|
313
|
+
decidim-core (= 0.27.5)
|
|
314
|
+
decidim-proposals (= 0.27.5)
|
|
315
|
+
decidim-surveys (0.27.5)
|
|
316
|
+
decidim-core (= 0.27.5)
|
|
317
|
+
decidim-forms (= 0.27.5)
|
|
318
|
+
decidim-templates (= 0.27.5)
|
|
319
|
+
decidim-system (0.27.5)
|
|
319
320
|
active_link_to (~> 1.0)
|
|
320
|
-
decidim-core (= 0.27.
|
|
321
|
+
decidim-core (= 0.27.5)
|
|
321
322
|
devise (~> 4.7)
|
|
322
323
|
devise-i18n (~> 1.2)
|
|
323
|
-
devise_invitable (~> 2.0)
|
|
324
|
-
decidim-templates (0.27.
|
|
325
|
-
decidim-core (= 0.27.
|
|
326
|
-
decidim-forms (= 0.27.
|
|
327
|
-
decidim-verifications (0.27.
|
|
328
|
-
decidim-core (= 0.27.
|
|
324
|
+
devise_invitable (~> 2.0, >= 2.0.9)
|
|
325
|
+
decidim-templates (0.27.5)
|
|
326
|
+
decidim-core (= 0.27.5)
|
|
327
|
+
decidim-forms (= 0.27.5)
|
|
328
|
+
decidim-verifications (0.27.5)
|
|
329
|
+
decidim-core (= 0.27.5)
|
|
329
330
|
declarative-builder (0.1.0)
|
|
330
331
|
declarative-option (< 0.2.0)
|
|
331
332
|
declarative-option (0.1.0)
|
|
@@ -339,7 +340,7 @@ GEM
|
|
|
339
340
|
warden (~> 1.2.3)
|
|
340
341
|
devise-i18n (1.12.0)
|
|
341
342
|
devise (>= 4.9.0)
|
|
342
|
-
devise_invitable (2.0.
|
|
343
|
+
devise_invitable (2.0.9)
|
|
343
344
|
actionmailer (>= 5.0)
|
|
344
345
|
devise (>= 4.6)
|
|
345
346
|
diff-lcs (1.5.0)
|
|
@@ -412,7 +413,8 @@ GEM
|
|
|
412
413
|
sass (~> 3.4)
|
|
413
414
|
hashdiff (1.0.1)
|
|
414
415
|
hashie (5.0.0)
|
|
415
|
-
highline (
|
|
416
|
+
highline (3.0.0)
|
|
417
|
+
abbrev
|
|
416
418
|
hkdf (0.3.0)
|
|
417
419
|
html-pipeline (2.14.3)
|
|
418
420
|
activesupport (>= 2)
|
|
@@ -431,7 +433,7 @@ GEM
|
|
|
431
433
|
rails-i18n
|
|
432
434
|
rainbow (>= 2.2.2, < 4.0)
|
|
433
435
|
terminal-table (>= 1.5.1)
|
|
434
|
-
icalendar (2.
|
|
436
|
+
icalendar (2.10.1)
|
|
435
437
|
ice_cube (~> 0.16)
|
|
436
438
|
ice_cube (0.16.4)
|
|
437
439
|
ice_nine (0.11.2)
|
|
@@ -440,7 +442,7 @@ GEM
|
|
|
440
442
|
ruby-vips (>= 2.0.17, < 3)
|
|
441
443
|
invisible_captcha (0.13.0)
|
|
442
444
|
rails (>= 3.2.0)
|
|
443
|
-
json (2.
|
|
445
|
+
json (2.7.1)
|
|
444
446
|
jwt (2.7.1)
|
|
445
447
|
kaminari (1.2.2)
|
|
446
448
|
activesupport (>= 4.1.0)
|
|
@@ -571,7 +573,7 @@ GEM
|
|
|
571
573
|
net-smtp
|
|
572
574
|
premailer (~> 1.7, >= 1.7.9)
|
|
573
575
|
public_suffix (5.0.3)
|
|
574
|
-
puma (5.6.
|
|
576
|
+
puma (5.6.8)
|
|
575
577
|
nio4r (~> 2.0)
|
|
576
578
|
racc (1.7.1)
|
|
577
579
|
rack (2.2.8)
|
|
@@ -641,9 +643,9 @@ GEM
|
|
|
641
643
|
rspec-core (~> 3.12.0)
|
|
642
644
|
rspec-expectations (~> 3.12.0)
|
|
643
645
|
rspec-mocks (~> 3.12.0)
|
|
644
|
-
rspec-cells (0.3.
|
|
646
|
+
rspec-cells (0.3.9)
|
|
645
647
|
cells (>= 4.0.0, < 6.0.0)
|
|
646
|
-
rspec-rails (>= 3.0.0, < 6.
|
|
648
|
+
rspec-rails (>= 3.0.0, < 6.2.0)
|
|
647
649
|
rspec-core (3.12.2)
|
|
648
650
|
rspec-support (~> 3.12.0)
|
|
649
651
|
rspec-expectations (3.12.3)
|
|
@@ -800,8 +802,8 @@ DEPENDENCIES
|
|
|
800
802
|
bootsnap (~> 1.7)
|
|
801
803
|
byebug (~> 11.0)
|
|
802
804
|
codecov
|
|
803
|
-
decidim (= 0.27.
|
|
804
|
-
decidim-dev (= 0.27.
|
|
805
|
+
decidim (= 0.27.5)
|
|
806
|
+
decidim-dev (= 0.27.5)
|
|
805
807
|
decidim-participatory_documents!
|
|
806
808
|
faker (~> 2.14)
|
|
807
809
|
letter_opener_web (~> 1.3)
|
|
@@ -816,4 +818,4 @@ RUBY VERSION
|
|
|
816
818
|
ruby 3.0.6p216
|
|
817
819
|
|
|
818
820
|
BUNDLED WITH
|
|
819
|
-
2.
|
|
821
|
+
2.4.22
|
data/README.md
CHANGED
|
@@ -41,8 +41,10 @@ Depending on your Decidim version, you can choose the corresponding version to e
|
|
|
41
41
|
|
|
42
42
|
## Usage
|
|
43
43
|
|
|
44
|
-
|
|
44
|
+
This module adds a new component to Decidim called `Participatory Documents` that allows to upload PDFs and define areas on top of it that will become spaces for suggestions or comments.
|
|
45
45
|
|
|
46
|
+
The administrator must upload a PDF file and then define areas on top of it by drawing polygons.
|
|
47
|
+
Each area will become a new zone that will allow users to create suggestions.
|
|
46
48
|
|
|
47
49
|
## Configuration
|
|
48
50
|
|
|
@@ -66,6 +68,14 @@ Decidim::ParticipatoryDocuments.configure do |config|
|
|
|
66
68
|
end
|
|
67
69
|
```
|
|
68
70
|
|
|
71
|
+
## Antivirus compatibility
|
|
72
|
+
|
|
73
|
+
This module has a builtin compatibility with https://github.com/mainio/decidim-module-antivirus to scan the uploaded documents (it is also possible to directly use the gem https://github.com/mainio/ratonvirus if configuring it in a initializer).
|
|
74
|
+
|
|
75
|
+
If the antivirus is not installed, the module will still work but the documents will not be scanned.
|
|
76
|
+
|
|
77
|
+
> Note: this module only checks for the existance of the class `AntivirusValidator` so it is possible to use any other antivirus validator as well (a custom one for instance).
|
|
78
|
+
|
|
69
79
|
## Contributing
|
|
70
80
|
|
|
71
81
|
Bug reports and pull requests are welcome on GitHub at https://github.com/openpoke/decidim-module-participatory-documents.
|
|
@@ -21,8 +21,12 @@ module Decidim
|
|
|
21
21
|
create_document
|
|
22
22
|
end
|
|
23
23
|
broadcast(:ok, document)
|
|
24
|
-
rescue ActiveRecord::RecordInvalid
|
|
25
|
-
|
|
24
|
+
rescue ActiveRecord::RecordInvalid => e
|
|
25
|
+
if document&.errors&.include? :file
|
|
26
|
+
form.errors.add(:file, document.errors[:file])
|
|
27
|
+
else
|
|
28
|
+
form.errors.add(:file, e.message)
|
|
29
|
+
end
|
|
26
30
|
broadcast(:invalid)
|
|
27
31
|
end
|
|
28
32
|
end
|
|
@@ -11,7 +11,8 @@ module Decidim
|
|
|
11
11
|
helper Decidim::ParticipatoryDocuments::Admin::SuggestionHelper
|
|
12
12
|
helper Decidim::Messaging::ConversationHelper
|
|
13
13
|
|
|
14
|
-
helper_method :suggestions, :suggestion, :notes_form, :find_valuators_for_select, :suggestion_ids,
|
|
14
|
+
helper_method :suggestions, :suggestion, :notes_form, :find_valuators_for_select, :suggestion_ids,
|
|
15
|
+
:suggestion_find, :valuator_assigned_to_suggestion?
|
|
15
16
|
|
|
16
17
|
def show
|
|
17
18
|
enforce_permission_to :show, :suggestion, suggestion: suggestion
|
|
@@ -174,6 +175,13 @@ module Decidim
|
|
|
174
175
|
[valuator.name, role.id]
|
|
175
176
|
end
|
|
176
177
|
end
|
|
178
|
+
|
|
179
|
+
def valuator_assigned_to_suggestion?
|
|
180
|
+
@valuator_assigned_to_suggestion ||=
|
|
181
|
+
Decidim::ParticipatoryDocuments::ValuationAssignment
|
|
182
|
+
.where(suggestion: suggestion, valuator_role: valuator_roles)
|
|
183
|
+
.any?
|
|
184
|
+
end
|
|
177
185
|
end
|
|
178
186
|
end
|
|
179
187
|
end
|
data/app/controllers/decidim/participatory_documents/admin/valuation_assignments_controller.rb
CHANGED
|
@@ -4,8 +4,10 @@ module Decidim
|
|
|
4
4
|
module ParticipatoryDocuments
|
|
5
5
|
module Admin
|
|
6
6
|
class ValuationAssignmentsController < Admin::ApplicationController
|
|
7
|
+
helper_method :suggestion
|
|
8
|
+
|
|
7
9
|
def create
|
|
8
|
-
enforce_permission_to :assign_to_valuator, :suggestions
|
|
10
|
+
enforce_permission_to :assign_to_valuator, :suggestions, suggestion: suggestion
|
|
9
11
|
|
|
10
12
|
@form = form(Admin::ValuationAssignmentForm).from_params(params)
|
|
11
13
|
|
|
@@ -25,7 +27,7 @@ module Decidim
|
|
|
25
27
|
def destroy
|
|
26
28
|
@form = form(Admin::ValuationAssignmentForm).from_params(destroy_params)
|
|
27
29
|
|
|
28
|
-
enforce_permission_to :unassign_from_valuator, :suggestions, valuator: @form.valuator_user
|
|
30
|
+
enforce_permission_to :unassign_from_valuator, :suggestions, valuator: @form.valuator_user, suggestion: suggestion
|
|
29
31
|
|
|
30
32
|
Admin::UnassignSuggestionsFromValuator.call(@form) do
|
|
31
33
|
on(:ok) do |_proposal|
|
|
@@ -46,6 +48,10 @@ module Decidim
|
|
|
46
48
|
|
|
47
49
|
private
|
|
48
50
|
|
|
51
|
+
def suggestion
|
|
52
|
+
@suggestion ||= Decidim::ParticipatoryDocuments::Suggestion.find(params[:suggestion_ids] || [params[:suggestion_id]])
|
|
53
|
+
end
|
|
54
|
+
|
|
49
55
|
def destroy_params
|
|
50
56
|
{
|
|
51
57
|
id: params.dig(:valuator_role, :id) || params[:id],
|
|
@@ -14,16 +14,23 @@ module Decidim
|
|
|
14
14
|
|
|
15
15
|
attribute :box_color, String, default: "#1e98d7"
|
|
16
16
|
attribute :box_opacity, Integer, default: 12
|
|
17
|
+
attribute :organization
|
|
17
18
|
|
|
18
19
|
attribute :file, Decidim::Attributes::Blob
|
|
19
20
|
attribute :remove_file, Boolean, default: false
|
|
20
21
|
|
|
22
|
+
validates :file, passthru: { to: Document }, if: ->(form) { form.file.present? }
|
|
21
23
|
validates :file, file_content_type: { allow: ["application/pdf"] }
|
|
24
|
+
|
|
22
25
|
# ensure color and opacity are present
|
|
23
26
|
def map_model(doc)
|
|
24
27
|
self.box_color = doc.box_color.presence || "#1e98d7"
|
|
25
28
|
self.box_opacity = doc.box_opacity.presence || 12
|
|
26
29
|
end
|
|
30
|
+
|
|
31
|
+
def organization
|
|
32
|
+
attributes[:organization] || current_organization
|
|
33
|
+
end
|
|
27
34
|
end
|
|
28
35
|
end
|
|
29
36
|
end
|
|
@@ -17,6 +17,8 @@ module Decidim
|
|
|
17
17
|
|
|
18
18
|
has_one_attached :file
|
|
19
19
|
validates_upload :file, uploader: Decidim::ParticipatoryDocuments::PdfDocumentUploader
|
|
20
|
+
# compatibility with ratonvirus (see https://github.com/mainio/decidim-module-antivirus)
|
|
21
|
+
validates :file, antivirus: true if ParticipatoryDocuments.antivirus_enabled
|
|
20
22
|
|
|
21
23
|
has_many :sections, class_name: "Decidim::ParticipatoryDocuments::Section", dependent: :restrict_with_error
|
|
22
24
|
has_many :suggestions, class_name: "Decidim::ParticipatoryDocuments::Suggestion", dependent: :restrict_with_error, as: :suggestable
|
|
@@ -24,6 +26,15 @@ module Decidim
|
|
|
24
26
|
|
|
25
27
|
attr_accessor :remove_file
|
|
26
28
|
|
|
29
|
+
# the dynamic upload validator requires the organization,
|
|
30
|
+
# if the object is not created yet is assigned from the context by the UploadValidationForm using this method
|
|
31
|
+
attr_writer :organization
|
|
32
|
+
|
|
33
|
+
# override the delegate from HasComponent for the dynamic upload validator
|
|
34
|
+
def organization
|
|
35
|
+
component&.organization || @organization
|
|
36
|
+
end
|
|
37
|
+
|
|
27
38
|
def self.log_presenter_class_for(_log)
|
|
28
39
|
Decidim::ParticipatoryDocuments::AdminLog::DocumentPresenter
|
|
29
40
|
end
|
|
@@ -19,11 +19,11 @@ module Decidim
|
|
|
19
19
|
if valuator_assigned_to_suggestion?
|
|
20
20
|
can_create_suggestion_note?
|
|
21
21
|
can_create_suggestion_answer?
|
|
22
|
+
valuator_can_assign_or_unassign_valuator_from_suggestions?
|
|
22
23
|
allow! if action_is_show_on_suggestion?
|
|
23
24
|
elsif action_is_show_on_suggestion?
|
|
24
25
|
disallow!
|
|
25
26
|
end
|
|
26
|
-
valuator_can_unassign_valuator_from_suggestions?
|
|
27
27
|
end
|
|
28
28
|
|
|
29
29
|
def handle_general_permissions
|
|
@@ -84,16 +84,8 @@ module Decidim
|
|
|
84
84
|
permission_action.action == :create
|
|
85
85
|
end
|
|
86
86
|
|
|
87
|
-
def
|
|
88
|
-
allow! if permission_action.
|
|
89
|
-
end
|
|
90
|
-
|
|
91
|
-
def valuator_can_unassign_valuator_from_suggestions?
|
|
92
|
-
can_unassign_valuator_from_suggestions? if user == context.fetch(:valuator, nil)
|
|
93
|
-
|
|
94
|
-
return unless permission_action.action == :assign_to_valuator && permission_action.subject == :suggestions
|
|
95
|
-
|
|
96
|
-
allow!
|
|
87
|
+
def valuator_can_assign_or_unassign_valuator_from_suggestions?
|
|
88
|
+
allow! if permission_action.action == :unassign_from_valuator || permission_action.action == :assign_to_valuator
|
|
97
89
|
end
|
|
98
90
|
|
|
99
91
|
def admin_suggestion_answering_is_enabled?
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
<% if
|
|
1
|
+
<% if valuator_assigned_to_suggestion? || current_user.admin? %>
|
|
2
2
|
<div id="js-assign-suggestion-to-valuator-actions" class="form-single-suggestion"
|
|
3
3
|
style="max-width:400px">
|
|
4
4
|
<%= form_tag(document_valuation_assignment_path(document), method: :post, id: "js-form-assign-suggestion-to-valuator",
|
|
@@ -20,8 +20,7 @@
|
|
|
20
20
|
presented_valuator.profile_path,
|
|
21
21
|
target: :blank
|
|
22
22
|
) %>
|
|
23
|
-
|
|
24
|
-
<% if allowed_to? :unassign_from_valuator, :suggestions, valuator: assignment.valuator %>
|
|
23
|
+
<% if valuator_assigned_to_suggestion? || current_user.admin? %>
|
|
25
24
|
<%= icon_link_to(
|
|
26
25
|
"circle-x",
|
|
27
26
|
document_suggestion_valuation_assignment_path(document, suggestion, assignment.valuator_role),
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
<% if document.present? && document.file.attached? %>
|
|
2
2
|
<div class="row">
|
|
3
|
-
<%= content_tag(:h3, translated_attribute(document.title), class: "title") if translated_attribute(document.title).present? %>
|
|
4
|
-
<%= content_tag(:p, translated_attribute(document.description)
|
|
3
|
+
<%= content_tag(:h3, sanitize(translated_attribute(document.title)), class: "title") if translated_attribute(document.title).present? %>
|
|
4
|
+
<%= content_tag(:p, sanitize(translated_attribute(document.description)), class: "description") if translated_attribute(document.description).present? %>
|
|
5
5
|
<% if preview_mode? %>
|
|
6
6
|
<div class="callout announcement mb-sm warning cell-announcement">
|
|
7
7
|
<p class="heading5"><%= t("decidim.participatory_documents.documents.preview_title") %></p>
|