decidim-templates 0.31.8 → 0.32.0.rc1
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/README.md +6 -12
- data/app/commands/decidim/templates/admin/questionnaire_copier.rb +8 -10
- data/app/controllers/decidim/templates/admin/application_controller.rb +0 -2
- data/app/controllers/decidim/templates/admin/block_user_templates_controller.rb +2 -2
- data/app/controllers/decidim/templates/admin/concerns/templatable.rb +2 -2
- data/app/controllers/decidim/templates/admin/proposal_answer_templates_controller.rb +7 -12
- data/app/controllers/decidim/templates/admin/questionnaire_templates/questionnaires_controller.rb +1 -15
- data/app/controllers/decidim/templates/admin/questionnaire_templates_controller.rb +8 -72
- data/app/permissions/decidim/templates/admin/permissions.rb +4 -48
- data/app/views/decidim/templates/admin/block_user_templates/index.html.erb +1 -1
- data/app/views/decidim/templates/admin/proposal_answer_templates/index.html.erb +2 -2
- data/app/views/decidim/templates/admin/questionnaire_templates/_preview.html.erb +1 -1
- data/app/views/decidim/templates/admin/questionnaire_templates/index.html.erb +1 -1
- data/config/locales/ar.yml +0 -1
- data/config/locales/bg.yml +0 -1
- data/config/locales/ca-IT.yml +0 -1
- data/config/locales/ca.yml +0 -1
- data/config/locales/cs.yml +0 -1
- data/config/locales/de.yml +0 -1
- data/config/locales/es-MX.yml +0 -1
- data/config/locales/es-PY.yml +0 -1
- data/config/locales/es.yml +0 -1
- data/config/locales/eu.yml +10 -11
- data/config/locales/fi-plain.yml +0 -1
- data/config/locales/fi.yml +0 -1
- data/config/locales/fr-CA.yml +0 -1
- data/config/locales/fr.yml +0 -1
- data/config/locales/ga-IE.yml +0 -1
- data/config/locales/gl.yml +0 -62
- data/config/locales/hu.yml +0 -1
- data/config/locales/it.yml +0 -1
- data/config/locales/ja.yml +0 -1
- data/config/locales/kaa.yml +0 -1
- data/config/locales/lt.yml +0 -1
- data/config/locales/nl.yml +0 -1
- data/config/locales/no.yml +0 -1
- data/config/locales/pl.yml +0 -1
- data/config/locales/pt-BR.yml +0 -1
- data/config/locales/pt.yml +0 -1
- data/config/locales/ro-RO.yml +0 -1
- data/config/locales/sk.yml +0 -120
- data/config/locales/sv.yml +0 -1
- data/config/locales/tr-TR.yml +0 -1
- data/config/locales/zh-CN.yml +0 -1
- data/config/locales/zh-TW.yml +0 -1
- data/decidim-templates.gemspec +10 -11
- data/lib/decidim/templates/admin_engine.rb +7 -1
- data/lib/decidim/templates/engine.rb +0 -2
- data/lib/decidim/templates/test/shared_examples/uses_questionnaire_templates.rb +12 -36
- data/lib/decidim/templates/version.rb +1 -1
- metadata +18 -21
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 16236ee594d068cf0992ba09e9e83cea49220d5cea16e4ef116c1cb8daac853b
|
|
4
|
+
data.tar.gz: dc72ebb0cfc076d11100f8d3d4c97ad235ee0e29f7d342e11d041bbce15b4e2b
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 5e096d90c8bf514e8d00342e0dad59cffdff9e9ec497f68c95f672954b91d35cf1351f73372f6189d1056a4ce8637f1424662b03d3719d520310b49408bf3fb0
|
|
7
|
+
data.tar.gz: 78302f59fba1aa1f0cbf13d4b31a055877750d8bfa932f811642a73fa9ab4b4942572361919f2f602af785fc2f236a247926f79c62cb790e8d7903c1a4a05967
|
data/README.md
CHANGED
|
@@ -1,24 +1,18 @@
|
|
|
1
|
-
#
|
|
1
|
+
# decidim-templates
|
|
2
2
|
|
|
3
3
|
This module provides a solution to create templates for different Decidim models, such as Proposals and Questionnaires.
|
|
4
4
|
|
|
5
5
|
## Usage
|
|
6
6
|
|
|
7
|
-
Templates will be available in their own section in the admin
|
|
7
|
+
Templates will be available in their own section in the admin.
|
|
8
8
|
|
|
9
9
|
## Installation
|
|
10
10
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
```ruby
|
|
14
|
-
gem 'decidim-templates'
|
|
15
|
-
```
|
|
16
|
-
|
|
17
|
-
And then execute:
|
|
11
|
+
To install this module, run in your console:
|
|
18
12
|
|
|
19
13
|
```bash
|
|
20
|
-
bundle
|
|
21
|
-
bundle exec rails
|
|
14
|
+
bundle add decidim-templates
|
|
15
|
+
bundle exec rails decidim:upgrade
|
|
22
16
|
bundle exec rails db:migrate
|
|
23
17
|
```
|
|
24
18
|
|
|
@@ -28,4 +22,4 @@ See [Decidim](https://github.com/decidim/decidim).
|
|
|
28
22
|
|
|
29
23
|
## License
|
|
30
24
|
|
|
31
|
-
|
|
25
|
+
See [Decidim](https://github.com/decidim/decidim).
|
|
@@ -7,8 +7,8 @@ module Decidim
|
|
|
7
7
|
module QuestionnaireCopier
|
|
8
8
|
def copy_questionnaire_questions(original_questionnaire, new_questionnaire)
|
|
9
9
|
# start by copying the questions so that they already exist when cross referencing them in the conditions
|
|
10
|
-
|
|
11
|
-
|
|
10
|
+
original_questionnaire.reload.questions.includes(:response_options, :matrix_rows, :display_conditions)
|
|
11
|
+
original_questionnaire.questions.each do |original_question|
|
|
12
12
|
new_question = original_question.dup
|
|
13
13
|
new_question.questionnaire = new_questionnaire
|
|
14
14
|
new_question.assign_attributes(
|
|
@@ -21,12 +21,9 @@ module Decidim
|
|
|
21
21
|
copy_questionnaire_response_options(original_question, new_question)
|
|
22
22
|
copy_questionnaire_matrix_rows(original_question, new_question)
|
|
23
23
|
end
|
|
24
|
-
# once all questions are copied, copy display conditions
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
destination_questions = new_questionnaire.questions.includes(:response_options).to_a
|
|
28
|
-
original_questions.zip(destination_questions).each do |original_question, new_question|
|
|
29
|
-
copy_question_display_conditions(original_question, new_question, destination_questions)
|
|
24
|
+
# once all questions are copied, copy display conditions
|
|
25
|
+
original_questionnaire.questions.zip(new_questionnaire.questions.load).each do |original_question, new_question|
|
|
26
|
+
copy_question_display_conditions(original_question, new_question)
|
|
30
27
|
end
|
|
31
28
|
end
|
|
32
29
|
|
|
@@ -46,12 +43,12 @@ module Decidim
|
|
|
46
43
|
end
|
|
47
44
|
end
|
|
48
45
|
|
|
49
|
-
def copy_question_display_conditions(original_question, destination_question
|
|
46
|
+
def copy_question_display_conditions(original_question, destination_question)
|
|
50
47
|
original_question.display_conditions.each do |original_display_condition|
|
|
51
48
|
new_display_condition = original_display_condition.dup
|
|
52
49
|
new_display_condition.question = destination_question
|
|
53
50
|
|
|
54
|
-
destination_question_to_be_checked = find_question_by_position(
|
|
51
|
+
destination_question_to_be_checked = find_question_by_position(destination_question.questionnaire.questions, original_display_condition.condition_question.position)
|
|
55
52
|
new_display_condition.condition_question = destination_question_to_be_checked
|
|
56
53
|
|
|
57
54
|
if original_display_condition.response_option
|
|
@@ -59,6 +56,7 @@ module Decidim
|
|
|
59
56
|
original_display_condition.response_option.body)
|
|
60
57
|
end
|
|
61
58
|
new_display_condition.save!
|
|
59
|
+
destination_question.display_conditions << new_display_condition
|
|
62
60
|
end
|
|
63
61
|
end
|
|
64
62
|
|
|
@@ -62,7 +62,7 @@ module Decidim
|
|
|
62
62
|
on(:invalid) do |template|
|
|
63
63
|
@template = template
|
|
64
64
|
flash.now[:error] = I18n.t("templates.update.error", scope: "decidim.admin")
|
|
65
|
-
render action: :edit, status: :
|
|
65
|
+
render action: :edit, status: :unprocessable_content
|
|
66
66
|
end
|
|
67
67
|
end
|
|
68
68
|
end
|
|
@@ -85,7 +85,7 @@ module Decidim
|
|
|
85
85
|
|
|
86
86
|
on(:invalid) do
|
|
87
87
|
flash.now[:alert] = I18n.t("templates.create.error", scope: "decidim.admin")
|
|
88
|
-
render :new, status: :
|
|
88
|
+
render :new, status: :unprocessable_content
|
|
89
89
|
end
|
|
90
90
|
end
|
|
91
91
|
end
|
|
@@ -13,8 +13,6 @@ module Decidim
|
|
|
13
13
|
included do
|
|
14
14
|
helper_method :templates, :choose_template?
|
|
15
15
|
|
|
16
|
-
protected
|
|
17
|
-
|
|
18
16
|
def templates
|
|
19
17
|
@templates = current_organization.templates.where(templatable_type:)
|
|
20
18
|
@templates = @templates.where.not(id: params[:id]) if templates_path?
|
|
@@ -31,6 +29,8 @@ module Decidim
|
|
|
31
29
|
templates.any? && templatable.pristine?
|
|
32
30
|
end
|
|
33
31
|
|
|
32
|
+
protected
|
|
33
|
+
|
|
34
34
|
def templatable
|
|
35
35
|
raise NotImplementedError, "Please set the templatable resource in your controller"
|
|
36
36
|
end
|
|
@@ -39,7 +39,7 @@ module Decidim
|
|
|
39
39
|
|
|
40
40
|
on(:invalid) do
|
|
41
41
|
flash.now[:alert] = I18n.t("templates.create.error", scope: "decidim.admin")
|
|
42
|
-
render :new, status: :
|
|
42
|
+
render :new, status: :unprocessable_content
|
|
43
43
|
end
|
|
44
44
|
end
|
|
45
45
|
end
|
|
@@ -58,7 +58,7 @@ module Decidim
|
|
|
58
58
|
def fetch
|
|
59
59
|
enforce_permission_to(:read, :template, template:, proposal:)
|
|
60
60
|
|
|
61
|
-
return render json: { msg: I18n.t("templates.fetch.error", scope: "decidim.admin") }, status: :
|
|
61
|
+
return render json: { msg: I18n.t("templates.fetch.error", scope: "decidim.admin") }, status: :unprocessable_content if template.blank?
|
|
62
62
|
|
|
63
63
|
state = fetch_proposal_state(template)
|
|
64
64
|
|
|
@@ -86,7 +86,7 @@ module Decidim
|
|
|
86
86
|
on(:invalid) do |template|
|
|
87
87
|
@template = template
|
|
88
88
|
flash.now[:error] = I18n.t("templates.update.error", scope: "decidim.admin")
|
|
89
|
-
render action: :edit, status: :
|
|
89
|
+
render action: :edit, status: :unprocessable_content
|
|
90
90
|
end
|
|
91
91
|
end
|
|
92
92
|
end
|
|
@@ -136,16 +136,11 @@ module Decidim
|
|
|
136
136
|
end
|
|
137
137
|
|
|
138
138
|
def available_states(component_id = nil)
|
|
139
|
-
Decidim::Proposals::ProposalState.where(decidim_component_id: component_id)
|
|
139
|
+
Decidim::Proposals::ProposalState.where(decidim_component_id: component_id)
|
|
140
140
|
end
|
|
141
141
|
|
|
142
142
|
def proposal
|
|
143
|
-
@proposal ||=
|
|
144
|
-
component_ids = current_organization.participatory_spaces
|
|
145
|
-
.flat_map { |s| s.components.where(manifest_name: :proposals).pluck(:id) }
|
|
146
|
-
Decidim::Proposals::Proposal.where(decidim_component_id: component_ids) # rubocop:disable Decidim/OrganizationScopedFinder -- scoped via component_ids derived from current_organization.participatory_spaces
|
|
147
|
-
.find_by(id: params[:proposalId].to_i)
|
|
148
|
-
end
|
|
143
|
+
@proposal ||= Decidim::Proposals::Proposal.find(params[:proposalId])
|
|
149
144
|
end
|
|
150
145
|
|
|
151
146
|
def availability_option_as_text(template)
|
|
@@ -160,7 +155,7 @@ module Decidim
|
|
|
160
155
|
|
|
161
156
|
def availability_options
|
|
162
157
|
@availability_options = []
|
|
163
|
-
Decidim::Component.includes(:participatory_space).where(manifest_name: [:proposals])
|
|
158
|
+
Decidim::Component.includes(:participatory_space).where(manifest_name: [:proposals])
|
|
164
159
|
.select { |a| a.participatory_space.decidim_organization_id == current_organization.id }.each do |component|
|
|
165
160
|
@availability_options.push [formatted_name(component), component.id]
|
|
166
161
|
end
|
|
@@ -174,7 +169,7 @@ module Decidim
|
|
|
174
169
|
end
|
|
175
170
|
|
|
176
171
|
def template
|
|
177
|
-
@template ||=
|
|
172
|
+
@template ||= Template.find_by(id: params[:id])
|
|
178
173
|
end
|
|
179
174
|
|
|
180
175
|
def collection
|
data/app/controllers/decidim/templates/admin/questionnaire_templates/questionnaires_controller.rb
CHANGED
|
@@ -10,8 +10,6 @@ module Decidim
|
|
|
10
10
|
|
|
11
11
|
helper Decidim::Admin::ExportsHelper
|
|
12
12
|
|
|
13
|
-
protected
|
|
14
|
-
|
|
15
13
|
def questionnaire_for
|
|
16
14
|
template
|
|
17
15
|
end
|
|
@@ -32,22 +30,10 @@ module Decidim
|
|
|
32
30
|
t(:title, scope: "decidim.templates.admin.questionnaire_templates.form", questionnaire_for: translated_attribute(template.name))
|
|
33
31
|
end
|
|
34
32
|
|
|
35
|
-
def response_options_url(params)
|
|
36
|
-
url_for(params.merge(controller: "decidim/templates/admin/questionnaire_templates/questionnaires", action: "response_options", format: :json, template_id: template.id))
|
|
37
|
-
end
|
|
38
|
-
|
|
39
33
|
private
|
|
40
34
|
|
|
41
35
|
def template
|
|
42
|
-
@template ||= current_organization.templates.where(templatable_type: "Decidim::Forms::Questionnaire").find(
|
|
43
|
-
end
|
|
44
|
-
|
|
45
|
-
def template_id
|
|
46
|
-
if action_name == "response_options"
|
|
47
|
-
params.require(:template_id)
|
|
48
|
-
else
|
|
49
|
-
params.require(:id)
|
|
50
|
-
end
|
|
36
|
+
@template ||= current_organization.templates.where(templatable_type: "Decidim::Forms::Questionnaire").find(params[:id])
|
|
51
37
|
end
|
|
52
38
|
end
|
|
53
39
|
end
|
|
@@ -8,6 +8,7 @@ module Decidim
|
|
|
8
8
|
class QuestionnaireTemplatesController < Decidim::Templates::Admin::ApplicationController
|
|
9
9
|
include Decidim::TranslatableAttributes
|
|
10
10
|
include Decidim::Forms::Admin::Concerns::HasQuestionnaire
|
|
11
|
+
|
|
11
12
|
helper Decidim::Forms::Admin::ApplicationHelper
|
|
12
13
|
|
|
13
14
|
helper_method :template, :questionnaire
|
|
@@ -48,7 +49,7 @@ module Decidim
|
|
|
48
49
|
|
|
49
50
|
on(:invalid) do
|
|
50
51
|
flash.now[:alert] = I18n.t("templates.create.error", scope: "decidim.admin")
|
|
51
|
-
render :new, status: :
|
|
52
|
+
render :new, status: :unprocessable_content
|
|
52
53
|
end
|
|
53
54
|
end
|
|
54
55
|
end
|
|
@@ -87,7 +88,7 @@ module Decidim
|
|
|
87
88
|
on(:invalid) do |template|
|
|
88
89
|
@template = template
|
|
89
90
|
flash.now[:error] = I18n.t("templates.update.error", scope: "decidim.admin")
|
|
90
|
-
render action: :edit, status: :
|
|
91
|
+
render action: :edit, status: :unprocessable_content
|
|
91
92
|
end
|
|
92
93
|
end
|
|
93
94
|
end
|
|
@@ -104,19 +105,13 @@ module Decidim
|
|
|
104
105
|
end
|
|
105
106
|
|
|
106
107
|
def apply
|
|
107
|
-
questionnaire =
|
|
108
|
-
|
|
109
|
-
template = collection.find_by(id: params.dig(:questionnaire, :questionnaire_template_id))
|
|
110
|
-
|
|
111
|
-
if questionnaire.blank?
|
|
112
|
-
flash[:alert] = I18n.t("templates.apply.error", scope: "decidim.admin")
|
|
113
|
-
return redirect_to(internal_redirect_path || { action: :index })
|
|
114
|
-
end
|
|
108
|
+
questionnaire = Decidim::Forms::Questionnaire.find_by(id: params[:questionnaire_id])
|
|
109
|
+
template = Decidim::Templates::Template.find_by(id: params.dig(:questionnaire, :questionnaire_template_id))
|
|
115
110
|
|
|
116
111
|
ApplyQuestionnaireTemplate.call(questionnaire, template) do
|
|
117
112
|
on(:ok) do
|
|
118
113
|
flash[:notice] = I18n.t("templates.apply.success", scope: "decidim.admin")
|
|
119
|
-
redirect_to(
|
|
114
|
+
redirect_to URI.parse(params[:url]).path
|
|
120
115
|
end
|
|
121
116
|
on(:invalid) do
|
|
122
117
|
flash[:error] = I18n.t("templates.apply.error", scope: "decidim.admin")
|
|
@@ -126,7 +121,6 @@ module Decidim
|
|
|
126
121
|
end
|
|
127
122
|
|
|
128
123
|
def preview
|
|
129
|
-
enforce_permission_to :preview, :questionnaire_template
|
|
130
124
|
respond_to do |format|
|
|
131
125
|
format.js do
|
|
132
126
|
@template = template
|
|
@@ -137,81 +131,23 @@ module Decidim
|
|
|
137
131
|
end
|
|
138
132
|
|
|
139
133
|
def skip
|
|
140
|
-
questionnaire =
|
|
141
|
-
enforce_permission_to :skip, :questionnaire_template, questionnaire:, component: questionnaire_component(questionnaire)
|
|
142
|
-
|
|
143
|
-
return redirect_to(internal_redirect_path || { action: :index }) unless questionnaire
|
|
144
|
-
|
|
134
|
+
questionnaire = Decidim::Forms::Questionnaire.find_by(id: params[:questionnaire_id])
|
|
145
135
|
# rubocop:disable Rails/SkipsModelValidations
|
|
146
136
|
questionnaire.touch
|
|
147
137
|
# rubocop:enable Rails/SkipsModelValidations
|
|
148
|
-
redirect_to(
|
|
138
|
+
redirect_to URI.parse(params[:url]).path
|
|
149
139
|
end
|
|
150
140
|
|
|
151
|
-
protected
|
|
152
|
-
|
|
153
141
|
def edit_questions_template
|
|
154
142
|
"decidim/templates/admin/questionnaire_templates/edit_questions"
|
|
155
143
|
end
|
|
156
144
|
|
|
157
|
-
def response_options_url(params)
|
|
158
|
-
url_for(params.merge(controller: "decidim/templates/admin/questionnaire_templates/questionnaires", action: "response_options", format: :json, template_id: template.id))
|
|
159
|
-
end
|
|
160
|
-
|
|
161
145
|
def after_update_url
|
|
162
146
|
edit_questionnaire_template_path(template)
|
|
163
147
|
end
|
|
164
148
|
|
|
165
149
|
private
|
|
166
150
|
|
|
167
|
-
def find_questionnaire(id)
|
|
168
|
-
questionnaire = Decidim::Forms::Questionnaire.find_by(id:) # rubocop:disable Decidim/OrganizationScopedFinder -- scoping requires polymorphic questionnaire_for chain; org ownership validated via questionnaire_for_in_organization?
|
|
169
|
-
return unless questionnaire
|
|
170
|
-
return unless questionnaire_for_in_organization?(questionnaire)
|
|
171
|
-
|
|
172
|
-
questionnaire
|
|
173
|
-
end
|
|
174
|
-
|
|
175
|
-
def questionnaire_component(questionnaire)
|
|
176
|
-
questionnaire&.questionnaire_for.try(:component)
|
|
177
|
-
end
|
|
178
|
-
|
|
179
|
-
def questionnaire_for_in_organization?(questionnaire)
|
|
180
|
-
questionnaire_for = questionnaire.questionnaire_for
|
|
181
|
-
return false unless questionnaire_for
|
|
182
|
-
return false unless questionnaire_for.respond_to?(:organization)
|
|
183
|
-
|
|
184
|
-
questionnaire_for.organization == current_organization
|
|
185
|
-
end
|
|
186
|
-
|
|
187
|
-
# Returns the path of the `url` param only when it points to the same
|
|
188
|
-
# origin. Absolute same-origin URLs and root-relative paths are
|
|
189
|
-
# accepted; protocol-relative, external and malformed URLs are rejected
|
|
190
|
-
# so they can never be used to redirect the user to another site.
|
|
191
|
-
def internal_redirect_path
|
|
192
|
-
url = params[:url].to_s
|
|
193
|
-
return if url.blank?
|
|
194
|
-
|
|
195
|
-
uri = URI.parse(url)
|
|
196
|
-
return if uri.host.present? && !same_origin?(uri)
|
|
197
|
-
|
|
198
|
-
safe_path(uri.path)
|
|
199
|
-
rescue URI::Error
|
|
200
|
-
nil
|
|
201
|
-
end
|
|
202
|
-
|
|
203
|
-
def same_origin?(uri)
|
|
204
|
-
uri.host == request.host && (uri.scheme.nil? || uri.scheme == request.scheme)
|
|
205
|
-
end
|
|
206
|
-
|
|
207
|
-
def safe_path(path)
|
|
208
|
-
return if path.blank? || !path.start_with?("/")
|
|
209
|
-
return if path.start_with?("//", "/\\") || path.include?("\\")
|
|
210
|
-
return if path.match?(/[\u0000-\u001f\u007f]/)
|
|
211
|
-
|
|
212
|
-
path
|
|
213
|
-
end
|
|
214
|
-
|
|
215
151
|
def questionnaire
|
|
216
152
|
template.templatable
|
|
217
153
|
end
|
|
@@ -9,9 +9,11 @@ module Decidim
|
|
|
9
9
|
return permission_action unless user
|
|
10
10
|
return permission_action if context[:current_organization] != user.organization
|
|
11
11
|
|
|
12
|
-
if
|
|
12
|
+
if user_has_a_role? && (permission_action.subject == :template && permission_action.action == :read)
|
|
13
13
|
allow!
|
|
14
|
-
|
|
14
|
+
else
|
|
15
|
+
return permission_action unless user.admin?
|
|
16
|
+
|
|
15
17
|
case permission_action.subject
|
|
16
18
|
when :template
|
|
17
19
|
allow! if [:read, :create, :update, :destroy, :copy].include? permission_action.action
|
|
@@ -19,8 +21,6 @@ module Decidim
|
|
|
19
21
|
allow! if permission_action.action == :index
|
|
20
22
|
when :questionnaire
|
|
21
23
|
allow!
|
|
22
|
-
when :questionnaire_template
|
|
23
|
-
allow! if [:preview, :apply, :skip].include? permission_action.action
|
|
24
24
|
end
|
|
25
25
|
end
|
|
26
26
|
|
|
@@ -42,50 +42,6 @@ module Decidim
|
|
|
42
42
|
|
|
43
43
|
user_roles.exists?(user:)
|
|
44
44
|
end
|
|
45
|
-
|
|
46
|
-
def read_template_action?
|
|
47
|
-
user_has_a_role? && permission_action.subject == :template && permission_action.action == :read
|
|
48
|
-
end
|
|
49
|
-
|
|
50
|
-
# Allows a user who is able to edit the target questionnaire to preview,
|
|
51
|
-
# apply or skip questionnaire templates. Organization admins can always
|
|
52
|
-
# perform these actions. "preview" has no target questionnaire to scope
|
|
53
|
-
# to, so it is allowed to any user holding a role in a participatory
|
|
54
|
-
# space, as it is only reachable from an already authorized form.
|
|
55
|
-
def allows_questionnaire_template_action?
|
|
56
|
-
return false unless permission_action.subject == :questionnaire_template
|
|
57
|
-
return false unless [:preview, :apply, :skip].include?(permission_action.action)
|
|
58
|
-
return true if user.admin?
|
|
59
|
-
|
|
60
|
-
if (component = context[:component]).present?
|
|
61
|
-
return user_can_manage_component?(component)
|
|
62
|
-
end
|
|
63
|
-
|
|
64
|
-
permission_action.action == :preview && user_has_any_role?(user, nil, broad_check: true)
|
|
65
|
-
end
|
|
66
|
-
|
|
67
|
-
# Checks the user can manage the given component by delegating the
|
|
68
|
-
# `:manage, :component` action to the component's own permission chain,
|
|
69
|
-
# so that space admins are authorized while other roles are not.
|
|
70
|
-
def user_can_manage_component?(component)
|
|
71
|
-
[
|
|
72
|
-
component.manifest.permissions_class,
|
|
73
|
-
component.participatory_space.manifest.permissions_class,
|
|
74
|
-
Decidim::Admin::Permissions
|
|
75
|
-
].inject(permission_action_for_manage_component) do |action, permission_class|
|
|
76
|
-
permission_class.new(
|
|
77
|
-
user,
|
|
78
|
-
action,
|
|
79
|
-
context.merge(component:, current_participatory_space: component.participatory_space)
|
|
80
|
-
).permissions
|
|
81
|
-
end.allowed?
|
|
82
|
-
rescue Decidim::PermissionAction::PermissionNotSetError
|
|
83
|
-
false
|
|
84
|
-
end
|
|
85
|
-
|
|
86
|
-
def permission_action_for_manage_component
|
|
87
|
-
Decidim::PermissionAction.new(scope: :admin, action: :manage, subject: :component)
|
|
88
|
-
end
|
|
89
45
|
end
|
|
90
46
|
end
|
|
91
47
|
end
|
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
<%= link_to translated_attribute(template.name), edit_block_user_template_path(template) %>
|
|
26
26
|
</td>
|
|
27
27
|
<td data-label="<%= t("template.fields.created_at", scope: "decidim.models") %>">
|
|
28
|
-
<%= l template.created_at, format: :
|
|
28
|
+
<%= l template.created_at, format: :decidim_short %>
|
|
29
29
|
</td>
|
|
30
30
|
<td data-label="<%= t("decidim.admin.actions.actions") %>" class="table-list__actions">
|
|
31
31
|
<button type="button" data-controller="dropdown" data-target="actions-block-user-template-<%= template.id %>" aria-label="<%= t("decidim.admin.actions.actions_label", resource: template.name) %>">
|
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
<% @templates.each do |template| %>
|
|
26
26
|
<tr data-proposal_answer-id="<%= template.id %>">
|
|
27
27
|
<td data-label="<%= t("template.name", scope: "decidim.models") %>">
|
|
28
|
-
<%= link_to_if allowed_to?(:update, :template, template:
|
|
28
|
+
<%= link_to_if allowed_to?(:update, :template, template:), translated_attribute(template.name), edit_proposal_answer_template_path(template) %>
|
|
29
29
|
</td>
|
|
30
30
|
<td data-label="<%= t(".proposal_state_id") %>">
|
|
31
31
|
<%= proposal_state(template) %>
|
|
@@ -34,7 +34,7 @@
|
|
|
34
34
|
<%= availability_option_as_text(template) %>
|
|
35
35
|
</td>
|
|
36
36
|
<td data-label="<%= t("template.fields.created_at", scope: "decidim.models") %>">
|
|
37
|
-
<%= l template.created_at, format: :
|
|
37
|
+
<%= l template.created_at, format: :decidim_short %>
|
|
38
38
|
</td>
|
|
39
39
|
<td data-label="<%= t("decidim.admin.actions.actions") %>" class="table-list__actions">
|
|
40
40
|
<button type="button" data-controller="dropdown" data-target="actions-proposal-answer-template-<%= template.id %>" aria-label="<%= t("decidim.admin.actions.actions_label", resource: template.name) %>">
|
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
<% response_idx = 0 %>
|
|
12
12
|
<% cleaned_response_idx = 0 %>
|
|
13
13
|
<% @preview_form.responses_by_step.each_with_index do |step_responses, step_index| %>
|
|
14
|
-
<div id="step-<%= step_index %>" class="questionnaire-step"
|
|
14
|
+
<div id="step-<%= step_index %>" class="<%= step_index.zero? ? "questionnaire-step" : "questionnaire-step hide" %>" data-toggler=".hide">
|
|
15
15
|
<div class="form__wrapper">
|
|
16
16
|
<% if @preview_form.total_steps > 1 %>
|
|
17
17
|
<h4>
|
|
@@ -33,7 +33,7 @@
|
|
|
33
33
|
<%= template.templatable.questions.count.to_i %>
|
|
34
34
|
</td>
|
|
35
35
|
<td data-label="<%= t("template.fields.created_at", scope: "decidim.models") %>">
|
|
36
|
-
<%= l template.created_at, format: :
|
|
36
|
+
<%= l template.created_at, format: :decidim_short %>
|
|
37
37
|
</td>
|
|
38
38
|
<td data-label="<%= t("decidim.admin.actions.actions") %>" class="table-list__actions">
|
|
39
39
|
<button type="button" data-controller="dropdown" data-target="actions-template-<%= template.id %>" aria-label="<%= t("decidim.admin.actions.actions_label", resource: template.name) %>">
|
data/config/locales/ar.yml
CHANGED
data/config/locales/bg.yml
CHANGED
data/config/locales/ca-IT.yml
CHANGED
data/config/locales/ca.yml
CHANGED
data/config/locales/cs.yml
CHANGED
data/config/locales/de.yml
CHANGED
data/config/locales/es-MX.yml
CHANGED
data/config/locales/es-PY.yml
CHANGED
data/config/locales/es.yml
CHANGED
data/config/locales/eu.yml
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
---
|
|
2
1
|
eu:
|
|
3
2
|
activemodel:
|
|
4
3
|
attributes:
|
|
@@ -27,7 +26,7 @@ eu:
|
|
|
27
26
|
success: Txantiloia zuzen ezabatua.
|
|
28
27
|
empty: Oraindik ez dago txantiloirik.
|
|
29
28
|
fetch:
|
|
30
|
-
error: Ezin da
|
|
29
|
+
error: Ezin da plantilla hau aurkitu. Kargatu orria, mesedez.
|
|
31
30
|
missing_resource: "(baliabide galdua)"
|
|
32
31
|
update:
|
|
33
32
|
error: Arazo bat egon da eztabaida hau eguneratzean.
|
|
@@ -43,7 +42,7 @@ eu:
|
|
|
43
42
|
title: Galdeketaren Izenburua
|
|
44
43
|
template:
|
|
45
44
|
fields:
|
|
46
|
-
created_at:
|
|
45
|
+
created_at: Noiz sortua
|
|
47
46
|
name: Txantiloia
|
|
48
47
|
templates:
|
|
49
48
|
admin:
|
|
@@ -61,24 +60,24 @@ eu:
|
|
|
61
60
|
select_template: Hautatu txantiloi-fitxategi bat
|
|
62
61
|
proposal_answer_templates:
|
|
63
62
|
edit:
|
|
64
|
-
title: Editatu proposamenaren erantzun-
|
|
63
|
+
title: Editatu proposamenaren erantzun-txantilioia
|
|
65
64
|
form:
|
|
66
65
|
component_constraint_help: Kontuan izan soilik zerrendatuko direla "proposamenak" motako osagaiak dituzten parte hartzeko espazioak.
|
|
67
66
|
hint1_html: "\n<strong>%{organization}</strong> erakundearen izenak ordezkatuko du."
|
|
68
|
-
hint2_html: "<strong>%{name}</strong> egilearen izenak ordezkatuko du"
|
|
69
|
-
hint3_html: "<strong>%{admin}</strong> administratzailearen izenak ordezkatuko du (proposamenari erantzuten diona)"
|
|
67
|
+
hint2_html: "<strong>%{name}</strong> egilearen izenak ordezkatuko du."
|
|
68
|
+
hint3_html: "<strong>%{admin}</strong> administratzailearen izenak ordezkatuko du (proposamenari erantzuten diona)."
|
|
70
69
|
hint_html: "<strong>Iradokizuna</strong> Aldagarri hauek erantzunaren txantiloiaren edozein lekutan erabil ditzakezu, txantiloia erabiltzean ordezkatuko baitira"
|
|
71
70
|
save: Gorde
|
|
72
71
|
index:
|
|
73
|
-
component_constraint: Gehitu hertsapena
|
|
72
|
+
component_constraint: Gehitu hertsapena.
|
|
74
73
|
confirm_delete: Ziur zaude txantiloi hau ezabatu nahi duzula?
|
|
75
74
|
missing_state: Egoera desagertua
|
|
76
75
|
proposal_state_id: Barne egoera
|
|
77
76
|
title: Proposamenen erantzunak
|
|
78
77
|
new:
|
|
79
|
-
title: Proposamenaren erantzun-
|
|
78
|
+
title: Proposamenaren erantzun-txantilioi berria
|
|
80
79
|
template_chooser:
|
|
81
|
-
select_template: Aukeratu erantzun-txantiloi bat
|
|
80
|
+
select_template: Aukeratu erantzun-txantiloi bat.
|
|
82
81
|
questionnaire_templates:
|
|
83
82
|
choose:
|
|
84
83
|
continue: Jarraitu
|
|
@@ -93,7 +92,7 @@ eu:
|
|
|
93
92
|
empty: Oraindik ez dago galderarik.
|
|
94
93
|
manage_questions: Galderak
|
|
95
94
|
questionnaire: Galdetegia
|
|
96
|
-
title:
|
|
95
|
+
title: Galdetegiaren txantiloia editatu
|
|
97
96
|
edit_questions:
|
|
98
97
|
add_question: Gehitu galdera
|
|
99
98
|
add_separator: Gehitu banatzailea
|
|
@@ -107,7 +106,7 @@ eu:
|
|
|
107
106
|
title: Beste galdetegi-txantiloi bat
|
|
108
107
|
preview:
|
|
109
108
|
current_step: '%{step} urratsa'
|
|
110
|
-
of_total_steps:
|
|
109
|
+
of_total_steps: '%{total_steps} etik'
|
|
111
110
|
tos_agreement: Parte hartzean erabilera-irizpideak eta baldintzak onartzen dituzu
|
|
112
111
|
admin_log:
|
|
113
112
|
template:
|
data/config/locales/fi-plain.yml
CHANGED
data/config/locales/fi.yml
CHANGED
data/config/locales/fr-CA.yml
CHANGED
data/config/locales/fr.yml
CHANGED