decidim-generators 0.26.9 → 0.27.0.rc1

Sign up to get free protection for your applications and to get access to all the features.
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,6 +73,18 @@ 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"
@@ -115,19 +131,94 @@ module Decidim
115
131
 
116
132
  gsub_file "Gemfile", /gem "#{current_gem}".*/, "gem \"#{current_gem}\", #{gem_modifier}"
117
133
 
118
- if current_gem == "decidim"
119
- gsub_file "Gemfile", /gem "decidim-dev".*/, "gem \"decidim-dev\", #{gem_modifier}"
134
+ return unless current_gem == "decidim"
135
+
136
+ gsub_file "Gemfile", /gem "decidim-dev".*/, "gem \"decidim-dev\", #{gem_modifier}"
137
+
138
+ %w(conferences consultations elections initiatives templates).each do |component|
139
+ if options[:demo]
140
+ gsub_file "Gemfile", /gem "decidim-#{component}".*/, "gem \"decidim-#{component}\", #{gem_modifier}"
141
+ else
142
+ gsub_file "Gemfile", /gem "decidim-#{component}".*/, "# gem \"decidim-#{component}\", #{gem_modifier}"
143
+ end
144
+ end
145
+ end
146
+
147
+ def add_storage_provider
148
+ template "storage.yml.erb", "config/storage.yml", force: true
149
+
150
+ providers = options[:storage].split(",")
151
+
152
+ abort("#{providers} is not supported as storage provider, please use local, s3, gcs or azure") unless (providers - %w(local s3 gcs azure)).empty?
153
+ gsub_file "config/environments/production.rb",
154
+ /config.active_storage.service = :local/,
155
+ "config.active_storage.service = Rails.application.secrets.dig(:storage, :provider) || :local"
156
+
157
+ add_production_gems do
158
+ gem "aws-sdk-s3", require: false if providers.include?("s3")
159
+ gem "azure-storage-blob", require: false if providers.include?("azure")
160
+ gem "google-cloud-storage", "~> 1.11", require: false if providers.include?("gcs")
161
+ end
162
+ end
163
+
164
+ def add_queue_adapter
165
+ adapter = options[:queue]
166
+
167
+ abort("#{adapter} is not supported as a queue adapter, please use sidekiq for the moment") unless adapter.in?(["", "sidekiq"])
168
+
169
+ return unless adapter == "sidekiq"
170
+
171
+ template "sidekiq.yml.erb", "config/sidekiq.yml", force: true
172
+
173
+ gsub_file "config/environments/production.rb",
174
+ /# config.active_job.queue_adapter = :resque/,
175
+ "config.active_job.queue_adapter = ENV['QUEUE_ADAPTER'] if ENV['QUEUE_ADAPTER'].present?"
120
176
 
121
- %w(conferences consultations elections initiatives templates).each do |component|
122
- if options[:demo]
123
- gsub_file "Gemfile", /gem "decidim-#{component}".*/, "gem \"decidim-#{component}\", #{gem_modifier}"
124
- else
125
- gsub_file "Gemfile", /gem "decidim-#{component}".*/, "# gem \"decidim-#{component}\", #{gem_modifier}"
126
- end
177
+ prepend_file "config/routes.rb", "require \"sidekiq/web\"\n\n"
178
+ route <<~RUBY
179
+ authenticate :user, ->(u) { u.admin? } do
180
+ mount Sidekiq::Web => "/sidekiq"
181
+ end
182
+ RUBY
183
+
184
+ add_production_gems do
185
+ gem "sidekiq"
186
+ end
187
+ end
188
+
189
+ def add_production_gems(&block)
190
+ return if options[:skip_gemfile]
191
+
192
+ if block
193
+ @production_gems ||= []
194
+ @production_gems << block
195
+ elsif @production_gems.present?
196
+ gem_group :production do
197
+ @production_gems.map(&:call)
127
198
  end
128
199
  end
200
+ end
201
+
202
+ def tweak_bootsnap
203
+ gsub_file "config/boot.rb", %r{require 'bootsnap/setup'.*$}, <<~RUBY.rstrip
204
+ require "bootsnap"
205
+
206
+ env = ENV["RAILS_ENV"] || "development"
129
207
 
