decidim-demographics 0.31.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 +7 -0
- data/README.md +26 -0
- data/Rakefile +3 -0
- data/app/commands/decidim/demographics/admin/update_demographics_settings.rb +44 -0
- data/app/commands/decidim/demographics/delete_demographic_data.rb +24 -0
- data/app/controllers/decidim/demographics/admin/application_controller.rb +42 -0
- data/app/controllers/decidim/demographics/admin/publish_responses_controller.rb +24 -0
- data/app/controllers/decidim/demographics/admin/questions_controller.rb +33 -0
- data/app/controllers/decidim/demographics/admin/responses_controller.rb +36 -0
- data/app/controllers/decidim/demographics/admin/settings_controller.rb +33 -0
- data/app/controllers/decidim/demographics/application_controller.rb +17 -0
- data/app/controllers/decidim/demographics/demographics_controller.rb +70 -0
- data/app/forms/decidim/demographics/admin/demographics_settings_form.rb +11 -0
- data/app/helpers/decidim/demographics/publish_responses_helper.rb +104 -0
- data/app/models/decidim/demographics/application_record.rb +10 -0
- data/app/models/decidim/demographics/demographic.rb +9 -0
- data/app/packs/entrypoints/decidim_demographics.js +1 -0
- data/app/packs/stylesheets/decidim/demographics/demographics.scss +37 -0
- data/app/permissions/decidim/demographics/admin/permissions.rb +22 -0
- data/app/permissions/decidim/demographics/permissions.rb +23 -0
- data/app/views/decidim/demographics/admin/demographics/_tabs_menu.html.erb +15 -0
- data/app/views/decidim/demographics/admin/publish_responses/index.html.erb +36 -0
- data/app/views/decidim/demographics/admin/questions/_questions_form.html.erb +74 -0
- data/app/views/decidim/demographics/admin/questions/edit.html.erb +13 -0
- data/app/views/decidim/demographics/admin/responses/index.html.erb +98 -0
- data/app/views/decidim/demographics/admin/settings/show.html.erb +23 -0
- data/app/views/decidim/demographics/demographics/_questionnaire.html.erb +88 -0
- data/app/views/decidim/demographics/demographics/_response.html.erb +41 -0
- data/app/views/decidim/demographics/demographics/responses/_single_option.html.erb +19 -0
- data/app/views/decidim/demographics/demographics/show.html.erb +25 -0
- data/config/assets.rb +8 -0
- data/config/locales/am-ET.yml +1 -0
- data/config/locales/ar.yml +1 -0
- data/config/locales/bg.yml +1 -0
- data/config/locales/bn-BD.yml +1 -0
- data/config/locales/bs-BA.yml +1 -0
- data/config/locales/ca-IT.yml +79 -0
- data/config/locales/ca.yml +79 -0
- data/config/locales/cs.yml +55 -0
- data/config/locales/da.yml +1 -0
- data/config/locales/de.yml +79 -0
- data/config/locales/el.yml +1 -0
- data/config/locales/en.yml +79 -0
- data/config/locales/eo.yml +1 -0
- data/config/locales/es-MX.yml +79 -0
- data/config/locales/es-PY.yml +79 -0
- data/config/locales/es.yml +79 -0
- data/config/locales/et.yml +1 -0
- data/config/locales/eu.yml +79 -0
- data/config/locales/fa-IR.yml +1 -0
- data/config/locales/fi-plain.yml +79 -0
- data/config/locales/fi.yml +79 -0
- data/config/locales/fr-CA.yml +79 -0
- data/config/locales/fr.yml +79 -0
- data/config/locales/ga-IE.yml +1 -0
- data/config/locales/gl.yml +1 -0
- data/config/locales/gn-PY.yml +1 -0
- data/config/locales/he-IL.yml +1 -0
- data/config/locales/hr.yml +1 -0
- data/config/locales/hu.yml +1 -0
- data/config/locales/id-ID.yml +1 -0
- data/config/locales/is-IS.yml +1 -0
- data/config/locales/it.yml +1 -0
- data/config/locales/ja.yml +79 -0
- data/config/locales/ka-GE.yml +1 -0
- data/config/locales/kaa.yml +1 -0
- data/config/locales/ko.yml +1 -0
- data/config/locales/lb.yml +1 -0
- data/config/locales/lo-LA.yml +1 -0
- data/config/locales/lt.yml +1 -0
- data/config/locales/lv.yml +1 -0
- data/config/locales/mt.yml +1 -0
- data/config/locales/nl.yml +1 -0
- data/config/locales/no.yml +8 -0
- data/config/locales/oc-FR.yml +1 -0
- data/config/locales/om-ET.yml +1 -0
- data/config/locales/pl.yml +1 -0
- data/config/locales/pt-BR.yml +1 -0
- data/config/locales/pt.yml +1 -0
- data/config/locales/ro-RO.yml +1 -0
- data/config/locales/ru.yml +1 -0
- data/config/locales/si-LK.yml +1 -0
- data/config/locales/sk.yml +1 -0
- data/config/locales/sl.yml +1 -0
- data/config/locales/so-SO.yml +1 -0
- data/config/locales/sq-AL.yml +1 -0
- data/config/locales/sr-CS.yml +1 -0
- data/config/locales/sv.yml +79 -0
- data/config/locales/sw-KE.yml +1 -0
- data/config/locales/th-TH.yml +1 -0
- data/config/locales/ti-ER.yml +1 -0
- data/config/locales/tr-TR.yml +1 -0
- data/config/locales/uk.yml +1 -0
- data/config/locales/val-ES.yml +1 -0
- data/config/locales/vi.yml +1 -0
- data/config/locales/zh-CN.yml +1 -0
- data/config/locales/zh-TW.yml +1 -0
- data/db/migrate/20250305200253_create_decidim_demographics_demographics.rb +12 -0
- data/decidim-demographics.gemspec +37 -0
- data/lib/decidim/demographics/admin.rb +10 -0
- data/lib/decidim/demographics/admin_engine.rb +83 -0
- data/lib/decidim/demographics/engine.rb +41 -0
- data/lib/decidim/demographics/test/factories.rb +16 -0
- data/lib/decidim/demographics/version.rb +10 -0
- data/lib/decidim/demographics.rb +52 -0
- data/lib/tasks/decidim_demographics.rake +14 -0
- metadata +195 -0
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require "decidim/demographics/admin"
|
|
4
|
+
require "decidim/demographics/engine"
|
|
5
|
+
require "decidim/demographics/admin_engine"
|
|
6
|
+
|
|
7
|
+
module Decidim
|
|
8
|
+
# This namespace holds the logic of the `Demographics` component. This component
|
|
9
|
+
# allows users to create demographics in a participatory space.
|
|
10
|
+
module Demographics
|
|
11
|
+
# i18n-tasks-use t('decidim.demographics.questions.age.question')
|
|
12
|
+
# i18n-tasks-use t('decidim.demographics.questions.age.options')
|
|
13
|
+
# i18n-tasks-use t('decidim.demographics.questions.gender.question')
|
|
14
|
+
# i18n-tasks-use t('decidim.demographics.questions.gender.options')
|
|
15
|
+
# i18n-tasks-use t('decidim.demographics.questions.postal.question')
|
|
16
|
+
def self.create_default_questionnaire!(questionnaire)
|
|
17
|
+
return if questionnaire.persisted?
|
|
18
|
+
|
|
19
|
+
questionnaire.save!
|
|
20
|
+
|
|
21
|
+
locales = questionnaire.questionnaire_for.organization.available_locales
|
|
22
|
+
|
|
23
|
+
scope = "decidim.demographics.questions"
|
|
24
|
+
|
|
25
|
+
first_question = questionnaire.questions.create!(
|
|
26
|
+
position: 0,
|
|
27
|
+
question_type: "single_option",
|
|
28
|
+
body: locales.index_with { |key| I18n.with_locale(key) { I18n.t("age.question", scope:) } }
|
|
29
|
+
)
|
|
30
|
+
|
|
31
|
+
I18n.t("age.options", scope:).each_with_index do |_o, index|
|
|
32
|
+
first_question.response_options.create!(body: locales.index_with { |key| I18n.with_locale(key) { I18n.t("age.options", scope:)[index] } }, free_text: false)
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
second_question = questionnaire.questions.create!(
|
|
36
|
+
position: 1,
|
|
37
|
+
question_type: "single_option",
|
|
38
|
+
body: locales.index_with { |key| I18n.with_locale(key) { I18n.t("gender.question", scope:) } }
|
|
39
|
+
)
|
|
40
|
+
|
|
41
|
+
I18n.t("gender.options", scope:).each_with_index do |_o, index|
|
|
42
|
+
second_question.response_options.create!(body: locales.index_with { |key| I18n.with_locale(key) { I18n.t("gender.options", scope:)[index] } }, free_text: false)
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
questionnaire.questions.create!(
|
|
46
|
+
position: 2,
|
|
47
|
+
question_type: "short_response",
|
|
48
|
+
body: locales.index_with { |key| I18n.with_locale(key) { I18n.t("postal.question", scope:) } }
|
|
49
|
+
)
|
|
50
|
+
end
|
|
51
|
+
end
|
|
52
|
+
end
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
namespace :decidim do
|
|
4
|
+
namespace :demographics do
|
|
5
|
+
desc "Setup environment so that only decidim migrations are installed."
|
|
6
|
+
task :choose_target_plugins do
|
|
7
|
+
ENV["FROM"] = "#{ENV.fetch("FROM", nil)},decidim_demographics"
|
|
8
|
+
end
|
|
9
|
+
end
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
Rake::Task["decidim:choose_target_plugins"].enhance do
|
|
13
|
+
Rake::Task["decidim:demographics:choose_target_plugins"].invoke
|
|
14
|
+
end
|
metadata
ADDED
|
@@ -0,0 +1,195 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: decidim-demographics
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 0.31.0.rc1
|
|
5
|
+
platform: ruby
|
|
6
|
+
authors:
|
|
7
|
+
- Alexandru-Emil Lupu
|
|
8
|
+
autorequire:
|
|
9
|
+
bindir: bin
|
|
10
|
+
cert_chain: []
|
|
11
|
+
date: 2025-09-25 00:00:00.000000000 Z
|
|
12
|
+
dependencies:
|
|
13
|
+
- !ruby/object:Gem::Dependency
|
|
14
|
+
name: decidim-core
|
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
|
16
|
+
requirements:
|
|
17
|
+
- - '='
|
|
18
|
+
- !ruby/object:Gem::Version
|
|
19
|
+
version: 0.31.0.rc1
|
|
20
|
+
type: :runtime
|
|
21
|
+
prerelease: false
|
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
23
|
+
requirements:
|
|
24
|
+
- - '='
|
|
25
|
+
- !ruby/object:Gem::Version
|
|
26
|
+
version: 0.31.0.rc1
|
|
27
|
+
- !ruby/object:Gem::Dependency
|
|
28
|
+
name: decidim-forms
|
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
|
30
|
+
requirements:
|
|
31
|
+
- - '='
|
|
32
|
+
- !ruby/object:Gem::Version
|
|
33
|
+
version: 0.31.0.rc1
|
|
34
|
+
type: :runtime
|
|
35
|
+
prerelease: false
|
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
37
|
+
requirements:
|
|
38
|
+
- - '='
|
|
39
|
+
- !ruby/object:Gem::Version
|
|
40
|
+
version: 0.31.0.rc1
|
|
41
|
+
- !ruby/object:Gem::Dependency
|
|
42
|
+
name: decidim-dev
|
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
|
44
|
+
requirements:
|
|
45
|
+
- - '='
|
|
46
|
+
- !ruby/object:Gem::Version
|
|
47
|
+
version: 0.31.0.rc1
|
|
48
|
+
type: :development
|
|
49
|
+
prerelease: false
|
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
51
|
+
requirements:
|
|
52
|
+
- - '='
|
|
53
|
+
- !ruby/object:Gem::Version
|
|
54
|
+
version: 0.31.0.rc1
|
|
55
|
+
description: Module that collects demographic data about participants.
|
|
56
|
+
email:
|
|
57
|
+
- contact@alecslupu.ro
|
|
58
|
+
executables: []
|
|
59
|
+
extensions: []
|
|
60
|
+
extra_rdoc_files: []
|
|
61
|
+
files:
|
|
62
|
+
- README.md
|
|
63
|
+
- Rakefile
|
|
64
|
+
- app/commands/decidim/demographics/admin/update_demographics_settings.rb
|
|
65
|
+
- app/commands/decidim/demographics/delete_demographic_data.rb
|
|
66
|
+
- app/controllers/decidim/demographics/admin/application_controller.rb
|
|
67
|
+
- app/controllers/decidim/demographics/admin/publish_responses_controller.rb
|
|
68
|
+
- app/controllers/decidim/demographics/admin/questions_controller.rb
|
|
69
|
+
- app/controllers/decidim/demographics/admin/responses_controller.rb
|
|
70
|
+
- app/controllers/decidim/demographics/admin/settings_controller.rb
|
|
71
|
+
- app/controllers/decidim/demographics/application_controller.rb
|
|
72
|
+
- app/controllers/decidim/demographics/demographics_controller.rb
|
|
73
|
+
- app/forms/decidim/demographics/admin/demographics_settings_form.rb
|
|
74
|
+
- app/helpers/decidim/demographics/publish_responses_helper.rb
|
|
75
|
+
- app/models/decidim/demographics/application_record.rb
|
|
76
|
+
- app/models/decidim/demographics/demographic.rb
|
|
77
|
+
- app/packs/entrypoints/decidim_demographics.js
|
|
78
|
+
- app/packs/stylesheets/decidim/demographics/demographics.scss
|
|
79
|
+
- app/permissions/decidim/demographics/admin/permissions.rb
|
|
80
|
+
- app/permissions/decidim/demographics/permissions.rb
|
|
81
|
+
- app/views/decidim/demographics/admin/demographics/_tabs_menu.html.erb
|
|
82
|
+
- app/views/decidim/demographics/admin/publish_responses/index.html.erb
|
|
83
|
+
- app/views/decidim/demographics/admin/questions/_questions_form.html.erb
|
|
84
|
+
- app/views/decidim/demographics/admin/questions/edit.html.erb
|
|
85
|
+
- app/views/decidim/demographics/admin/responses/index.html.erb
|
|
86
|
+
- app/views/decidim/demographics/admin/settings/show.html.erb
|
|
87
|
+
- app/views/decidim/demographics/demographics/_questionnaire.html.erb
|
|
88
|
+
- app/views/decidim/demographics/demographics/_response.html.erb
|
|
89
|
+
- app/views/decidim/demographics/demographics/responses/_single_option.html.erb
|
|
90
|
+
- app/views/decidim/demographics/demographics/show.html.erb
|
|
91
|
+
- config/assets.rb
|
|
92
|
+
- config/locales/am-ET.yml
|
|
93
|
+
- config/locales/ar.yml
|
|
94
|
+
- config/locales/bg.yml
|
|
95
|
+
- config/locales/bn-BD.yml
|
|
96
|
+
- config/locales/bs-BA.yml
|
|
97
|
+
- config/locales/ca-IT.yml
|
|
98
|
+
- config/locales/ca.yml
|
|
99
|
+
- config/locales/cs.yml
|
|
100
|
+
- config/locales/da.yml
|
|
101
|
+
- config/locales/de.yml
|
|
102
|
+
- config/locales/el.yml
|
|
103
|
+
- config/locales/en.yml
|
|
104
|
+
- config/locales/eo.yml
|
|
105
|
+
- config/locales/es-MX.yml
|
|
106
|
+
- config/locales/es-PY.yml
|
|
107
|
+
- config/locales/es.yml
|
|
108
|
+
- config/locales/et.yml
|
|
109
|
+
- config/locales/eu.yml
|
|
110
|
+
- config/locales/fa-IR.yml
|
|
111
|
+
- config/locales/fi-plain.yml
|
|
112
|
+
- config/locales/fi.yml
|
|
113
|
+
- config/locales/fr-CA.yml
|
|
114
|
+
- config/locales/fr.yml
|
|
115
|
+
- config/locales/ga-IE.yml
|
|
116
|
+
- config/locales/gl.yml
|
|
117
|
+
- config/locales/gn-PY.yml
|
|
118
|
+
- config/locales/he-IL.yml
|
|
119
|
+
- config/locales/hr.yml
|
|
120
|
+
- config/locales/hu.yml
|
|
121
|
+
- config/locales/id-ID.yml
|
|
122
|
+
- config/locales/is-IS.yml
|
|
123
|
+
- config/locales/it.yml
|
|
124
|
+
- config/locales/ja.yml
|
|
125
|
+
- config/locales/ka-GE.yml
|
|
126
|
+
- config/locales/kaa.yml
|
|
127
|
+
- config/locales/ko.yml
|
|
128
|
+
- config/locales/lb.yml
|
|
129
|
+
- config/locales/lo-LA.yml
|
|
130
|
+
- config/locales/lt.yml
|
|
131
|
+
- config/locales/lv.yml
|
|
132
|
+
- config/locales/mt.yml
|
|
133
|
+
- config/locales/nl.yml
|
|
134
|
+
- config/locales/no.yml
|
|
135
|
+
- config/locales/oc-FR.yml
|
|
136
|
+
- config/locales/om-ET.yml
|
|
137
|
+
- config/locales/pl.yml
|
|
138
|
+
- config/locales/pt-BR.yml
|
|
139
|
+
- config/locales/pt.yml
|
|
140
|
+
- config/locales/ro-RO.yml
|
|
141
|
+
- config/locales/ru.yml
|
|
142
|
+
- config/locales/si-LK.yml
|
|
143
|
+
- config/locales/sk.yml
|
|
144
|
+
- config/locales/sl.yml
|
|
145
|
+
- config/locales/so-SO.yml
|
|
146
|
+
- config/locales/sq-AL.yml
|
|
147
|
+
- config/locales/sr-CS.yml
|
|
148
|
+
- config/locales/sv.yml
|
|
149
|
+
- config/locales/sw-KE.yml
|
|
150
|
+
- config/locales/th-TH.yml
|
|
151
|
+
- config/locales/ti-ER.yml
|
|
152
|
+
- config/locales/tr-TR.yml
|
|
153
|
+
- config/locales/uk.yml
|
|
154
|
+
- config/locales/val-ES.yml
|
|
155
|
+
- config/locales/vi.yml
|
|
156
|
+
- config/locales/zh-CN.yml
|
|
157
|
+
- config/locales/zh-TW.yml
|
|
158
|
+
- db/migrate/20250305200253_create_decidim_demographics_demographics.rb
|
|
159
|
+
- decidim-demographics.gemspec
|
|
160
|
+
- lib/decidim/demographics.rb
|
|
161
|
+
- lib/decidim/demographics/admin.rb
|
|
162
|
+
- lib/decidim/demographics/admin_engine.rb
|
|
163
|
+
- lib/decidim/demographics/engine.rb
|
|
164
|
+
- lib/decidim/demographics/test/factories.rb
|
|
165
|
+
- lib/decidim/demographics/version.rb
|
|
166
|
+
- lib/tasks/decidim_demographics.rake
|
|
167
|
+
homepage: https://decidim.org
|
|
168
|
+
licenses:
|
|
169
|
+
- AGPL-3.0-or-later
|
|
170
|
+
metadata:
|
|
171
|
+
bug_tracker_uri: https://github.com/decidim/decidim/issues
|
|
172
|
+
documentation_uri: https://docs.decidim.org/
|
|
173
|
+
funding_uri: https://opencollective.com/decidim
|
|
174
|
+
homepage_uri: https://decidim.org
|
|
175
|
+
source_code_uri: https://github.com/decidim/decidim
|
|
176
|
+
post_install_message:
|
|
177
|
+
rdoc_options: []
|
|
178
|
+
require_paths:
|
|
179
|
+
- lib
|
|
180
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
181
|
+
requirements:
|
|
182
|
+
- - "~>"
|
|
183
|
+
- !ruby/object:Gem::Version
|
|
184
|
+
version: 3.3.0
|
|
185
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
186
|
+
requirements:
|
|
187
|
+
- - ">="
|
|
188
|
+
- !ruby/object:Gem::Version
|
|
189
|
+
version: '0'
|
|
190
|
+
requirements: []
|
|
191
|
+
rubygems_version: 3.5.11
|
|
192
|
+
signing_key:
|
|
193
|
+
specification_version: 4
|
|
194
|
+
summary: A decidim demographics module
|
|
195
|
+
test_files: []
|