decidim-forms 0.31.4 → 0.31.6
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/commands/decidim/forms/response_questionnaire.rb +2 -2
- data/app/controllers/decidim/forms/admin/concerns/has_questionnaire.rb +10 -2
- data/app/forms/decidim/forms/questionnaire_form.rb +1 -1
- data/app/forms/decidim/forms/response_form.rb +7 -7
- data/app/views/decidim/forms/questionnaires/_questionnaire.html.erb +1 -1
- data/app/views/decidim/forms/questionnaires/responses/_files.html.erb +1 -1
- data/config/locales/ca-IT.yml +2 -2
- data/config/locales/ca.yml +2 -2
- data/config/locales/eu.yml +1 -1
- data/config/locales/sk.yml +182 -0
- data/db/data/20260616144141_rename_answers_to_responses.rb +31 -0
- data/lib/decidim/forms/test/shared_examples/questionnaire_admin_access.rb +95 -0
- data/lib/decidim/forms/test/shared_examples/questionnaire_admin_controller_permissions.rb +41 -0
- data/lib/decidim/forms/version.rb +1 -1
- metadata +11 -8
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 9f876821d13528d9c5c2295a65210f8892d31c035b5ff979369580028845b8ce
|
|
4
|
+
data.tar.gz: 35112840ecae63ba1ccbf64d3fcc11027ab1376f14cc92db3659ae5b77d4f935
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: d1a7634cb60b39ea11d2c7b6495045ff36ed956cc032400ccba6f4af8f898c66cae7944bb12d17406d50addae122643a766f5f6821884af0e9ffa551670b1797
|
|
7
|
+
data.tar.gz: 9e59083b34e23307b39502ffe0799b1e7db17bb93865082434dc789efbbdc9aa644099c5d09c7c8ed1eac028490e253ff0fcea9dd5fb1b57f73a50b251dd36ec
|
|
@@ -59,7 +59,7 @@ module Decidim
|
|
|
59
59
|
# of this problem.
|
|
60
60
|
def reset_form_attachments
|
|
61
61
|
@form.responses.each do |response|
|
|
62
|
-
response.errors.add(:
|
|
62
|
+
response.errors.add(:add_attachments, :needs_to_be_reattached) if response.has_attachments? || response.has_error_in_attachments?
|
|
63
63
|
end
|
|
64
64
|
end
|
|
65
65
|
|
|
@@ -116,7 +116,7 @@ module Decidim
|
|
|
116
116
|
end
|
|
117
117
|
|
|
118
118
|
create_attachments if process_attachments?
|
|
119
|
-
|
|
119
|
+
attachment_cleanup!
|
|
120
120
|
end
|
|
121
121
|
|
|
122
122
|
@form = @main_form
|
|
@@ -34,7 +34,7 @@ module Decidim
|
|
|
34
34
|
end
|
|
35
35
|
|
|
36
36
|
def edit
|
|
37
|
-
enforce_permission_to(:update,
|
|
37
|
+
enforce_permission_to(:update, permission_subject, questionnaire:)
|
|
38
38
|
|
|
39
39
|
@form = form(Admin::QuestionnaireForm).from_model(questionnaire)
|
|
40
40
|
|
|
@@ -42,7 +42,7 @@ module Decidim
|
|
|
42
42
|
end
|
|
43
43
|
|
|
44
44
|
def update
|
|
45
|
-
enforce_permission_to(:update,
|
|
45
|
+
enforce_permission_to(:update, permission_subject, questionnaire:)
|
|
46
46
|
|
|
47
47
|
@form = form(Admin::QuestionnaireForm).from_params(params)
|
|
48
48
|
|
|
@@ -62,6 +62,8 @@ module Decidim
|
|
|
62
62
|
end
|
|
63
63
|
|
|
64
64
|
def edit_questions
|
|
65
|
+
enforce_permission_to(:update, permission_subject, questionnaire:)
|
|
66
|
+
|
|
65
67
|
@form = form(Admin::QuestionsForm).from_model(questionnaire)
|
|
66
68
|
|
|
67
69
|
render template: edit_questions_template
|
|
@@ -70,6 +72,8 @@ module Decidim
|
|
|
70
72
|
# i18n-tasks-use t("decidim.forms.admin.questionnaires.questions_form.update.success")
|
|
71
73
|
# i18n-tasks-use t("decidim.forms.admin.questionnaires.update.invalid")
|
|
72
74
|
def update_questions
|
|
75
|
+
enforce_permission_to(:update, permission_subject, questionnaire:)
|
|
76
|
+
|
|
73
77
|
@form = form(Admin::QuestionsForm).from_params(params)
|
|
74
78
|
Admin::UpdateQuestions.call(@form, questionnaire) do
|
|
75
79
|
on(:ok) do
|
|
@@ -181,6 +185,10 @@ module Decidim
|
|
|
181
185
|
[condition_type, I18n.t("decidim.forms.admin.questionnaires.display_condition.condition_types.#{condition_type}")]
|
|
182
186
|
end
|
|
183
187
|
end
|
|
188
|
+
|
|
189
|
+
def permission_subject
|
|
190
|
+
:questionnaire
|
|
191
|
+
end
|
|
184
192
|
end
|
|
185
193
|
end
|
|
186
194
|
end
|
|
@@ -30,7 +30,7 @@ module Decidim
|
|
|
30
30
|
|
|
31
31
|
def add_responses!(questionnaire:, session_token:, ip_hash:)
|
|
32
32
|
self.responses = questionnaire.questions.map do |question|
|
|
33
|
-
ResponseForm.from_model(Decidim::Forms::Response.where(question:, user: current_user, session_token:, ip_hash:).first_or_initialize)
|
|
33
|
+
ResponseForm.from_model(Decidim::Forms::Response.where(question:, user: current_user, session_token:, ip_hash:).first_or_initialize).with_context(context)
|
|
34
34
|
end
|
|
35
35
|
end
|
|
36
36
|
|
|
@@ -12,7 +12,7 @@ module Decidim
|
|
|
12
12
|
attribute :choices, Array[ResponseChoiceForm]
|
|
13
13
|
attribute :matrix_choices, Array[ResponseChoiceForm]
|
|
14
14
|
|
|
15
|
-
attachments_attribute :
|
|
15
|
+
attachments_attribute :attachments
|
|
16
16
|
|
|
17
17
|
validates :body, presence: true, if: :mandatory_body?
|
|
18
18
|
validates :selected_choices, presence: true, if: :mandatory_choices?
|
|
@@ -20,7 +20,7 @@ module Decidim
|
|
|
20
20
|
validate :max_choices, if: -> { question.max_choices }
|
|
21
21
|
validate :all_choices, if: :sorting?
|
|
22
22
|
validate :min_choices, if: -> { question.matrix? && question.mandatory? }
|
|
23
|
-
validate :
|
|
23
|
+
validate :attachments_present, if: -> { question.question_type == "files" && question.mandatory? }
|
|
24
24
|
validate :max_characters, if: -> { question.max_characters.positive? }
|
|
25
25
|
|
|
26
26
|
delegate :mandatory_body?, :mandatory_choices?, :matrix?, to: :question
|
|
@@ -44,7 +44,7 @@ module Decidim
|
|
|
44
44
|
def map_model(model)
|
|
45
45
|
self.question_id = model.decidim_question_id
|
|
46
46
|
self.question = model.question
|
|
47
|
-
self.
|
|
47
|
+
self.attachments = model.attachments
|
|
48
48
|
|
|
49
49
|
self.choices = model.choices.map do |choice|
|
|
50
50
|
ResponseChoiceForm.from_model(choice)
|
|
@@ -82,11 +82,11 @@ module Decidim
|
|
|
82
82
|
end
|
|
83
83
|
|
|
84
84
|
def has_attachments?
|
|
85
|
-
question.has_attachments? && errors[:
|
|
85
|
+
question.has_attachments? && errors[:add_attachments].empty? && add_attachments.present?
|
|
86
86
|
end
|
|
87
87
|
|
|
88
88
|
def has_error_in_attachments?
|
|
89
|
-
errors[:
|
|
89
|
+
errors[:add_attachments].present?
|
|
90
90
|
end
|
|
91
91
|
|
|
92
92
|
def sorting?
|
|
@@ -141,8 +141,8 @@ module Decidim
|
|
|
141
141
|
I18n.t("questionnaires.question.max_choices", scope: "decidim.forms", n: question.max_choices)
|
|
142
142
|
end
|
|
143
143
|
|
|
144
|
-
def
|
|
145
|
-
errors.add(:
|
|
144
|
+
def attachments_present
|
|
145
|
+
errors.add(:add_attachments, :blank) if add_attachments.empty? && errors[:add_attachments].empty?
|
|
146
146
|
end
|
|
147
147
|
end
|
|
148
148
|
end
|
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
<%= invisible_captcha %>
|
|
19
19
|
<% response_idx = 0 %>
|
|
20
20
|
<% @form.responses_by_step.each_with_index do |step_responses, step_index| %>
|
|
21
|
-
<div id="step-<%= step_index %>" class="response-questionnaire__step" <%= "hidden" if
|
|
21
|
+
<div id="step-<%= step_index %>" class="response-questionnaire__step" <%= "hidden" if step_index.positive? %>>
|
|
22
22
|
|
|
23
23
|
<% if @form.total_steps > 1 %>
|
|
24
24
|
<p class="response-questionnaire__step-counter">
|
|
@@ -1 +1 @@
|
|
|
1
|
-
<%= response_form.upload :
|
|
1
|
+
<%= response_form.upload :add_attachments, attachments: response.attachments, label: false, multiple: true, id: field_id, disabled:, button_class: "button button__lg button__transparent-secondary w-full" %>
|
data/config/locales/ca-IT.yml
CHANGED
|
@@ -188,10 +188,10 @@ ca-IT:
|
|
|
188
188
|
of_total_steps: de %{total_steps}
|
|
189
189
|
questionnaire_closed:
|
|
190
190
|
body: El formulari està tancat i no es pot respondre.
|
|
191
|
-
title:
|
|
191
|
+
title: Formulari tancat
|
|
192
192
|
questionnaire_for_private_users:
|
|
193
193
|
body: El formulari només està disponible per a participants privades
|
|
194
|
-
title:
|
|
194
|
+
title: Formulari tancat
|
|
195
195
|
questionnaire_js_disabled:
|
|
196
196
|
body: Algunes de les característiques d'aquest formulari es deshabilitaran. Per millorar la teva experiència, si us plau, habilita JavaScript al teu navegador.
|
|
197
197
|
title: JavaScript està desactivat
|
data/config/locales/ca.yml
CHANGED
|
@@ -188,10 +188,10 @@ ca:
|
|
|
188
188
|
of_total_steps: de %{total_steps}
|
|
189
189
|
questionnaire_closed:
|
|
190
190
|
body: El formulari està tancat i no es pot respondre.
|
|
191
|
-
title:
|
|
191
|
+
title: Formulari tancat
|
|
192
192
|
questionnaire_for_private_users:
|
|
193
193
|
body: El formulari només està disponible per a participants privades
|
|
194
|
-
title:
|
|
194
|
+
title: Formulari tancat
|
|
195
195
|
questionnaire_js_disabled:
|
|
196
196
|
body: Algunes de les característiques d'aquest formulari es deshabilitaran. Per millorar la teva experiència, si us plau, habilita JavaScript al teu navegador.
|
|
197
197
|
title: JavaScript està desactivat
|
data/config/locales/eu.yml
CHANGED
data/config/locales/sk.yml
CHANGED
|
@@ -7,43 +7,225 @@ sk:
|
|
|
7
7
|
question_type: Typ
|
|
8
8
|
questionnaire_question:
|
|
9
9
|
mandatory: Povinné
|
|
10
|
+
max_characters: Limit znakov (ponechajte 0, ak bez limitu)
|
|
11
|
+
response:
|
|
12
|
+
body: Odpoveď
|
|
13
|
+
choices: Možnosti
|
|
14
|
+
selected_choices: Vybrané možnosti
|
|
15
|
+
errors:
|
|
16
|
+
models:
|
|
17
|
+
questionnaire:
|
|
18
|
+
request_invalid: Pri spracovaní požiadavky sa vyskytol problém. Skúste to znova.
|
|
19
|
+
response:
|
|
20
|
+
attributes:
|
|
21
|
+
add_documents:
|
|
22
|
+
needs_to_be_reattached: Je potrebné znova pripojiť
|
|
23
|
+
body:
|
|
24
|
+
too_long: je príliš dlhé
|
|
25
|
+
choices:
|
|
26
|
+
missing: nie sú úplné
|
|
27
|
+
too_many: Môžete si vybrať maximálne %{count}.
|
|
10
28
|
decidim:
|
|
29
|
+
download_your_data:
|
|
30
|
+
help:
|
|
31
|
+
responses:
|
|
32
|
+
id: Jedinečný identifikátor odpovede
|
|
33
|
+
question: Otázka, na ktorú sa odpovedalo
|
|
34
|
+
questionnaire: Dotazník, na ktorý sa odpovedalo
|
|
35
|
+
response: Odpoveď na otázku
|
|
36
|
+
user: Používateľ, ktorý odpovedal na dotazník
|
|
37
|
+
show:
|
|
38
|
+
responses: Export odpovedí
|
|
39
|
+
survey_user_responses: Odpovede používateľov v prieskume
|
|
11
40
|
forms:
|
|
12
41
|
admin:
|
|
13
42
|
models:
|
|
14
43
|
components:
|
|
44
|
+
allow_editing_responses: Povoliť registrovaným používateľom upravovať vlastné odpovede v prieskume
|
|
45
|
+
allow_responses: Povoliť odpovede
|
|
46
|
+
allow_unregistered: Povoliť neregistrovaným používateľom odpovedať na prieskum
|
|
47
|
+
allow_unregistered_help: Ak je táto možnosť aktívna, na odpovedanie na prieskum nebude potrebné prihlásenie. To môže viesť k nekvalitným alebo nespoľahlivým údajom a bude to zraniteľnejšie voči automatizovaným útokom. Používajte opatrne! Majte na pamäti, že účastník môže na ten istý prieskum odpovedať viackrát pomocou rôznych prehliadačov alebo funkcie „súkromné prehliadanie“ vo svojom webovom prehliadači.
|
|
48
|
+
announcement: Oznámenie
|
|
49
|
+
clean_after_publish: Vymazať odpovede pri zverejnení prieskumu
|
|
15
50
|
description: Popis
|
|
51
|
+
ends_at: Odpovede prijímané do
|
|
52
|
+
ends_at_help: Ponechajte prázdne, ak nie je určený konkrétny dátum
|
|
53
|
+
starts_at: Odpovede prijímané od
|
|
54
|
+
starts_at_help: Ponechajte prázdne, ak nie je určený konkrétny dátum
|
|
16
55
|
tos: Podmienky použitia
|
|
17
56
|
questionnaires:
|
|
57
|
+
actions:
|
|
58
|
+
back: Späť na odpovede
|
|
59
|
+
publish_responses: Zverejniť odpovede
|
|
60
|
+
show: Odpovede
|
|
61
|
+
display_condition:
|
|
62
|
+
condition_question: Otázka
|
|
63
|
+
condition_type: Podmienka
|
|
64
|
+
condition_types:
|
|
65
|
+
equal: Rovná sa
|
|
66
|
+
match: Obsahuje text
|
|
67
|
+
not_equal: Nerovná sa
|
|
68
|
+
not_responded: Nezodpovedané
|
|
69
|
+
responded: Zodpovedané
|
|
70
|
+
condition_value: Zahrnutý text
|
|
71
|
+
display_condition: Podmienka zobrazenia
|
|
72
|
+
mandatory: Táto podmienka musí byť splnená vždy bez ohľadu na stav iných podmienok
|
|
73
|
+
remove: Odstrániť
|
|
74
|
+
response_option: Možnosť odpovede
|
|
75
|
+
save_warning: Nezabudnite uložiť formulár pred konfiguráciou podmienok zobrazenia
|
|
76
|
+
select_condition_question: Vyberte otázku
|
|
77
|
+
select_condition_type: Vyberte typ podmienky
|
|
78
|
+
select_response_option: Vyberte možnosť odpovede
|
|
18
79
|
edit:
|
|
19
80
|
save: Uložiť
|
|
81
|
+
title: Upraviť dotazník
|
|
82
|
+
edit_questions:
|
|
83
|
+
add_question: Pridať otázku
|
|
84
|
+
add_separator: Pridať oddeľovač
|
|
85
|
+
add_title_and_description: Pridať názov a popis
|
|
86
|
+
save: Uložiť
|
|
87
|
+
title: Otázky
|
|
20
88
|
form:
|
|
21
89
|
add_question: Pridať otázku
|
|
90
|
+
collapse: Zbaliť všetky otázky
|
|
91
|
+
expand: Rozbaliť všetky otázky
|
|
92
|
+
preview: Náhľad
|
|
93
|
+
title: Upraviť formulár pre %{questionnaire_for}
|
|
22
94
|
matrix_row:
|
|
95
|
+
matrix_row: Riadok
|
|
23
96
|
remove: Odstrániť
|
|
24
97
|
statement: Prehlásenie
|
|
25
98
|
question:
|
|
99
|
+
add_display_condition: Pridať podmienku zobrazenia
|
|
100
|
+
add_display_condition_info: Uložte formulár pre konfiguráciu podmienok zobrazenia
|
|
101
|
+
add_matrix_row: Pridať riadok
|
|
102
|
+
add_response_option: Pridať možnosť odpovede
|
|
26
103
|
any: Akékoľvek
|
|
104
|
+
collapse: Zbaliť
|
|
27
105
|
description: Popis
|
|
106
|
+
expand: Rozbaliť
|
|
28
107
|
question: Otázka
|
|
29
108
|
remove: Odstrániť
|
|
30
109
|
statement: Prehlásenie
|
|
110
|
+
questions_form:
|
|
111
|
+
already_responded_warning: Na formulár už odpovedali niektorí používatelia, takže nemôžete upravovať jeho otázky.
|
|
112
|
+
collapse: Zbaliť všetky otázky
|
|
113
|
+
expand: Rozbaliť všetky otázky
|
|
114
|
+
unpublished_warning: Formulár nie je zverejnený. Môžete upraviť jeho otázky, ale týmto krokom sa vymažú aktuálne odpovede.
|
|
115
|
+
update:
|
|
116
|
+
success: Otázky prieskumu boli úspešne uložené.
|
|
117
|
+
response_option:
|
|
118
|
+
free_text: Voľný text
|
|
119
|
+
remove: Odstrániť
|
|
120
|
+
response_option: Možnosť odpovede
|
|
121
|
+
statement: Tvrdenie
|
|
122
|
+
responses:
|
|
123
|
+
actions:
|
|
124
|
+
back: Späť na odpovede
|
|
125
|
+
export: Exportovať
|
|
126
|
+
next: Ďalej ›
|
|
127
|
+
previous: "‹ Predchádzajúce"
|
|
128
|
+
show: Zobraziť odpovede
|
|
129
|
+
empty: Zatiaľ žiadne odpovede
|
|
130
|
+
export:
|
|
131
|
+
response:
|
|
132
|
+
title: 'Odpoveď č. %{number}'
|
|
133
|
+
export_response:
|
|
134
|
+
title: survey_user_responses_%{token}
|
|
135
|
+
index:
|
|
136
|
+
title: "Celkovo %{total} odpovedí"
|
|
137
|
+
show:
|
|
138
|
+
title: 'Odpoveď č. %{number}'
|
|
139
|
+
separator:
|
|
140
|
+
remove: Odstrániť
|
|
141
|
+
separator: Oddeľovač
|
|
142
|
+
title_and_description:
|
|
143
|
+
collapse: Zbaliť
|
|
144
|
+
description: Popis
|
|
145
|
+
expand: Rozbaliť
|
|
146
|
+
remove: Odstrániť
|
|
147
|
+
title: Názov
|
|
148
|
+
title_and_description: Názov a popis
|
|
31
149
|
update:
|
|
32
150
|
invalid: Vyskytol sa problém s ukladaním formulára.
|
|
151
|
+
success: Formulár bol úspešne uložený.
|
|
152
|
+
admin_log:
|
|
153
|
+
question:
|
|
154
|
+
publish_responses: "%{user_name} zverejnil/a odpovede na otázku %{resource_name} v priestore %{space_name}"
|
|
155
|
+
unpublish_responses: "%{user_name} zrušil/a zverejnenie odpovedí na otázku %{resource_name} v priestore %{space_name}"
|
|
156
|
+
questionnaire:
|
|
157
|
+
update: "%{user_name} aktualizoval/a dotazník %{resource_name}"
|
|
158
|
+
errors:
|
|
159
|
+
response:
|
|
160
|
+
body: Telo nemôže byť prázdne
|
|
161
|
+
images:
|
|
162
|
+
dimensions: "%{width} x %{height} px"
|
|
163
|
+
processors:
|
|
164
|
+
resize_and_pad: Veľkosť tohto obrázka sa zmení a doplní na %{dimensions}.
|
|
165
|
+
resize_to_fit: Veľkosť tohto obrázka sa zmení tak, aby sa zmestil do %{dimensions}.
|
|
33
166
|
question_types:
|
|
167
|
+
files: Súbory
|
|
168
|
+
long_response: Dlhá odpoveď
|
|
169
|
+
matrix_multiple: Matica (Viacero možností)
|
|
170
|
+
matrix_single: Matica (Jedna možnosť)
|
|
34
171
|
multiple_option: Viacero možností
|
|
172
|
+
short_response: Krátka odpoveď
|
|
35
173
|
single_option: Jedna možnosť
|
|
36
174
|
sorting: Zoradenie
|
|
175
|
+
title_and_description: Názov a popis
|
|
176
|
+
questionnaire_response_presenter:
|
|
177
|
+
download_attachment: Stiahnuť prílohu
|
|
37
178
|
questionnaires:
|
|
38
179
|
question:
|
|
39
180
|
max_choices: 'Maximum možností: %{n}'
|
|
181
|
+
response:
|
|
182
|
+
invalid: Pri odpovedaní na formulár sa vyskytol problém.
|
|
183
|
+
max_choices_alert: Je vybratých príliš veľa možností
|
|
184
|
+
success: Formulár bol úspešne vyplnený.
|
|
40
185
|
show:
|
|
186
|
+
current_step: Krok %{step}
|
|
187
|
+
empty: Pre tento formulár zatiaľ nie sú nakonfigurované žiadne otázky.
|
|
188
|
+
of_total_steps: z %{total_steps}
|
|
41
189
|
questionnaire_closed:
|
|
190
|
+
body: Formulár je uzavretý a nie je možné naň odpovedať.
|
|
42
191
|
title: Formulár je uzavretý.
|
|
43
192
|
questionnaire_for_private_users:
|
|
44
193
|
body: Formulár je otvorený len pre súkromných používateľov
|
|
45
194
|
title: Formulár je uzavretý.
|
|
195
|
+
questionnaire_js_disabled:
|
|
196
|
+
body: Niektoré funkcie tohto formulára budú vypnuté. Pre lepšiu skúsenosť si vo svojom prehliadači povoľte JavaScript.
|
|
197
|
+
title: JavaScript je vypnutý
|
|
198
|
+
questionnaire_not_published:
|
|
199
|
+
body: Tento formulár zatiaľ nie je zverejnený.
|
|
200
|
+
questionnaire_responded:
|
|
201
|
+
body: Na tento formulár ste už odpovedali.
|
|
202
|
+
title: Už ste odpovedali
|
|
203
|
+
questionnaire_responded_edit:
|
|
204
|
+
body: Na tento formulár ste už odpovedali. %{link}
|
|
205
|
+
edit: Upraviť vaše odpovede
|
|
206
|
+
response_questionnaire:
|
|
207
|
+
already_have_an_account?: Už máte účet?
|
|
208
|
+
are_you_new?: Nový používateľ?
|
|
209
|
+
sign_in_description: Prihláste sa, aby ste sa mohli zúčastniť prieskumu
|
|
210
|
+
sign_up_description: Vytvorte si účastnícky účet, aby ste sa mohli zúčastniť prieskumu
|
|
211
|
+
title: Odpovedať na formulár
|
|
46
212
|
tos_agreement: Účasťou súhlasíte s našimi Podmienkami použitia
|
|
47
213
|
step_navigation:
|
|
48
214
|
show:
|
|
215
|
+
are_you_sure_edit_guest: Ak chcete mať možnosť neskôr upraviť svoje odpovede, musíte sa prihlásiť alebo si vytvoriť účet.
|
|
216
|
+
are_you_sure_no_edit: Túto akciu nie je možné vrátiť späť a nebudete môcť upraviť svoje odpovede. Ste si istí?
|
|
217
|
+
back: Späť
|
|
218
|
+
continue: Pokračovať
|
|
219
|
+
disallowed: Nemáte povolenie upravovať svoje odpovede.
|
|
49
220
|
submit: Poslať
|
|
221
|
+
user_responses_serializer:
|
|
222
|
+
body: Odpoveď
|
|
223
|
+
completion: Dokončenie
|
|
224
|
+
created_at: Odpovedané dňa
|
|
225
|
+
id: ID odpovede
|
|
226
|
+
ip_hash: IP Hash
|
|
227
|
+
question: Otázka
|
|
228
|
+
registered: Registrovaný
|
|
229
|
+
session_token: Identifikátor používateľa
|
|
230
|
+
unregistered: Neregistrovaný
|
|
231
|
+
user_status: Stav používateľa
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
class RenameAnswersToResponses < ActiveRecord::Migration[7.2]
|
|
4
|
+
class Attachment < ApplicationRecord
|
|
5
|
+
self.table_name = "decidim_attachments"
|
|
6
|
+
end
|
|
7
|
+
|
|
8
|
+
class ActionLog < ApplicationRecord
|
|
9
|
+
self.table_name = "decidim_action_logs"
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
class Version < ApplicationRecord
|
|
13
|
+
self.table_name = "versions"
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
def up
|
|
17
|
+
# rubocop:disable Rails/SkipsModelValidations
|
|
18
|
+
Attachment.where(attached_to_type: "Decidim::Forms::Answer").update_all(attached_to_type: "Decidim::Forms::Response")
|
|
19
|
+
ActionLog.where(resource_type: "Decidim::Forms::Answer").update_all(resource_type: "Decidim::Forms::Response")
|
|
20
|
+
Version.where(item_type: "Decidim::Forms::Answer").update_all(item_type: "Decidim::Forms::Response")
|
|
21
|
+
# rubocop:enable Rails/SkipsModelValidations
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
def down
|
|
25
|
+
# rubocop:disable Rails/SkipsModelValidations
|
|
26
|
+
Attachment.where(attached_to_type: "Decidim::Forms::Response").update_all(attached_to_type: "Decidim::Forms::Answer")
|
|
27
|
+
ActionLog.where(resource_type: "Decidim::Forms::Response").update_all(resource_type: "Decidim::Forms::Answer")
|
|
28
|
+
Version.where(item_type: "Decidim::Forms::Response").update_all(item_type: "Decidim::Forms::Answer")
|
|
29
|
+
# rubocop:enable Rails/SkipsModelValidations
|
|
30
|
+
end
|
|
31
|
+
end
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require "spec_helper"
|
|
4
|
+
|
|
5
|
+
shared_examples_for "questionnaire admin access" do |denied_error:, allow_process_admin: true|
|
|
6
|
+
context "when the user is not an admin", driver: :rack_test do
|
|
7
|
+
let(:regular_user) { create(:user, :confirmed, organization:) }
|
|
8
|
+
let(:target_path) { manage_questions_path }
|
|
9
|
+
|
|
10
|
+
before do
|
|
11
|
+
login_as regular_user, scope: :user
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
before do
|
|
15
|
+
allow(Rails.application).to \
|
|
16
|
+
receive(:env_config).with(no_args).and_wrap_original do |m, *|
|
|
17
|
+
m.call.merge(
|
|
18
|
+
"action_dispatch.show_exceptions" => true,
|
|
19
|
+
"action_dispatch.show_detailed_exceptions" => false
|
|
20
|
+
)
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
visit target_path
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
it "leads to an error" do
|
|
27
|
+
denied_response = case denied_error
|
|
28
|
+
when 403
|
|
29
|
+
page.status_code == 403 || page.has_content?("You are not authorized to perform this action")
|
|
30
|
+
when 404
|
|
31
|
+
page.status_code == 404 || page.has_content?("The page you are looking for cannot be found")
|
|
32
|
+
else
|
|
33
|
+
raise ArgumentError, "unsupported denied_error: #{denied_error.inspect}. Use 403 or 404"
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
expect(denied_response).to be(true)
|
|
37
|
+
end
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
if allow_process_admin
|
|
41
|
+
context "when the user is a process admin" do
|
|
42
|
+
let(:process_admin) { create(:process_admin, :confirmed, participatory_process:) }
|
|
43
|
+
|
|
44
|
+
it "allows access to the questionnaire" do
|
|
45
|
+
login_as process_admin, scope: :user
|
|
46
|
+
visit manage_questions_path
|
|
47
|
+
|
|
48
|
+
expect(page).to have_current_path(manage_questions_path)
|
|
49
|
+
end
|
|
50
|
+
end
|
|
51
|
+
else
|
|
52
|
+
context "when the user is a process admin", driver: :rack_test do
|
|
53
|
+
let(:participatory_process) { create(:participatory_process, organization:) }
|
|
54
|
+
let(:process_admin) { create(:process_admin, :confirmed, participatory_process:) }
|
|
55
|
+
|
|
56
|
+
before do
|
|
57
|
+
login_as process_admin, scope: :user
|
|
58
|
+
|
|
59
|
+
allow(Rails.application).to \
|
|
60
|
+
receive(:env_config).with(no_args).and_wrap_original do |m, *|
|
|
61
|
+
m.call.merge(
|
|
62
|
+
"action_dispatch.show_exceptions" => true,
|
|
63
|
+
"action_dispatch.show_detailed_exceptions" => false
|
|
64
|
+
)
|
|
65
|
+
end
|
|
66
|
+
|
|
67
|
+
visit manage_questions_path
|
|
68
|
+
end
|
|
69
|
+
|
|
70
|
+
it "denies access to the questionnaire" do
|
|
71
|
+
denied_response = case denied_error
|
|
72
|
+
when 403
|
|
73
|
+
page.status_code == 403 || page.has_content?("You are not authorized to perform this action")
|
|
74
|
+
when 404
|
|
75
|
+
page.status_code == 404 || page.has_content?("The page you are looking for cannot be found")
|
|
76
|
+
else
|
|
77
|
+
raise ArgumentError, "unsupported denied_error: #{denied_error.inspect}. Use 403 or 404"
|
|
78
|
+
end
|
|
79
|
+
|
|
80
|
+
expect(denied_response).to be(true)
|
|
81
|
+
end
|
|
82
|
+
end
|
|
83
|
+
end
|
|
84
|
+
|
|
85
|
+
context "when the user is an admin" do
|
|
86
|
+
let(:admin) { create(:user, :admin, :confirmed, organization:) }
|
|
87
|
+
|
|
88
|
+
it "allows access to the questionnaire" do
|
|
89
|
+
login_as admin, scope: :user
|
|
90
|
+
visit manage_questions_path
|
|
91
|
+
|
|
92
|
+
expect(page).to have_current_path(manage_questions_path)
|
|
93
|
+
end
|
|
94
|
+
end
|
|
95
|
+
end
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require "spec_helper"
|
|
4
|
+
|
|
5
|
+
shared_examples_for "questionnaire admin controller permissions" do
|
|
6
|
+
describe "GET #edit" do
|
|
7
|
+
let(:action) { :edit }
|
|
8
|
+
|
|
9
|
+
it "enforces permission to update the questionnaire" do
|
|
10
|
+
expect(controller).to receive(:enforce_permission_to).with(:update, permission_subject, questionnaire:)
|
|
11
|
+
get action
|
|
12
|
+
end
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
describe "PATCH #update" do
|
|
16
|
+
let(:action) { :update }
|
|
17
|
+
|
|
18
|
+
it "enforces permission to update the questionnaire" do
|
|
19
|
+
expect(controller).to receive(:enforce_permission_to).with(:update, permission_subject, questionnaire:)
|
|
20
|
+
patch action, params: { questionnaire: {} }
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
describe "GET #edit_questions" do
|
|
25
|
+
let(:action) { :edit_questions }
|
|
26
|
+
|
|
27
|
+
it "enforces permission to update the questionnaire" do
|
|
28
|
+
expect(controller).to receive(:enforce_permission_to).with(:update, permission_subject, questionnaire:)
|
|
29
|
+
get action
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
describe "PATCH #update_questions" do
|
|
34
|
+
let(:action) { :update_questions }
|
|
35
|
+
|
|
36
|
+
it "enforces permission to update the questionnaire" do
|
|
37
|
+
expect(controller).to receive(:enforce_permission_to).with(:update, permission_subject, questionnaire:)
|
|
38
|
+
patch action, params: { questions: {} }
|
|
39
|
+
end
|
|
40
|
+
end
|
|
41
|
+
end
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: decidim-forms
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.31.
|
|
4
|
+
version: 0.31.6
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Josep Jaume Rey Peroy
|
|
@@ -11,7 +11,7 @@ authors:
|
|
|
11
11
|
autorequire:
|
|
12
12
|
bindir: bin
|
|
13
13
|
cert_chain: []
|
|
14
|
-
date: 2026-
|
|
14
|
+
date: 2026-07-06 00:00:00.000000000 Z
|
|
15
15
|
dependencies:
|
|
16
16
|
- !ruby/object:Gem::Dependency
|
|
17
17
|
name: decidim-core
|
|
@@ -19,42 +19,42 @@ dependencies:
|
|
|
19
19
|
requirements:
|
|
20
20
|
- - '='
|
|
21
21
|
- !ruby/object:Gem::Version
|
|
22
|
-
version: 0.31.
|
|
22
|
+
version: 0.31.6
|
|
23
23
|
type: :runtime
|
|
24
24
|
prerelease: false
|
|
25
25
|
version_requirements: !ruby/object:Gem::Requirement
|
|
26
26
|
requirements:
|
|
27
27
|
- - '='
|
|
28
28
|
- !ruby/object:Gem::Version
|
|
29
|
-
version: 0.31.
|
|
29
|
+
version: 0.31.6
|
|
30
30
|
- !ruby/object:Gem::Dependency
|
|
31
31
|
name: decidim-admin
|
|
32
32
|
requirement: !ruby/object:Gem::Requirement
|
|
33
33
|
requirements:
|
|
34
34
|
- - '='
|
|
35
35
|
- !ruby/object:Gem::Version
|
|
36
|
-
version: 0.31.
|
|
36
|
+
version: 0.31.6
|
|
37
37
|
type: :development
|
|
38
38
|
prerelease: false
|
|
39
39
|
version_requirements: !ruby/object:Gem::Requirement
|
|
40
40
|
requirements:
|
|
41
41
|
- - '='
|
|
42
42
|
- !ruby/object:Gem::Version
|
|
43
|
-
version: 0.31.
|
|
43
|
+
version: 0.31.6
|
|
44
44
|
- !ruby/object:Gem::Dependency
|
|
45
45
|
name: decidim-dev
|
|
46
46
|
requirement: !ruby/object:Gem::Requirement
|
|
47
47
|
requirements:
|
|
48
48
|
- - '='
|
|
49
49
|
- !ruby/object:Gem::Version
|
|
50
|
-
version: 0.31.
|
|
50
|
+
version: 0.31.6
|
|
51
51
|
type: :development
|
|
52
52
|
prerelease: false
|
|
53
53
|
version_requirements: !ruby/object:Gem::Requirement
|
|
54
54
|
requirements:
|
|
55
55
|
- - '='
|
|
56
56
|
- !ruby/object:Gem::Version
|
|
57
|
-
version: 0.31.
|
|
57
|
+
version: 0.31.6
|
|
58
58
|
description: A forms gem for decidim.
|
|
59
59
|
email:
|
|
60
60
|
- josepjaume@gmail.com
|
|
@@ -244,6 +244,7 @@ files:
|
|
|
244
244
|
- config/locales/vi.yml
|
|
245
245
|
- config/locales/zh-CN.yml
|
|
246
246
|
- config/locales/zh-TW.yml
|
|
247
|
+
- db/data/20260616144141_rename_answers_to_responses.rb
|
|
247
248
|
- db/migrate/20170511092231_create_decidim_forms_questionnaires.rb
|
|
248
249
|
- db/migrate/20170515090916_create_decidim_forms_questions.rb
|
|
249
250
|
- db/migrate/20170515144119_create_decidim_forms_answers.rb
|
|
@@ -287,6 +288,8 @@ files:
|
|
|
287
288
|
- lib/decidim/forms/test/shared_examples/manage_questionnaires/draggable_behavior.rb
|
|
288
289
|
- lib/decidim/forms/test/shared_examples/manage_questionnaires/update_display_conditions.rb
|
|
289
290
|
- lib/decidim/forms/test/shared_examples/manage_questionnaires/update_questions.rb
|
|
291
|
+
- lib/decidim/forms/test/shared_examples/questionnaire_admin_access.rb
|
|
292
|
+
- lib/decidim/forms/test/shared_examples/questionnaire_admin_controller_permissions.rb
|
|
290
293
|
- lib/decidim/forms/user_responses_serializer.rb
|
|
291
294
|
- lib/decidim/forms/version.rb
|
|
292
295
|
homepage: https://decidim.org
|