130
- run "bundle install"
208
+ Bootsnap.setup(
209
+ cache_dir: File.expand_path(File.join("..", "tmp", "cache"), __dir__),
210
+ development_mode: env == "development",
211
+ load_path_cache: true,
212
+ compile_cache_iseq: !ENV["SIMPLECOV"],
213
+ compile_cache_yaml: true
214
+ )
215
+ RUBY
216
+ end
217
+
218
+ def tweak_spring
219
+ return unless File.exist?("config/spring.rb")
220
+
221
+ prepend_to_file "config/spring.rb", "require \"decidim/spring\"\n\n"
131
222
  end
132
223
 
133
224
  def add_ignore_uploads
@@ -142,11 +233,27 @@ module Decidim
142
233
  def decidim_initializer
143
234
  copy_file "initializer.rb", "config/initializers/decidim.rb"
144
235
 
236
+ gsub_file "config/environments/production.rb",
237
+ /config.log_level = :info/,
238
+ "config.log_level = %w(debug info warn error fatal).include?(ENV['RAILS_LOG_LEVEL']) ? ENV['RAILS_LOG_LEVEL'] : :info"
239
+
240
+ gsub_file "config/environments/production.rb",
241
+ %r{# config.asset_host = 'http://assets.example.com'},
242
+ "config.asset_host = ENV['RAILS_ASSET_HOST'] if ENV['RAILS_ASSET_HOST'].present?"
243
+
145
244
  if options[:force_ssl] == "false"
146
245
  gsub_file "config/initializers/decidim.rb",
147
246
  /# config.force_ssl = true/,
148
247
  "config.force_ssl = false"
149
248
  end
249
+ return if options[:locales].blank?
250
+
251
+ gsub_file "config/initializers/decidim.rb",
252
+ /#{Regexp.escape("# config.available_locales = %w(en ca es)")}/,
253
+ "config.available_locales = %w(#{options[:locales].gsub(",", " ")})"
254
+ gsub_file "config/initializers/decidim.rb",
255
+ /#{Regexp.escape("config.available_locales = Rails.application.secrets.decidim[:available_locales].presence || [:en]")}/,
256
+ "# config.available_locales = Rails.application.secrets.decidim[:available_locales].presence || [:en]"
150
257
  end
151
258
 
152
259
  def authorization_handler
@@ -214,11 +321,11 @@ module Decidim
214
321
 
215
322
  def gem_modifier
216
323
  @gem_modifier ||= if options[:path]
217
- "path: \"#{options[:path]}\""
324
+ %(path: "#{options[:path]}")
218
325
  elsif branch.present?
219
- "git: \"https://github.com/decidim/decidim.git\", branch: \"#{branch}\""
326
+ %(git: "#{repository}", branch: "#{branch}")
220
327
  else
221
- "\"#{Decidim::Generators.version}\""
328
+ %("#{Decidim::Generators.version}")
222
329
  end
223
330
  end
224
331
 
@@ -228,6 +335,10 @@ module Decidim
228
335
  @branch ||= options[:edge] ? Decidim::Generators.edge_git_branch : options[:branch].presence
229
336
  end
230
337
 
338
+ def repository
339
+ @repository ||= options[:repository] || "https://github.com/decidim/decidim.git"
340
+ end
341
+
231
342
  def app_name
232
343
  options[:app_name] || super
233
344
  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 Virtus.
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 = "My 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 = "change-me@example.org"
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 = [:en, :ca, :es]
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
- # config.system_accesslist_ips = ["127.0.0.1"]
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,13 +32,16 @@ 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
- # See Decidim docs at https://docs.decidim.org/en/develop/services/maps.html
38
- # for more information about how it works and how to set it up.
39
- #
40
45
  # == HERE Maps ==
41
46
  # config.maps = {
42
47
  # provider: :here,
@@ -101,6 +106,40 @@ Decidim.configure do |config|
101
106
  # cache: Redis.new,
102
107
  # cache_prefix: "..."
103
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
104
143
 
105
144
  # Custom resource reference generator method. Check the docs for more info.
106
145
  # config.reference_generator = lambda do |resource, component|
@@ -109,14 +148,20 @@ Decidim.configure do |config|
109
148
  # end
110
149
 
111
150
  # Currency unit
112
- # config.currency_unit = "€"
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?
113
155
 
114
156
  # Defines the quality of image uploads after processing. Image uploads are
115
157
  # processed by Decidim, this value helps reduce the size of the files.
116
- # config.image_uploader_quality = 80
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
117
162
 
118
163
  # The number of reports which a resource can receive before hiding it
119
- # config.max_reports_before_hiding = 3
164
+ config.max_reports_before_hiding = Rails.application.secrets.decidim[:max_reports_before_hiding].to_i
120
165
 
121
166
  # Custom HTML Header snippets
122
167
  #
@@ -131,22 +176,22 @@ Decidim.configure do |config|
131
176
  # that an organization's administrator injects malicious scripts to spy on or
132
177
  # take over user accounts.
133
178
  #
134
- config.enable_html_header_snippets = false
179
+ config.enable_html_header_snippets = Rails.application.secrets.decidim[:enable_html_header_snippets].present?
135
180
 
136
181
  # Allow organizations admins to track newsletter links.
137
- # config.track_newsletter_links = true
182
+ config.track_newsletter_links = Rails.application.secrets.decidim[:track_newsletter_links].present? unless Rails.application.secrets.decidim[:track_newsletter_links] == "auto"
138
183
 
139
- # Amount of time that the data portability files will be available in the server.
140
- # config.data_portability_expiry_time = 7.days
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
141
186
 
142
187
  # Max requests in a time period to prevent DoS attacks. Only applied on production.
143
- # config.throttling_max_requests = 100
188
+ config.throttling_max_requests = Rails.application.secrets.decidim[:throttling_max_requests].to_i
144
189
 
145
190
  # Time window in which the throttling is applied.
146
- # config.throttling_period = 1.minute
191
+ config.throttling_period = Rails.application.secrets.decidim[:throttling_period].to_i.minutes
147
192
 
148
193
  # Time window were users can access the website even if their email is not confirmed.
149
- # config.unconfirmed_access_for = 2.days
194
+ config.unconfirmed_access_for = Rails.application.secrets.decidim[:unconfirmed_access_for].to_i.days
150
195
 
151
196
  # A base path for the uploads. If set, make sure it ends in a slash.
152
197
  # Uploads will be set to `<base_path>/uploads/`. This can be useful if you
@@ -154,7 +199,7 @@ Decidim.configure do |config|
154
199
  # environments, but in different folders.
155
200
  #
156
201
  # If not set, it will be ignored.
157
- # config.base_uploads_path = nil
202
+ config.base_uploads_path = Rails.application.secrets.decidim[:base_uploads_path] if Rails.application.secrets.decidim[:base_uploads_path].present?
158
203
 
159
204
  # SMS gateway configuration
160
205
  #
@@ -201,6 +246,7 @@ Decidim.configure do |config|
201
246
  # end
202
247
  # end
203
248
  #
249
+ #
204
250
  # config.timestamp_service = "MyTimestampService"
205
251
 
206
252
  # PDF signature service configuration
@@ -231,14 +277,16 @@ Decidim.configure do |config|
231
277
  # Only needed if you want to have Etherpad integration with Decidim. See
232
278
  # Decidim docs at https://docs.decidim.org/en/services/etherpad/ in order to set it up.
233
279
  #
234
- # config.etherpad = {
235
- # server: Rails.application.secrets.etherpad[:server],
236
- # api_key: Rails.application.secrets.etherpad[:api_key],
237
- # api_version: Rails.application.secrets.etherpad[:api_version]
238
- # }
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
239
287
 
240
288
  # Sets Decidim::Exporters::CSV's default column separator
241
- # config.default_csv_col_sep = ";"
289
+ config.default_csv_col_sep = Rails.application.secrets.decidim[:default_csv_col_sep] if Rails.application.secrets.decidim[:default_csv_col_sep].present?
242
290
 
243
291
  # The list of roles a user can have, not considering the space-specific roles.
244
292
  # config.user_roles = %w(admin user_manager)
@@ -287,7 +335,147 @@ Decidim.configure do |config|
287
335
 
288
336
  # Defines the name of the cookie used to check if the user allows Decidim to
289
337
  # set cookies.
290
- # config.consent_cookie_name = "decidim-cc"
338
+ config.consent_cookie_name = Rails.application.secrets.decidim[:consent_cookie_name] if Rails.application.secrets.decidim[:consent_cookie_name].present?
339
+
340
+ # Defines cookie consent categories and cookies.
341
+ # config.consent_categories = [
342
+ # {
343
+ # slug: "essential",
344
+ # mandatory: true,
345
+ # cookies: [
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
291
479
  end
292
480
 
293
481
  Rails.application.config.i18n.available_locales = Decidim.available_locales