# frozen_string_literal: true require "decidim/core/engine" require "decidim/core/api" require "decidim/core/version" # Decidim configuration. module Decidim autoload :TranslatableAttributes, "decidim/translatable_attributes" autoload :FormBuilder, "decidim/form_builder" autoload :AuthorizationFormBuilder, "decidim/authorization_form_builder" autoload :FilterFormBuilder, "decidim/filter_form_builder" autoload :ComponentManifest, "decidim/component_manifest" autoload :ParticipatorySpaceManifest, "decidim/participatory_space_manifest" autoload :ResourceManifest, "decidim/resource_manifest" autoload :Resourceable, "decidim/resourceable" autoload :Traceable, "decidim/traceable" autoload :Loggable, "decidim/loggable" autoload :Reportable, "decidim/reportable" autoload :Authorable, "decidim/authorable" autoload :Coauthorable, "decidim/coauthorable" autoload :Participable, "decidim/participable" autoload :Publicable, "decidim/publicable" autoload :Scopable, "decidim/scopable" autoload :ScopableComponent, "decidim/scopable_component" autoload :ContentParsers, "decidim/content_parsers" autoload :ContentRenderers, "decidim/content_renderers" autoload :ContentProcessor, "decidim/content_processor" autoload :Components, "decidim/components" autoload :HasAttachmentCollections, "decidim/has_attachment_collections" autoload :HasAttachments, "decidim/has_attachments" autoload :ComponentValidator, "decidim/component_validator" autoload :HasSettings, "decidim/has_settings" autoload :HasComponent, "decidim/has_component" autoload :HasCategory, "decidim/has_category" autoload :Followable, "decidim/followable" autoload :FriendlyDates, "decidim/friendly_dates" autoload :Nicknamizable, "decidim/nicknamizable" autoload :HasReference, "decidim/has_reference" autoload :Attributes, "decidim/attributes" autoload :StatsRegistry, "decidim/stats_registry" autoload :Exporters, "decidim/exporters" autoload :FileZipper, "decidim/file_zipper" autoload :Menu, "decidim/menu" autoload :MenuItem, "decidim/menu_item" autoload :MenuRegistry, "decidim/menu_registry" autoload :Messaging, "decidim/messaging" autoload :ManifestRegistry, "decidim/manifest_registry" autoload :EngineRouter, "decidim/engine_router" autoload :Events, "decidim/events" autoload :ViewHooks, "decidim/view_hooks" autoload :ContentBlockRegistry, "decidim/content_block_registry" autoload :ContentBlockManifest, "decidim/content_block_manifest" autoload :MetricRegistry, "decidim/metric_registry" autoload :MetricManifest, "decidim/metric_manifest" autoload :MetricOperation, "decidim/metric_operation" autoload :MetricOperationManifest, "decidim/metric_operation_manifest" autoload :NewsletterEncryptor, "decidim/newsletter_encryptor" autoload :Searchable, "decidim/searchable" autoload :SearchResourceFieldsMapper, "decidim/search_resource_fields_mapper" autoload :QueryExtensions, "decidim/query_extensions" autoload :ParticipatorySpaceResourceable, "decidim/participatory_space_resourceable" autoload :HasPrivateUsers, "decidim/has_private_users" autoload :ViewModel, "decidim/view_model" autoload :FingerprintCalculator, "decidim/fingerprint_calculator" autoload :Fingerprintable, "decidim/fingerprintable" autoload :DataPortability, "decidim/data_portability" autoload :DataPortabilitySerializers, "decidim/data_portability_serializers" autoload :DataPortabilityFileReader, "decidim/data_portability_file_reader" autoload :DataPortabilityFileZipper, "decidim/data_portability_file_zipper" autoload :Amendable, "decidim/amendable" autoload :Gamification, "decidim/gamification" autoload :Hashtag, "decidim/hashtag" autoload :Hashtaggable, "decidim/hashtaggable" autoload :Paddable, "decidim/paddable" autoload :OpenDataExporter, "decidim/open_data_exporter" autoload :IoEncoder, "decidim/io_encoder" autoload :HasResourcePermission, "decidim/has_resource_permission" include ActiveSupport::Configurable # Loads seeds from all engines. def self.seed! # Faker needs to have the `:en` locale in order to work properly, so we # must enforce it during the seeds. original_locale = I18n.available_locales I18n.available_locales = original_locale + [:en] unless original_locale.include?(:en) Rails.application.railties.to_a.uniq.each do |railtie| next unless railtie.respond_to?(:load_seed) && railtie.class.name.include?("Decidim::") railtie.load_seed end participatory_space_manifests.each do |manifest| manifest.seed! Organization.all.each do |organization| ContextualHelpSection.set_content( organization, manifest.name, Decidim::Faker::Localized.wrapped("
", "
") do Decidim::Faker::Localized.sentence(15) end ) end end Gamification.badges.each do |badge| puts "Setting random values for the \"#{badge.name}\" badge..." User.all.find_each do |user| Gamification::BadgeScore.find_or_create_by!( user: user, badge_name: badge.name, value: Random.rand(0...20) ) end end I18n.available_locales = original_locale end # Exposes a configuration option: The application name String. config_accessor :application_name # Exposes a configuration option: The email String to use as sender in all # the mails. config_accessor :mailer_sender # Exposes a configuration option: The application available locales. config_accessor :available_locales do %w(en ca de es es-MX es-PY eu fi-pl fi fr gl hu id it nl pl pt pt-BR ru sv tr uk) end # Exposes a configuration option: an array of symbols representing processors # that will be automatically executed when a content is parsed or rendered. # # A content processor is a concept to refer to a set of two classes: # the content parser class and the content renderer class. # e.g. If we register a content processor named `user`: # # Decidim.content_processors += [:user] # # we must declare the following classes: # # Decidim::ContentParsers::UserParser < BaseParser # Decidim::ContentRenderers::UserRenderer < BaseRenderer config_accessor :content_processors do [] end # Exposes a configuration option: The application default locale. config_accessor :default_locale do :en end # Exposes a configuration option: an object to configure geocoder config_accessor :geocoder # Exposes a configuration option: a custom method to generate references. # If overwritten, it should handle both component resources and participatory spaces. # Default: Calculates a unique reference for the model in # the following format: # # "BCN-PROP-2017-02-6589" which in this example translates to: # # BCN: A setting configured at the organization to be prepended to each reference. # PROP: Unique name identifier for a resource: Decidim::Proposals::Proposal # (MEET for meetings or PROJ for projects). # 2017-02: Year-Month of the resource creation date # 6589: ID of the resource config_accessor :reference_generator do lambda do |resource, component| ref = "" if resource.is_a?(Decidim::HasComponent) && component.present? # It's a component resource ref = component.participatory_space.organization.reference_prefix elsif resource.is_a?(Decidim::Participable) # It's a participatory space ref = resource.organization.reference_prefix end class_identifier = resource.class.name.demodulize[0..3].upcase year_month = (resource.created_at || Time.current).strftime("%Y-%m") [ref, class_identifier, year_month, resource.id].join("-") end end # Exposes a configuration option: the currency unit config_accessor :currency_unit do "€" end # Exposes a configuration option: The image uploader quality. config_accessor :image_uploader_quality do 80 end # Exposes a configuration option: The maximum file size of an attachment. config_accessor :maximum_attachment_size do 10.megabytes end # Exposes a configuration option: The maximum file size for user avatar images. config_accessor :maximum_avatar_size do 5.megabytes end # The number of reports which an object can receive before hiding it config_accessor :max_reports_before_hiding do 3 end # Allow organization's administrators to inject custom HTML into the frontend config_accessor :enable_html_header_snippets do true end # Allow organization's administrators to track newsletter links config_accessor :track_newsletter_links do true end # Time that data portability files are available in server config_accessor :data_portability_expiry_time do 7.days end # Max requests in a time period to prevent DoS attacks. Only applied on production. config_accessor :throttling_max_requests do 100 end # Time window in which the throttling is applied. config_accessor :throttling_period do 1.minute end # Time window were users can access the website even if their email is not confirmed. config_accessor :unconfirmed_access_for do 2.days end # Exposes a configuration option: an object to configure Etherpad config_accessor :etherpad # A base path for the uploads. If set, make sure it ends in a slash. # Uploads will be set to `