decidim-generators 0.26.2 → 0.27.0.rc2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +2 -2
- data/Gemfile.lock +310 -279
- data/exe/decidim +28 -1
- data/lib/decidim/generators/app_generator.rb +130 -13
- data/lib/decidim/generators/app_templates/database.yml.erb +1 -1
- data/lib/decidim/generators/app_templates/dummy_authorization_handler.rb +1 -1
- data/lib/decidim/generators/app_templates/initializer.rb +214 -23
- data/lib/decidim/generators/app_templates/secrets.yml.erb +133 -14
- data/lib/decidim/generators/app_templates/sidekiq.yml.erb +16 -0
- data/lib/decidim/generators/app_templates/storage.yml.erb +42 -0
- data/lib/decidim/generators/component_templates/Gemfile.erb +2 -2
- data/lib/decidim/generators/component_templates/decidim-component.gemspec.erb +1 -1
- data/lib/decidim/generators/install_generator.rb +7 -0
- data/lib/decidim/generators/test/generator_examples.rb +1074 -0
- data/lib/decidim/generators/version.rb +1 -1
- metadata +13 -10
data/exe/decidim
CHANGED
@@ -28,7 +28,34 @@ Options:
|
|
28
28
|
--help display this help and exit
|
29
29
|
--version output version information and exit
|
30
30
|
--component [name] creates a component for Decidim
|
31
|
-
[name] creates an application based on Decidim
|
31
|
+
[name] creates an application based on Decidim
|
32
|
+
|
33
|
+
App generation extra options (ignored if the --component flag is on):
|
34
|
+
--storage [provider] Setup the Gemfile with the appropiate gem to handle a storage provider. Supported options are: local (default), s3, gcs, azure
|
35
|
+
--queue [provider] Setup the Gemfile with the appropiate gem to handle a job queue backend. Only 'sidekiq' is supported as option for now.
|
36
|
+
--force_ssl [true|false] Enables or disables mandatory redirection to HTTPS (defaults to enabled)
|
37
|
+
--locales [locales] Force the available locales to the ones specified. Separate with comas
|
38
|
+
Warning: this option disables the ENV var DECIDIM_AVAILABLE_LOCALES used to setup this configuration by default.
|
39
|
+
--profiling Adds profiling gems for development
|
40
|
+
--path Use a local path for the Gemfile instead of the last decidim gem version available
|
41
|
+
--edge Use GitHub's develop branch instead of the last decidim gem version available
|
42
|
+
--branch [branch] Use GitHub's specified branch instead of the last decidim gem version available
|
43
|
+
--repository Use a custom GIT repository instead of the default https::/github.com/decidim/decidim
|
44
|
+
--skip_gemfile Skip Gemfile processing
|
45
|
+
--skip_bundle Do not run bundle install
|
46
|
+
--skip_webpack_install Do not run webpacker initialization (webpack install)
|
47
|
+
--demo Create a demo application, with seeds, all the optional modules enabled and some authorization examples
|
48
|
+
--seed_db [true|false] Seed the database: generate demo data for each participatory space and component
|
49
|
+
--recreate_db Recreate the database after installing Decidim
|
50
|
+
|
51
|
+
Examples:
|
52
|
+
decidim my-application
|
53
|
+
decidim --storage=s3 my-application
|
54
|
+
decidim --storage=s3,gcs --profiling --force_ssl=false my-application
|
55
|
+
decidim --locales=en,ca,es,fr my-application
|
56
|
+
decidim --queue sidekiq my-application
|
57
|
+
decidim --queue sidekiq --storage s3 my-application
|
58
|
+
"
|
32
59
|
else
|
33
60
|
require "decidim/generators/app_generator"
|
34
61
|
|
@@ -41,6 +41,10 @@ module Decidim
|
|
41
41
|
default: nil,
|
42
42
|
desc: "Use a specific branch from GitHub's version"
|
43
43
|
|
44
|
+
class_option :repository, type: :string,
|
45
|
+
default: "https://github.com/decidim/decidim.git",
|
46
|
+
desc: "Use a specific GIT repository (valid in conjunction with --edge or --branch)"
|
47
|
+
|
44
48
|
class_option :recreate_db, type: :boolean,
|
45
49
|
default: false,
|
46
50
|
desc: "Recreate test database"
|
@@ -50,7 +54,7 @@ module Decidim
|
|
50
54
|
desc: "Seed test database"
|
51
55
|
|
52
56
|
class_option :skip_bundle, type: :boolean,
|
53
|
-
default: true,
|
57
|
+
default: true, # this is to avoid installing gems in this step yet (done by InstallGenerator)
|
54
58
|
desc: "Don't run bundle install"
|
55
59
|
|
56
60
|
class_option :skip_gemfile, type: :boolean,
|
@@ -69,10 +73,26 @@ module Decidim
|
|
69
73
|
default: "true",
|
70
74
|
desc: "Doesn't force to use ssl"
|
71
75
|
|
76
|
+
class_option :locales, type: :string,
|
77
|
+
default: "",
|
78
|
+
desc: "Force the available locales to the ones specified. Separate with comas"
|
79
|
+
|
80
|
+
class_option :storage, type: :string,
|
81
|
+
default: "local",
|
82
|
+
desc: "Setup the Gemfile with the appropiate gem to handle a storage provider. Supported options are: local (default), s3, gcs, azure"
|
83
|
+
|
84
|
+
class_option :queue, type: :string,
|
85
|
+
default: "",
|
86
|
+
desc: "Setup the Gemfile with the appropiate gem to handle a queue adapter provider. Supported options are: (empty, does nothing) and sidekiq"
|
87
|
+
|
72
88
|
class_option :skip_webpack_install, type: :boolean,
|
73
89
|
default: true,
|
74
90
|
desc: "Don't run Webpack install"
|
75
91
|
|
92
|
+
class_option :dev_ssl, type: :boolean,
|
93
|
+
default: false,
|
94
|
+
desc: "Don't add Puma development SSL configuration options"
|
95
|
+
|
76
96
|
def database_yml
|
77
97
|
template "database.yml.erb", "config/database.yml", force: true
|
78
98
|
end
|
@@ -115,19 +135,72 @@ module Decidim
|
|
115
135
|
|
116
136
|
gsub_file "Gemfile", /gem "#{current_gem}".*/, "gem \"#{current_gem}\", #{gem_modifier}"
|
117
137
|
|
118
|
-
|
119
|
-
|
138
|
+
return unless current_gem == "decidim"
|
139
|
+
|
140
|
+
gsub_file "Gemfile", /gem "decidim-dev".*/, "gem \"decidim-dev\", #{gem_modifier}"
|
141
|
+
|
142
|
+
%w(conferences consultations elections initiatives templates).each do |component|
|
143
|
+
if options[:demo]
|
144
|
+
gsub_file "Gemfile", /gem "decidim-#{component}".*/, "gem \"decidim-#{component}\", #{gem_modifier}"
|
145
|
+
else
|
146
|
+
gsub_file "Gemfile", /gem "decidim-#{component}".*/, "# gem \"decidim-#{component}\", #{gem_modifier}"
|
147
|
+
end
|
148
|
+
end
|
149
|
+
end
|
150
|
+
|
151
|
+
def add_storage_provider
|
152
|
+
template "storage.yml.erb", "config/storage.yml", force: true
|
153
|
+
|
154
|
+
providers = options[:storage].split(",")
|
155
|
+
|
156
|
+
abort("#{providers} is not supported as storage provider, please use local, s3, gcs or azure") unless (providers - %w(local s3 gcs azure)).empty?
|
157
|
+
gsub_file "config/environments/production.rb",
|
158
|
+
/config.active_storage.service = :local/,
|
159
|
+
"config.active_storage.service = Rails.application.secrets.dig(:storage, :provider) || :local"
|
160
|
+
|
161
|
+
add_production_gems do
|
162
|
+
gem "aws-sdk-s3", require: false if providers.include?("s3")
|
163
|
+
gem "azure-storage-blob", require: false if providers.include?("azure")
|
164
|
+
gem "google-cloud-storage", "~> 1.11", require: false if providers.include?("gcs")
|
165
|
+
end
|
166
|
+
end
|
167
|
+
|
168
|
+
def add_queue_adapter
|
169
|
+
adapter = options[:queue]
|
170
|
+
|
171
|
+
abort("#{adapter} is not supported as a queue adapter, please use sidekiq for the moment") unless adapter.in?(["", "sidekiq"])
|
172
|
+
|
173
|
+
return unless adapter == "sidekiq"
|
174
|
+
|
175
|
+
template "sidekiq.yml.erb", "config/sidekiq.yml", force: true
|
176
|
+
|
177
|
+
gsub_file "config/environments/production.rb",
|
178
|
+
/# config.active_job.queue_adapter = :resque/,
|
179
|
+
"config.active_job.queue_adapter = ENV['QUEUE_ADAPTER'] if ENV['QUEUE_ADAPTER'].present?"
|
120
180
|
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
gsub_file "Gemfile", /gem "decidim-#{component}".*/, "# gem \"decidim-#{component}\", #{gem_modifier}"
|
126
|
-
end
|
181
|
+
prepend_file "config/routes.rb", "require \"sidekiq/web\"\n\n"
|
182
|
+
route <<~RUBY
|
183
|
+
authenticate :user, ->(u) { u.admin? } do
|
184
|
+
mount Sidekiq::Web => "/sidekiq"
|
127
185
|
end
|
186
|
+
RUBY
|
187
|
+
|
188
|
+
add_production_gems do
|
189
|
+
gem "sidekiq"
|
128
190
|
end
|
191
|
+
end
|
129
192
|
|
130
|
-
|
193
|
+
def add_production_gems(&block)
|
194
|
+
return if options[:skip_gemfile]
|
195
|
+
|
196
|
+
if block
|
197
|
+
@production_gems ||= []
|
198
|
+
@production_gems << block
|
199
|
+
elsif @production_gems.present?
|
200
|
+
gem_group :production do
|
201
|
+
@production_gems.map(&:call)
|
202
|
+
end
|
203
|
+
end
|
131
204
|
end
|
132
205
|
|
133
206
|
def tweak_bootsnap
|
@@ -146,6 +219,30 @@ module Decidim
|
|
146
219
|
RUBY
|
147
220
|
end
|
148
221
|
|
222
|
+
def tweak_spring
|
223
|
+
return unless File.exist?("config/spring.rb")
|
224
|
+
|
225
|
+
prepend_to_file "config/spring.rb", "require \"decidim/spring\"\n\n"
|
226
|
+
end
|
227
|
+
|
228
|
+
def puma_ssl_options
|
229
|
+
return unless options[:dev_ssl]
|
230
|
+
|
231
|
+
append_file "config/puma.rb", <<~CONFIG
|
232
|
+
|
233
|
+
# Development SSL
|
234
|
+
if ENV["DEV_SSL"] && defined?(Bundler) && (dev_gem = Bundler.load.specs.find { |spec| spec.name == "decidim-dev" })
|
235
|
+
cert_dir = ENV.fetch("DEV_SSL_DIR") { "\#{dev_gem.full_gem_path}/lib/decidim/dev/assets" }
|
236
|
+
ssl_bind(
|
237
|
+
"0.0.0.0",
|
238
|
+
ENV.fetch("DEV_SSL_PORT") { 3443 },
|
239
|
+
cert_pem: File.read("\#{cert_dir}/ssl-cert.pem"),
|
240
|
+
key_pem: File.read("\#{cert_dir}/ssl-key.pem")
|
241
|
+
)
|
242
|
+
end
|
243
|
+
CONFIG
|
244
|
+
end
|
245
|
+
|
149
246
|
def add_ignore_uploads
|
150
247
|
append_file ".gitignore", "\n# Ignore public uploads\npublic/uploads" unless options["skip_git"]
|
151
248
|
end
|
@@ -158,11 +255,27 @@ module Decidim
|
|
158
255
|
def decidim_initializer
|
159
256
|
copy_file "initializer.rb", "config/initializers/decidim.rb"
|
160
257
|
|
258
|
+
gsub_file "config/environments/production.rb",
|
259
|
+
/config.log_level = :info/,
|
260
|
+
"config.log_level = %w(debug info warn error fatal).include?(ENV['RAILS_LOG_LEVEL']) ? ENV['RAILS_LOG_LEVEL'] : :info"
|
261
|
+
|
262
|
+
gsub_file "config/environments/production.rb",
|
263
|
+
%r{# config.asset_host = 'http://assets.example.com'},
|
264
|
+
"config.asset_host = ENV['RAILS_ASSET_HOST'] if ENV['RAILS_ASSET_HOST'].present?"
|
265
|
+
|
161
266
|
if options[:force_ssl] == "false"
|
162
267
|
gsub_file "config/initializers/decidim.rb",
|
163
268
|
/# config.force_ssl = true/,
|
164
269
|
"config.force_ssl = false"
|
165
270
|
end
|
271
|
+
return if options[:locales].blank?
|
272
|
+
|
273
|
+
gsub_file "config/initializers/decidim.rb",
|
274
|
+
/#{Regexp.escape("# config.available_locales = %w(en ca es)")}/,
|
275
|
+
"config.available_locales = %w(#{options[:locales].gsub(",", " ")})"
|
276
|
+
gsub_file "config/initializers/decidim.rb",
|
277
|
+
/#{Regexp.escape("config.available_locales = Rails.application.secrets.decidim[:available_locales].presence || [:en]")}/,
|
278
|
+
"# config.available_locales = Rails.application.secrets.decidim[:available_locales].presence || [:en]"
|
166
279
|
end
|
167
280
|
|
168
281
|
def authorization_handler
|
@@ -230,11 +343,11 @@ module Decidim
|
|
230
343
|
|
231
344
|
def gem_modifier
|
232
345
|
@gem_modifier ||= if options[:path]
|
233
|
-
|
346
|
+
%(path: "#{options[:path]}")
|
234
347
|
elsif branch.present?
|
235
|
-
|
348
|
+
%(git: "#{repository}", branch: "#{branch}")
|
236
349
|
else
|
237
|
-
"
|
350
|
+
%("#{Decidim::Generators.version}")
|
238
351
|
end
|
239
352
|
end
|
240
353
|
|
@@ -244,6 +357,10 @@ module Decidim
|
|
244
357
|
@branch ||= options[:edge] ? Decidim::Generators.edge_git_branch : options[:branch].presence
|
245
358
|
end
|
246
359
|
|
360
|
+
def repository
|
361
|
+
@repository ||= options[:repository] || "https://github.com/decidim/decidim.git"
|
362
|
+
end
|
363
|
+
|
247
364
|
def app_name
|
248
365
|
options[:app_name] || super
|
249
366
|
end
|
@@ -63,7 +63,7 @@ development:
|
|
63
63
|
# Do not set this db to the same as development or production.
|
64
64
|
test:
|
65
65
|
<<: *default
|
66
|
-
database: <%= app_name %>_test
|
66
|
+
database: <%= app_name %>_test<%%= ENV.fetch('TEST_ENV_NUMBER', "") %>
|
67
67
|
|
68
68
|
# As with config/secrets.yml, you never want to store sensitive information,
|
69
69
|
# like your database password, in your source code. If your source code is
|
@@ -21,7 +21,7 @@
|
|
21
21
|
# See Decidim::AuthorizationHandler for more documentation.
|
22
22
|
class DummyAuthorizationHandler < Decidim::AuthorizationHandler
|
23
23
|
# Define the attributes you need for this authorization handler. Attributes
|
24
|
-
# are defined using
|
24
|
+
# are defined using Decidim::AttributeObject.
|
25
25
|
#
|
26
26
|
attribute :name_and_surname, String
|
27
27
|
attribute :document_number, String
|
@@ -2,27 +2,29 @@
|
|
2
2
|
|
3
3
|
Decidim.configure do |config|
|
4
4
|
# The name of the application
|
5
|
-
config.application_name =
|
5
|
+
config.application_name = Rails.application.secrets.decidim[:application_name]
|
6
6
|
|
7
7
|
# The email that will be used as sender in all emails from Decidim
|
8
|
-
config.mailer_sender =
|
8
|
+
config.mailer_sender = Rails.application.secrets.decidim[:mailer_sender]
|
9
9
|
|
10
10
|
# Sets the list of available locales for the whole application.
|
11
11
|
#
|
12
12
|
# When an organization is created through the System area, system admins will
|
13
13
|
# be able to choose the available languages for that organization. That list
|
14
14
|
# of languages will be equal or a subset of the list in this file.
|
15
|
-
config.available_locales = [:
|
15
|
+
config.available_locales = Rails.application.secrets.decidim[:available_locales].presence || [:en]
|
16
|
+
# Or block set it up manually and prevent ENV manipulation:
|
17
|
+
# config.available_locales = %w(en ca es)
|
16
18
|
|
17
19
|
# Sets the default locale for new organizations. When creating a new
|
18
20
|
# organization from the System area, system admins will be able to overwrite
|
19
21
|
# this value for that specific organization.
|
20
|
-
config.default_locale = :en
|
22
|
+
config.default_locale = Rails.application.secrets.decidim[:default_locale].presence || :en
|
21
23
|
|
22
24
|
# Restrict access to the system part with an authorized ip list.
|
23
25
|
# You can use a single ip like ("1.2.3.4"), or an ip subnet like ("1.2.3.4/24")
|
24
26
|
# You may specify multiple ip in an array ["1.2.3.4", "1.2.3.4/24"]
|
25
|
-
|
27
|
+
config.system_accesslist_ips = Rails.application.secrets.decidim[:system_accesslist_ips] if Rails.application.secrets.decidim[:system_accesslist_ips].present?
|
26
28
|
|
27
29
|
# Defines a list of custom content processors. They are used to parse and
|
28
30
|
# render specific tags inside some user-provided content. Check the docs for
|
@@ -30,8 +32,14 @@ Decidim.configure do |config|
|
|
30
32
|
# config.content_processors = []
|
31
33
|
|
32
34
|
# Whether SSL should be enabled or not.
|
35
|
+
# if this var is not defined, it is decided automatically per-rails-environment
|
36
|
+
config.force_ssl = Rails.application.secrets.decidim[:force_ssl].present? unless Rails.application.secrets.decidim[:force_ssl] == "auto"
|
37
|
+
# or set it up manually and prevent any ENV manipulation:
|
33
38
|
# config.force_ssl = true
|
34
39
|
|
40
|
+
# Enable the service worker. By default is disabled in development and enabled in the rest of environments
|
41
|
+
config.service_worker_enabled = Rails.application.secrets.decidim[:service_worker_enabled].present?
|
42
|
+
|
35
43
|
# Map and Geocoder configuration
|
36
44
|
#
|
37
45
|
# == HERE Maps ==
|
@@ -98,6 +106,40 @@ Decidim.configure do |config|
|
|
98
106
|
# cache: Redis.new,
|
99
107
|
# cache_prefix: "..."
|
100
108
|
# }
|
109
|
+
if Rails.application.secrets.maps.present? && Rails.application.secrets.maps[:static_provider].present?
|
110
|
+
static_provider = Rails.application.secrets.maps[:static_provider]
|
111
|
+
dynamic_provider = Rails.application.secrets.maps[:dynamic_provider]
|
112
|
+
dynamic_url = Rails.application.secrets.maps[:dynamic_url]
|
113
|
+
static_url = Rails.application.secrets.maps[:static_url]
|
114
|
+
static_url = "https://image.maps.ls.hereapi.com/mia/1.6/mapview" if static_provider == "here" && static_url.blank?
|
115
|
+
config.maps = {
|
116
|
+
provider: static_provider,
|
117
|
+
api_key: Rails.application.secrets.maps[:static_api_key],
|
118
|
+
static: { url: static_url },
|
119
|
+
dynamic: {
|
120
|
+
provider: dynamic_provider,
|
121
|
+
api_key: Rails.application.secrets.maps[:dynamic_api_key]
|
122
|
+
}
|
123
|
+
}
|
124
|
+
config.maps[:geocoding] = { host: Rails.application.secrets.maps[:geocoding_host], use_https: true } if Rails.application.secrets.maps[:geocoding_host]
|
125
|
+
config.maps[:dynamic][:tile_layer] = {}
|
126
|
+
config.maps[:dynamic][:tile_layer][:url] = dynamic_url if dynamic_url
|
127
|
+
config.maps[:dynamic][:tile_layer][:attribution] = Rails.application.secrets.maps[:attribution] if Rails.application.secrets.maps[:attribution]
|
128
|
+
if Rails.application.secrets.maps[:extra_vars].present?
|
129
|
+
vars = URI.decode_www_form(Rails.application.secrets.maps[:extra_vars])
|
130
|
+
vars.each do |key, value|
|
131
|
+
# perform a naive type conversion
|
132
|
+
config.maps[:dynamic][:tile_layer][key] = case value
|
133
|
+
when /^true$|^false$/i
|
134
|
+
value.downcase == "true"
|
135
|
+
when /\A[-+]?\d+\z/
|
136
|
+
value.to_i
|
137
|
+
else
|
138
|
+
value
|
139
|
+
end
|
140
|
+
end
|
141
|
+
end
|
142
|
+
end
|
101
143
|
|
102
144
|
# Custom resource reference generator method. Check the docs for more info.
|
103
145
|
# config.reference_generator = lambda do |resource, component|
|
@@ -106,14 +148,20 @@ Decidim.configure do |config|
|
|
106
148
|
# end
|
107
149
|
|
108
150
|
# Currency unit
|
109
|
-
|
151
|
+
config.currency_unit = Rails.application.secrets.decidim[:currency_unit] if Rails.application.secrets.decidim[:currency_unit].present?
|
152
|
+
|
153
|
+
# Workaround to enable SVG assets cors
|
154
|
+
config.cors_enabled = Rails.application.secrets.decidim[:cors_enabled].present?
|
110
155
|
|
111
156
|
# Defines the quality of image uploads after processing. Image uploads are
|
112
157
|
# processed by Decidim, this value helps reduce the size of the files.
|
113
|
-
|
158
|
+
config.image_uploader_quality = Rails.application.secrets.decidim[:image_uploader_quality].to_i
|
159
|
+
|
160
|
+
config.maximum_attachment_size = Rails.application.secrets.decidim[:maximum_attachment_size].to_i.megabytes
|
161
|
+
config.maximum_avatar_size = Rails.application.secrets.decidim[:maximum_avatar_size].to_i.megabytes
|
114
162
|
|
115
163
|
# The number of reports which a resource can receive before hiding it
|
116
|
-
|
164
|
+
config.max_reports_before_hiding = Rails.application.secrets.decidim[:max_reports_before_hiding].to_i
|
117
165
|
|
118
166
|
# Custom HTML Header snippets
|
119
167
|
#
|
@@ -128,22 +176,22 @@ Decidim.configure do |config|
|
|
128
176
|
# that an organization's administrator injects malicious scripts to spy on or
|
129
177
|
# take over user accounts.
|
130
178
|
#
|
131
|
-
config.enable_html_header_snippets =
|
179
|
+
config.enable_html_header_snippets = Rails.application.secrets.decidim[:enable_html_header_snippets].present?
|
132
180
|
|
133
181
|
# Allow organizations admins to track newsletter links.
|
134
|
-
|
182
|
+
config.track_newsletter_links = Rails.application.secrets.decidim[:track_newsletter_links].present? unless Rails.application.secrets.decidim[:track_newsletter_links] == "auto"
|
135
183
|
|
136
|
-
# Amount of time that the data
|
137
|
-
|
184
|
+
# Amount of time that the download your data files will be available in the server.
|
185
|
+
config.download_your_data_expiry_time = Rails.application.secrets.decidim[:download_your_data_expiry_time].to_i.days
|
138
186
|
|
139
187
|
# Max requests in a time period to prevent DoS attacks. Only applied on production.
|
140
|
-
|
188
|
+
config.throttling_max_requests = Rails.application.secrets.decidim[:throttling_max_requests].to_i
|
141
189
|
|
142
190
|
# Time window in which the throttling is applied.
|
143
|
-
|
191
|
+
config.throttling_period = Rails.application.secrets.decidim[:throttling_period].to_i.minutes
|
144
192
|
|
145
193
|
# Time window were users can access the website even if their email is not confirmed.
|
146
|
-
|
194
|
+
config.unconfirmed_access_for = Rails.application.secrets.decidim[:unconfirmed_access_for].to_i.days
|
147
195
|
|
148
196
|
# A base path for the uploads. If set, make sure it ends in a slash.
|
149
197
|
# Uploads will be set to `<base_path>/uploads/`. This can be useful if you
|
@@ -151,7 +199,7 @@ Decidim.configure do |config|
|
|
151
199
|
# environments, but in different folders.
|
152
200
|
#
|
153
201
|
# If not set, it will be ignored.
|
154
|
-
|
202
|
+
config.base_uploads_path = Rails.application.secrets.decidim[:base_uploads_path] if Rails.application.secrets.decidim[:base_uploads_path].present?
|
155
203
|
|
156
204
|
# SMS gateway configuration
|
157
205
|
#
|
@@ -198,6 +246,7 @@ Decidim.configure do |config|
|
|
198
246
|
# end
|
199
247
|
# end
|
200
248
|
#
|
249
|
+
#
|
201
250
|
# config.timestamp_service = "MyTimestampService"
|
202
251
|
|
203
252
|
# PDF signature service configuration
|
@@ -228,14 +277,16 @@ Decidim.configure do |config|
|
|
228
277
|
# Only needed if you want to have Etherpad integration with Decidim. See
|
229
278
|
# Decidim docs at https://docs.decidim.org/en/services/etherpad/ in order to set it up.
|
230
279
|
#
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
|
280
|
+
if Rails.application.secrets.etherpad.present? && Rails.application.secrets.etherpad[:server].present?
|
281
|
+
config.etherpad = {
|
282
|
+
server: Rails.application.secrets.etherpad[:server],
|
283
|
+
api_key: Rails.application.secrets.etherpad[:api_key],
|
284
|
+
api_version: Rails.application.secrets.etherpad[:api_version]
|
285
|
+
}
|
286
|
+
end
|
236
287
|
|
237
288
|
# Sets Decidim::Exporters::CSV's default column separator
|
238
|
-
|
289
|
+
config.default_csv_col_sep = Rails.application.secrets.decidim[:default_csv_col_sep] if Rails.application.secrets.decidim[:default_csv_col_sep].present?
|
239
290
|
|
240
291
|
# The list of roles a user can have, not considering the space-specific roles.
|
241
292
|
# config.user_roles = %w(admin user_manager)
|
@@ -284,7 +335,147 @@ Decidim.configure do |config|
|
|
284
335
|
|
285
336
|
# Defines the name of the cookie used to check if the user allows Decidim to
|
286
337
|
# set cookies.
|
287
|
-
|
338
|
+
config.consent_cookie_name = Rails.application.secrets.decidim[:consent_cookie_name] if Rails.application.secrets.decidim[:consent_cookie_name].present?
|
339
|
+
|
340
|
+
# Defines data consent categories and the data stored in each category.
|
341
|
+
# config.consent_categories = [
|
342
|
+
# {
|
343
|
+
# slug: "essential",
|
344
|
+
# mandatory: true,
|
345
|
+
# items: [
|
346
|
+
# {
|
347
|
+
# type: "cookie",
|
348
|
+
# name: "_session_id"
|
349
|
+
# },
|
350
|
+
# {
|
351
|
+
# type: "cookie",
|
352
|
+
# name: Decidim.consent_cookie_name
|
353
|
+
# }
|
354
|
+
# ]
|
355
|
+
# },
|
356
|
+
# {
|
357
|
+
# slug: "preferences",
|
358
|
+
# mandatory: false
|
359
|
+
# },
|
360
|
+
# {
|
361
|
+
# slug: "analytics",
|
362
|
+
# mandatory: false
|
363
|
+
# },
|
364
|
+
# {
|
365
|
+
# slug: "marketing",
|
366
|
+
# mandatory: false
|
367
|
+
# }
|
368
|
+
# ]
|
369
|
+
|
370
|
+
# Admin admin password configurations
|
371
|
+
Rails.application.secrets.dig(:decidim, :admin_password, :strong).tap do |strong_pw|
|
372
|
+
# When the strong password is not configured, default to true
|
373
|
+
config.admin_password_strong = strong_pw.nil? ? true : strong_pw.present?
|
374
|
+
end
|
375
|
+
config.admin_password_expiration_days = Rails.application.secrets.dig(:decidim, :admin_password, :expiration_days).presence || 90
|
376
|
+
config.admin_password_min_length = Rails.application.secrets.dig(:decidim, :admin_password, :min_length).presence || 15
|
377
|
+
config.admin_password_repetition_times = Rails.application.secrets.dig(:decidim, :admin_password, :repetition_times).presence || 5
|
378
|
+
|
379
|
+
# Additional optional configurations (see decidim-core/lib/decidim/core.rb)
|
380
|
+
config.cache_key_separator = Rails.application.secrets.decidim[:cache_key_separator] if Rails.application.secrets.decidim[:cache_key_separator].present?
|
381
|
+
config.expire_session_after = Rails.application.secrets.decidim[:expire_session_after].to_i.minutes if Rails.application.secrets.decidim[:expire_session_after].present?
|
382
|
+
config.enable_remember_me = Rails.application.secrets.decidim[:enable_remember_me].present? unless Rails.application.secrets.decidim[:enable_remember_me] == "auto"
|
383
|
+
if Rails.application.secrets.decidim[:session_timeout_interval].present?
|
384
|
+
config.session_timeout_interval = Rails.application.secrets.decidim[:session_timeout_interval].to_i.seconds
|
385
|
+
end
|
386
|
+
config.follow_http_x_forwarded_host = Rails.application.secrets.decidim[:follow_http_x_forwarded_host].present?
|
387
|
+
config.maximum_conversation_message_length = Rails.application.secrets.decidim[:maximum_conversation_message_length].to_i
|
388
|
+
config.password_blacklist = Rails.application.secrets.decidim[:password_blacklist] if Rails.application.secrets.decidim[:password_blacklist].present?
|
389
|
+
config.allow_open_redirects = Rails.application.secrets.decidim[:allow_open_redirects] if Rails.application.secrets.decidim[:allow_open_redirects].present?
|
390
|
+
end
|
391
|
+
|
392
|
+
if Decidim.module_installed? :api
|
393
|
+
Decidim::Api.configure do |config|
|
394
|
+
config.schema_max_per_page = Rails.application.secrets.dig(:decidim, :api, :schema_max_per_page).presence || 50
|
395
|
+
config.schema_max_complexity = Rails.application.secrets.dig(:decidim, :api, :schema_max_complexity).presence || 5000
|
396
|
+
config.schema_max_depth = Rails.application.secrets.dig(:decidim, :api, :schema_max_depth).presence || 15
|
397
|
+
end
|
398
|
+
end
|
399
|
+
|
400
|
+
if Decidim.module_installed? :proposals
|
401
|
+
Decidim::Proposals.configure do |config|
|
402
|
+
config.similarity_threshold = Rails.application.secrets.dig(:decidim, :proposals, :similarity_threshold).presence || 0.25
|
403
|
+
config.similarity_limit = Rails.application.secrets.dig(:decidim, :proposals, :similarity_limit).presence || 10
|
404
|
+
config.participatory_space_highlighted_proposals_limit = Rails.application.secrets.dig(:decidim, :proposals, :participatory_space_highlighted_proposals_limit).presence || 4
|
405
|
+
config.process_group_highlighted_proposals_limit = Rails.application.secrets.dig(:decidim, :proposals, :process_group_highlighted_proposals_limit).presence || 3
|
406
|
+
end
|
407
|
+
end
|
408
|
+
|
409
|
+
if Decidim.module_installed? :meetings
|
410
|
+
Decidim::Meetings.configure do |config|
|
411
|
+
config.upcoming_meeting_notification = Rails.application.secrets.dig(:decidim, :meetings, :upcoming_meeting_notification).to_i.days
|
412
|
+
if Rails.application.secrets.dig(:decidim, :meetings, :embeddable_services).present?
|
413
|
+
config.embeddable_services = Rails.application.secrets.dig(:decidim, :meetings, :embeddable_services)
|
414
|
+
end
|
415
|
+
unless Rails.application.secrets.dig(:decidim, :meetings, :enable_proposal_linking) == "auto"
|
416
|
+
config.enable_proposal_linking = Rails.application.secrets.dig(:decidim, :meetings, :enable_proposal_linking).present?
|
417
|
+
end
|
418
|
+
end
|
419
|
+
end
|
420
|
+
|
421
|
+
if Decidim.module_installed? :budgets
|
422
|
+
Decidim::Budgets.configure do |config|
|
423
|
+
unless Rails.application.secrets.dig(:decidim, :budgets, :enable_proposal_linking) == "auto"
|
424
|
+
config.enable_proposal_linking = Rails.application.secrets.dig(:decidim, :budgets, :enable_proposal_linking).present?
|
425
|
+
end
|
426
|
+
end
|
427
|
+
end
|
428
|
+
|
429
|
+
if Decidim.module_installed? :accountability
|
430
|
+
Decidim::Accountability.configure do |config|
|
431
|
+
unless Rails.application.secrets.dig(:decidim, :accountability, :enable_proposal_linking) == "auto"
|
432
|
+
config.enable_proposal_linking = Rails.application.secrets.dig(:decidim, :accountability, :enable_proposal_linking).present?
|
433
|
+
end
|
434
|
+
end
|
435
|
+
end
|
436
|
+
|
437
|
+
if Decidim.module_installed? :consultations
|
438
|
+
Decidim::Consultations.configure do |config|
|
439
|
+
config.stats_cache_expiration_time = Rails.application.secrets.dig(:decidim, :consultations, :stats_cache_expiration_time).to_i.minutes
|
440
|
+
end
|
441
|
+
end
|
442
|
+
|
443
|
+
if Decidim.module_installed? :initiatives
|
444
|
+
Decidim::Initiatives.configure do |config|
|
445
|
+
unless Rails.application.secrets.dig(:decidim, :initiatives, :creation_enabled) == "auto"
|
446
|
+
config.creation_enabled = Rails.application.secrets.dig(:decidim, :initiatives, :creation_enabled).present?
|
447
|
+
end
|
448
|
+
config.similarity_threshold = Rails.application.secrets.dig(:decidim, :initiatives, :similarity_threshold).presence || 0.25
|
449
|
+
config.similarity_limit = Rails.application.secrets.dig(:decidim, :initiatives, :similarity_limit).presence || 5
|
450
|
+
config.minimum_committee_members = Rails.application.secrets.dig(:decidim, :initiatives, :minimum_committee_members).presence || 2
|
451
|
+
config.default_signature_time_period_length = Rails.application.secrets.dig(:decidim, :initiatives, :default_signature_time_period_length).presence || 120
|
452
|
+
config.default_components = Rails.application.secrets.dig(:decidim, :initiatives, :default_components)
|
453
|
+
config.first_notification_percentage = Rails.application.secrets.dig(:decidim, :initiatives, :first_notification_percentage).presence || 33
|
454
|
+
config.second_notification_percentage = Rails.application.secrets.dig(:decidim, :initiatives, :second_notification_percentage).presence || 66
|
455
|
+
config.stats_cache_expiration_time = Rails.application.secrets.dig(:decidim, :initiatives, :stats_cache_expiration_time).to_i.minutes
|
456
|
+
config.max_time_in_validating_state = Rails.application.secrets.dig(:decidim, :initiatives, :max_time_in_validating_state).to_i.days
|
457
|
+
unless Rails.application.secrets.dig(:decidim, :initiatives, :print_enabled) == "auto"
|
458
|
+
config.print_enabled = Rails.application.secrets.dig(:decidim, :initiatives, :print_enabled).present?
|
459
|
+
end
|
460
|
+
config.do_not_require_authorization = Rails.application.secrets.dig(:decidim, :initiatives, :do_not_require_authorization).present?
|
461
|
+
end
|
462
|
+
end
|
463
|
+
|
464
|
+
if Decidim.module_installed? :elections
|
465
|
+
Decidim::Elections.configure do |config|
|
466
|
+
config.setup_minimum_hours_before_start = Rails.application.secrets.dig(:elections, :setup_minimum_hours_before_start).presence || 3
|
467
|
+
config.start_vote_maximum_hours_before_start = Rails.application.secrets.dig(:elections, :start_vote_maximum_hours_before_start).presence || 6
|
468
|
+
config.voter_token_expiration_minutes = Rails.application.secrets.dig(:elections, :voter_token_expiration_minutes).presence || 120
|
469
|
+
end
|
470
|
+
|
471
|
+
Decidim::Votings.configure do |config|
|
472
|
+
config.check_census_max_requests = Rails.application.secrets.dig(:elections, :votings, :check_census_max_requests).presence || 5
|
473
|
+
config.throttling_period = Rails.application.secrets.dig(:elections, :votings, :throttling_period).to_i.minutes
|
474
|
+
end
|
475
|
+
|
476
|
+
Decidim::Votings::Census.configure do |config|
|
477
|
+
config.census_access_codes_export_expiry_time = Rails.application.secrets.dig(:elections, :votings, :census, :access_codes_export_expiry_time).to_i.days
|
478
|
+
end
|
288
479
|
end
|
289
480
|
|
290
481
|
Rails.application.config.i18n.available_locales = Decidim.available_locales
|