From 93cd9e8f56dcc45e452d876e5ef4f42baa66e8d2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ivan=20Verg=C3=A9s?= Date: Thu, 27 Mar 2025 16:20:26 +0100 Subject: [PATCH 01/10] add EU language --- config/locales/eu.yml | 68 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 68 insertions(+) create mode 100644 config/locales/eu.yml diff --git a/config/locales/eu.yml b/config/locales/eu.yml new file mode 100644 index 0000000..45d7d97 --- /dev/null +++ b/config/locales/eu.yml @@ -0,0 +1,68 @@ +--- +eu: + activemodel: + attributes: + user: + country: Herria + date_of_birth: Jaioteguna + gender: Generoa + location: Helbidea + phone_number: Telefono zenbakia + postal_code: Posta kodea + decidim: + admin: + actions: + export: Esportatu + exports: + export_as: "%{export_format} gisa esportatu" + extra_user_fields: + menu: + title: Kudeatu extra user fields + components: + extra_user_fields: + name: ExtraUserFields + extra_user_fields: + admin: + exports: + users: Parte-hartzaileak + extra_user_fields: + fields: + country: + description: Eremu hau herrien zerrenda bat da. Erabiltzaileek herri bat aukeratu ahal izango dute. + label: Herriaren eremua aktibatu + date_of_birth: + description: Eremu hau data bat da. Erabiltzaileak bere jaioteguna jarri ahal izango du data aukeratuz. + label: Jaiotegunaren eremua aktibatu + gender: + description: Eremu hau generoen zerrenda bat da. Erabiltzaileak generoa aukeratu ahal izango du erregistroa egitean. + label: Generoaren eremua aktibatu + location: + description: Eremu hau testua da. Erabiltzaileak helbidea idatzi ahal izango du bertan. + label: Helbidearen eremua aktibatu + phone_number: + description: Eremu hau testua da. Erabiltzaileak bere telefono zenbakia idatzi ahal izango du bertan. + label: Telefono zenbakiaren eremua aktibatu + postal_code: + description: Eremu hau testua da. Erabiltzaileak bere posta kodea idatzi ahal izango du bertan. + label: Posta kodearen eremua aktibatu + form: + callout: + help: Extra user fields-en funtzionaltasunak aktibatu. Honi esker erregistroa egiteko unean eremu gehigarriak agertuko dira. Gogoratu aukera hau aktibatuta ere, erregistroaren formularioan behean aktibatutako eremuak baino ez dituela gehituko. + extra_user_fields: + extra_user_fields_enabled: Extra User Fields aktibatu + section: Eregistroa egiteko formularioan erabilgarri dauden eremu gehigarriak. + global: + title: Funtzionatasuna Aktibatu / Desaktibatu + index: + save: Ezarpenak gorde + title: Extra user fields kudeatu + update: + failure: Erakundearen datuak eguneratzean errore bat sortu da + success: Extra user fields zuzen eguneratu dira erakundean + genders: + female: Emakumea + male: Gizona + other: Beste bat + registration_form: + signup: + legend: Argibide gehiago From 1906deb90b9da5ad419ce594147bb339d02bdadb Mon Sep 17 00:00:00 2001 From: Anna Topalidi <60363870+antopalidi@users.noreply.github.com> Date: Wed, 2 Apr 2025 15:34:54 +0200 Subject: [PATCH 02/10] Upgrade to 0.29 (#1) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * upgrade to 0.29 * update CI * fix tests * fix tests * fix test * Apply suggestions from code review Co-authored-by: Ivan Vergés * Update Gemfile and lockfile for Decidim 0.29.2 * fix accessibility test * add overrides_spec * fix custom_country_select --------- Co-authored-by: Ivan Vergés --- .github/workflows/build_app.yml | 8 +- .github/workflows/ci_tests.yml | 4 +- .github/workflows/test_app.yml | 13 +- .rubocop.yml | 7 +- .ruby-version | 2 +- Gemfile | 14 +- Gemfile.lock | 568 +++++++++--------- README.md | 6 + .../update_account_commands_overrides.rb | 16 +- .../extra_user_fields/forms_definitions.rb | 2 +- .../show/extra_user_fields.html.erb.deface | 2 +- .../extra_user_fields/_profile_form.html.erb | 2 +- .../_registration_form.html.erb | 2 +- bin/dev | 5 + decidim-extra_user_fields.gemspec | 2 +- lib/decidim/extra_user_fields/admin_engine.rb | 2 +- .../extra_user_fields/form_builder_methods.rb | 17 +- lib/decidim/extra_user_fields/version.rb | 4 +- spec/factories.rb | 7 +- spec/forms/decidim/registration_form_spec.rb | 2 +- spec/lib/overrides_spec.rb | 44 ++ spec/models/decidim/organization_spec.rb | 4 + spec/system/account_spec.rb | 24 +- .../admin_manages_officializations_spec.rb | 2 +- ...ges_organization_extra_user_fields_spec.rb | 2 +- spec/system/registration_spec.rb | 4 +- 26 files changed, 417 insertions(+), 348 deletions(-) create mode 100755 bin/dev create mode 100644 spec/lib/overrides_spec.rb diff --git a/.github/workflows/build_app.yml b/.github/workflows/build_app.yml index 35e54a5..f7ca3a7 100644 --- a/.github/workflows/build_app.yml +++ b/.github/workflows/build_app.yml @@ -3,7 +3,7 @@ on: inputs: ruby_version: description: 'Ruby Version' - default: "3.1.1" + default: "3.2.6" type: string required: false node_version: @@ -34,19 +34,19 @@ jobs: env: POSTGRES_PASSWORD: postgres steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 with: fetch-depth: 1 - uses: ruby/setup-ruby@v1 with: ruby-version: ${{ inputs.ruby_version }} bundler-cache: true - - uses: actions/setup-node@v3 + - uses: actions/setup-node@v4 with: node-version: ${{ inputs.node_version }} cache: 'npm' cache-dependency-path: ./package-lock.json - - uses: actions/cache@v3 + - uses: actions/cache@v4 id: app-cache with: path: ./spec/decidim_dummy_app/ diff --git a/.github/workflows/ci_tests.yml b/.github/workflows/ci_tests.yml index 20fe405..7745fa8 100644 --- a/.github/workflows/ci_tests.yml +++ b/.github/workflows/ci_tests.yml @@ -15,7 +15,7 @@ on: env: CI: "true" - RUBY_VERSION: 3.1.1 + RUBY_VERSION: 3.2.6 NODE_VERSION: 18.17.1 concurrency: @@ -33,7 +33,7 @@ jobs: runs-on: ubuntu-latest timeout-minutes: 60 steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 with: fetch-depth: 1 - uses: actions/setup-node@master diff --git a/.github/workflows/test_app.yml b/.github/workflows/test_app.yml index 70894d8..1b9e5cf 100644 --- a/.github/workflows/test_app.yml +++ b/.github/workflows/test_app.yml @@ -3,7 +3,7 @@ on: inputs: ruby_version: description: 'Ruby Version' - default: "3.1.1" + default: "3.2.6" required: false type: string test_command: @@ -41,8 +41,15 @@ jobs: --health-retries 5 env: POSTGRES_PASSWORD: postgres + redis: + image: redis + options: >- + --health-cmd "redis-cli ping" + --health-interval 10s + --health-timeout 5s + --health-retries 5 steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 with: fetch-depth: 1 - uses: ruby/setup-ruby@v1 @@ -59,7 +66,7 @@ jobs: name: Install Chrome version ${{inputs.chrome_version}} with: chromedriver-version: ${{inputs.chrome_version}} - - uses: actions/cache@v3 + - uses: actions/cache@v4 id: app-cache with: path: ./spec/decidim_dummy_app/ diff --git a/.rubocop.yml b/.rubocop.yml index b901a13..e85f6ba 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -1,4 +1,5 @@ -inherit_from: https://raw.githubusercontent.com/decidim/decidim/release/0.28-stable/.rubocop.yml +inherit_gem: + decidim-dev: rubocop-decidim.yml AllCops: Include: @@ -14,7 +15,3 @@ AllCops: - "node_modules/**/*" - "db/schema.rb" - "vendor/**/*" - -RSpec/FilePath: - Exclude: - - "spec/serializers/user_export_serializer_spec.rb" diff --git a/.ruby-version b/.ruby-version index 94ff29c..34cde56 100644 --- a/.ruby-version +++ b/.ruby-version @@ -1 +1 @@ -3.1.1 +3.2.6 diff --git a/Gemfile b/Gemfile index ed3f02d..0ca8b63 100644 --- a/Gemfile +++ b/Gemfile @@ -1,6 +1,6 @@ # frozen_string_literal: true -DECIDIM_VERSION = "~> 0.28" +DECIDIM_VERSION = "~> 0.29.2" source "https://rubygems.org" @@ -9,9 +9,8 @@ ruby RUBY_VERSION gem "decidim", DECIDIM_VERSION gem "decidim-extra_user_fields", path: "." -gem "bootsnap", "~> 1.3" -gem "country_select", "~> 4.0" -gem "puma", ">= 4.3" +gem "bootsnap", "~> 1.7" +gem "puma", ">= 6.3.1" group :development, :test do gem "byebug", "~> 11.0", platform: :mri @@ -23,12 +22,5 @@ group :development do gem "letter_opener_web", "~> 2.0" gem "listen", "~> 3.1" gem "rubocop-faker" - gem "spring", "~> 2.0" - gem "spring-watcher-listen", "~> 2.0" gem "web-console", "~> 4.2" end - -group :test do - gem "rubocop-factory_bot", "!= 2.26.0", require: false - gem "rubocop-rspec_rails", "!= 2.29.0", require: false -end diff --git a/Gemfile.lock b/Gemfile.lock index 1539fe4..8c69f55 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,48 +1,55 @@ PATH remote: . specs: - decidim-extra_user_fields (0.28.0) + decidim-extra_user_fields (0.29.0) country_select (~> 4.0) - decidim-core (>= 0.28) + decidim-core (>= 0.29) deface (~> 1.5) GEM remote: https://rubygems.org/ specs: - actioncable (6.1.7.8) - actionpack (= 6.1.7.8) - activesupport (= 6.1.7.8) + actioncable (7.0.8.7) + actionpack (= 7.0.8.7) + activesupport (= 7.0.8.7) nio4r (~> 2.0) websocket-driver (>= 0.6.1) - actionmailbox (6.1.7.8) - actionpack (= 6.1.7.8) - activejob (= 6.1.7.8) - activerecord (= 6.1.7.8) - activestorage (= 6.1.7.8) - activesupport (= 6.1.7.8) + actionmailbox (7.0.8.7) + actionpack (= 7.0.8.7) + activejob (= 7.0.8.7) + activerecord (= 7.0.8.7) + activestorage (= 7.0.8.7) + activesupport (= 7.0.8.7) mail (>= 2.7.1) - actionmailer (6.1.7.8) - actionpack (= 6.1.7.8) - actionview (= 6.1.7.8) - activejob (= 6.1.7.8) - activesupport (= 6.1.7.8) + net-imap + net-pop + net-smtp + actionmailer (7.0.8.7) + actionpack (= 7.0.8.7) + actionview (= 7.0.8.7) + activejob (= 7.0.8.7) + activesupport (= 7.0.8.7) mail (~> 2.5, >= 2.5.4) + net-imap + net-pop + net-smtp rails-dom-testing (~> 2.0) - actionpack (6.1.7.8) - actionview (= 6.1.7.8) - activesupport (= 6.1.7.8) - rack (~> 2.0, >= 2.0.9) + actionpack (7.0.8.7) + actionview (= 7.0.8.7) + activesupport (= 7.0.8.7) + rack (~> 2.0, >= 2.2.4) rack-test (>= 0.6.3) rails-dom-testing (~> 2.0) rails-html-sanitizer (~> 1.0, >= 1.2.0) - actiontext (6.1.7.8) - actionpack (= 6.1.7.8) - activerecord (= 6.1.7.8) - activestorage (= 6.1.7.8) - activesupport (= 6.1.7.8) + actiontext (7.0.8.7) + actionpack (= 7.0.8.7) + activerecord (= 7.0.8.7) + activestorage (= 7.0.8.7) + activesupport (= 7.0.8.7) + globalid (>= 0.6.0) nokogiri (>= 1.8.5) - actionview (6.1.7.8) - activesupport (= 6.1.7.8) + actionview (7.0.8.7) + activesupport (= 7.0.8.7) builder (~> 3.1) erubi (~> 1.4) rails-dom-testing (~> 2.0) @@ -50,28 +57,27 @@ GEM active_link_to (1.0.5) actionpack addressable - activejob (6.1.7.8) - activesupport (= 6.1.7.8) + activejob (7.0.8.7) + activesupport (= 7.0.8.7) globalid (>= 0.3.6) - activemodel (6.1.7.8) - activesupport (= 6.1.7.8) - activerecord (6.1.7.8) - activemodel (= 6.1.7.8) - activesupport (= 6.1.7.8) - activestorage (6.1.7.8) - actionpack (= 6.1.7.8) - activejob (= 6.1.7.8) - activerecord (= 6.1.7.8) - activesupport (= 6.1.7.8) + activemodel (7.0.8.7) + activesupport (= 7.0.8.7) + activerecord (7.0.8.7) + activemodel (= 7.0.8.7) + activesupport (= 7.0.8.7) + activestorage (7.0.8.7) + actionpack (= 7.0.8.7) + activejob (= 7.0.8.7) + activerecord (= 7.0.8.7) + activesupport (= 7.0.8.7) marcel (~> 1.0) mini_mime (>= 1.1.0) - activesupport (6.1.7.8) + activesupport (7.0.8.7) concurrent-ruby (~> 1.0, >= 1.0.2) i18n (>= 1.6, < 2) minitest (>= 5.1) tzinfo (~> 2.0) - zeitwerk (~> 2.3) - acts_as_list (1.2.1) + acts_as_list (1.2.4) activerecord (>= 6.1) activesupport (>= 6.1) addressable (2.8.7) @@ -87,7 +93,7 @@ GEM erubi (~> 1.4) parser (>= 2.4) smart_properties - bigdecimal (3.1.8) + bigdecimal (3.1.9) bindex (0.8.1) bootsnap (1.18.3) msgpack (~> 1.2) @@ -106,30 +112,22 @@ GEM rack-test (>= 0.6.3) regexp_parser (>= 1.5, < 3.0) xpath (~> 3.2) - carrierwave (2.2.6) - activemodel (>= 5.0.0) - activesupport (>= 5.0.0) - addressable (~> 2.6) - image_processing (~> 1.1) - marcel (~> 1.0.0) - mini_mime (>= 0.1.3) - ssrf_filter (~> 1.0) - cells (4.1.7) - declarative-builder (< 0.2.0) + cells (4.1.8) + declarative-builder (~> 0.2.0) declarative-option (< 0.2.0) tilt (>= 1.4, < 3) uber (< 0.2.0) cells-erb (0.1.0) cells (~> 4.0) erbse (>= 0.1.1) - cells-rails (0.1.5) + cells-rails (0.1.6) actionpack (>= 5.0) cells (>= 4.1.6, < 5.0.0) - charlock_holmes (0.7.8) + charlock_holmes (0.7.9) childprocess (5.1.0) logger (~> 1.5) - commonmarker (0.23.10) - concurrent-ruby (1.3.3) + commonmarker (0.23.11) + concurrent-ruby (1.3.4) countries (3.1.0) i18n_data (~> 0.11.0) sixarm_ruby_unaccent (~> 1.1) @@ -141,70 +139,69 @@ GEM bigdecimal rexml crass (1.0.6) - css_parser (1.17.1) + css_parser (1.21.1) addressable - csv (3.3.0) - date (3.3.4) + csv (3.3.3) + dartsass (1.49.8) + date (3.4.1) date_validator (0.12.0) activemodel (>= 3) activesupport (>= 3) - decidim (0.28.1) - decidim-accountability (= 0.28.1) - decidim-admin (= 0.28.1) - decidim-api (= 0.28.1) - decidim-assemblies (= 0.28.1) - decidim-blogs (= 0.28.1) - decidim-budgets (= 0.28.1) - decidim-comments (= 0.28.1) - decidim-core (= 0.28.1) - decidim-debates (= 0.28.1) - decidim-forms (= 0.28.1) - decidim-generators (= 0.28.1) - decidim-meetings (= 0.28.1) - decidim-pages (= 0.28.1) - decidim-participatory_processes (= 0.28.1) - decidim-proposals (= 0.28.1) - decidim-sortitions (= 0.28.1) - decidim-surveys (= 0.28.1) - decidim-system (= 0.28.1) - decidim-templates (= 0.28.1) - decidim-verifications (= 0.28.1) - decidim-accountability (0.28.1) - decidim-comments (= 0.28.1) - decidim-core (= 0.28.1) - decidim-admin (0.28.1) + decidim (0.29.2) + decidim-accountability (= 0.29.2) + decidim-admin (= 0.29.2) + decidim-api (= 0.29.2) + decidim-assemblies (= 0.29.2) + decidim-blogs (= 0.29.2) + decidim-budgets (= 0.29.2) + decidim-comments (= 0.29.2) + decidim-core (= 0.29.2) + decidim-debates (= 0.29.2) + decidim-forms (= 0.29.2) + decidim-generators (= 0.29.2) + decidim-meetings (= 0.29.2) + decidim-pages (= 0.29.2) + decidim-participatory_processes (= 0.29.2) + decidim-proposals (= 0.29.2) + decidim-sortitions (= 0.29.2) + decidim-surveys (= 0.29.2) + decidim-system (= 0.29.2) + decidim-verifications (= 0.29.2) + decidim-accountability (0.29.2) + decidim-comments (= 0.29.2) + decidim-core (= 0.29.2) + decidim-admin (0.29.2) active_link_to (~> 1.0) - decidim-core (= 0.28.1) + decidim-core (= 0.29.2) devise (~> 4.7) devise-i18n (~> 1.2) devise_invitable (~> 2.0, >= 2.0.9) - decidim-api (0.28.1) - commonmarker (~> 0.23.0, >= 0.23.9) - decidim-core (= 0.28.1) - graphql (~> 2.0.0) - graphql-docs (~> 3.0.1) + decidim-api (0.29.2) + decidim-core (= 0.29.2) + graphql (~> 2.2.6) + graphql-docs (~> 4.0) rack-cors (~> 1.0) - decidim-assemblies (0.28.1) - decidim-core (= 0.28.1) - decidim-blogs (0.28.1) - decidim-admin (= 0.28.1) - decidim-comments (= 0.28.1) - decidim-core (= 0.28.1) - decidim-budgets (0.28.1) - decidim-comments (= 0.28.1) - decidim-core (= 0.28.1) - decidim-comments (0.28.1) - decidim-core (= 0.28.1) + decidim-assemblies (0.29.2) + decidim-core (= 0.29.2) + decidim-blogs (0.29.2) + decidim-admin (= 0.29.2) + decidim-comments (= 0.29.2) + decidim-core (= 0.29.2) + decidim-budgets (0.29.2) + decidim-comments (= 0.29.2) + decidim-core (= 0.29.2) + decidim-comments (0.29.2) + decidim-core (= 0.29.2) redcarpet (~> 3.5, >= 3.5.1) - decidim-core (0.28.1) + decidim-core (0.29.2) active_link_to (~> 1.0) acts_as_list (~> 1.0) batch-loader (~> 1.2) browser (~> 2.7) - carrierwave (~> 2.2.5, >= 2.2.5) cells-erb (~> 0.1.0) cells-rails (~> 0.1.3) charlock_holmes (~> 0.7) + concurrent-ruby (= 1.3.4) date_validator (~> 0.12.0) devise (~> 4.7) devise-i18n (~> 1.2, < 1.11.1) @@ -216,12 +213,14 @@ GEM foundation_rails_helper (~> 4.0) geocoder (~> 1.8) hashdiff (>= 0.4.0, < 2.0.0) + image_processing (~> 1.2) invisible_captcha (~> 0.12) kaminari (~> 1.2, >= 1.2.1) loofah (~> 2.19, >= 2.19.1) mime-types (>= 1.16, < 4.0) mini_magick (~> 4.9) net-smtp (~> 0.3.1) + nokogiri (~> 1.16, >= 1.16.2) omniauth (~> 2.0) omniauth-facebook (~> 5.0) omniauth-google-oauth2 (~> 1.0) @@ -232,33 +231,32 @@ GEM pg_search (~> 2.2) premailer-rails (~> 1.10) psych (~> 4.0) - rack (~> 2.2, >= 2.2.6.4) + rack (~> 2.2, >= 2.2.8.1) rack-attack (~> 6.0) - rails (~> 6.1.7, >= 6.1.7.4) - rails-i18n (~> 6.0) + rails (~> 7.0.8) + rails-i18n (~> 7.0) ransack (~> 3.2.1) redis (~> 4.1) request_store (~> 1.5.0) rubyXL (~> 3.4) rubyzip (~> 2.0) - seven_zip_ruby (~> 1.3) shakapacker (~> 7.1.0) valid_email2 (~> 4.0) web-push (~> 3.0) wisper (~> 2.0) - decidim-debates (0.28.1) - decidim-comments (= 0.28.1) - decidim-core (= 0.28.1) - decidim-dev (0.28.1) - bullet (~> 7.0) + decidim-debates (0.29.2) + decidim-comments (= 0.29.2) + decidim-core (= 0.29.2) + decidim-dev (0.29.2) + bullet (~> 7.1.6) byebug (~> 11.0) capybara (~> 3.39) - decidim (= 0.28.1) + decidim (= 0.29.2) erb_lint (~> 0.4.0) factory_bot_rails (~> 6.2) faker (~> 3.2) i18n-tasks (~> 1.0) - nokogiri (~> 1.14, >= 1.14.3) + nokogiri (~> 1.16, >= 1.16.2) parallel_tests (~> 4.2) puma (~> 6.2, >= 6.3.1) rails-controller-testing (~> 1.0) @@ -268,56 +266,59 @@ GEM rspec-rails (~> 6.0) rspec-retry (~> 0.6.2) rspec_junit_formatter (~> 0.6.0) - rubocop (~> 1.50.0) + rubocop (~> 1.65.0) + rubocop-capybara (~> 2.21) + rubocop-factory_bot (~> 2.26) rubocop-faker (~> 1.1) - rubocop-rails (~> 2.19) - rubocop-rspec (~> 2.20) + rubocop-performance (~> 1.21) + rubocop-rails (~> 2.25) + rubocop-rspec (~> 3.0) + rubocop-rspec_rails (~> 2.30) + rubocop-rubycw (~> 0.1) selenium-webdriver (~> 4.9) simplecov (~> 0.22.0) simplecov-cobertura (~> 2.1.0) + spring (~> 4.0) + spring-watcher-listen (~> 2.0) w3c_rspec_validators (~> 0.3.0) webmock (~> 3.18) wisper-rspec (~> 1.0) - decidim-forms (0.28.1) - decidim-core (= 0.28.1) + decidim-forms (0.29.2) + decidim-core (= 0.29.2) wicked_pdf (~> 2.1) - wkhtmltopdf-binary (~> 0.12) - decidim-generators (0.28.1) - decidim-core (= 0.28.1) - decidim-meetings (0.28.1) - decidim-core (= 0.28.1) - decidim-forms (= 0.28.1) + decidim-generators (0.29.2) + decidim-core (= 0.29.2) + decidim-meetings (0.29.2) + decidim-core (= 0.29.2) + decidim-forms (= 0.29.2) icalendar (~> 2.5) - decidim-pages (0.28.1) - decidim-core (= 0.28.1) - decidim-participatory_processes (0.28.1) - decidim-core (= 0.28.1) - decidim-proposals (0.28.1) - decidim-comments (= 0.28.1) - decidim-core (= 0.28.1) - doc2text (~> 0.4.6) + decidim-pages (0.29.2) + decidim-core (= 0.29.2) + decidim-participatory_processes (0.29.2) + decidim-core (= 0.29.2) + decidim-proposals (0.29.2) + decidim-comments (= 0.29.2) + decidim-core (= 0.29.2) + doc2text (~> 0.4.7) redcarpet (~> 3.5, >= 3.5.1) - decidim-sortitions (0.28.1) - decidim-admin (= 0.28.1) - decidim-comments (= 0.28.1) - decidim-core (= 0.28.1) - decidim-proposals (= 0.28.1) - decidim-surveys (0.28.1) - decidim-core (= 0.28.1) - decidim-forms (= 0.28.1) - decidim-system (0.28.1) + decidim-sortitions (0.29.2) + decidim-admin (= 0.29.2) + decidim-comments (= 0.29.2) + decidim-core (= 0.29.2) + decidim-proposals (= 0.29.2) + decidim-surveys (0.29.2) + decidim-core (= 0.29.2) + decidim-forms (= 0.29.2) + decidim-system (0.29.2) active_link_to (~> 1.0) - decidim-core (= 0.28.1) + decidim-core (= 0.29.2) devise (~> 4.7) devise-i18n (~> 1.2) devise_invitable (~> 2.0, >= 2.0.9) - decidim-templates (0.28.1) - decidim-core (= 0.28.1) - decidim-forms (= 0.28.1) - decidim-verifications (0.28.1) - decidim-core (= 0.28.1) - declarative-builder (0.1.0) - declarative-option (< 0.2.0) + decidim-verifications (0.29.2) + decidim-core (= 0.29.2) + declarative-builder (0.2.0) + trailblazer-option (~> 0.1.0) declarative-option (0.1.0) deface (1.9.0) actionview (>= 5.2) @@ -333,16 +334,16 @@ GEM warden (~> 1.2.3) devise-i18n (1.11.0) devise (>= 4.9.0) - devise_invitable (2.0.9) + devise_invitable (2.0.10) actionmailer (>= 5.0) devise (>= 4.6) diff-lcs (1.5.1) - diffy (3.4.2) - doc2text (0.4.7) - nokogiri (>= 1.13.2, < 1.17.0) + diffy (3.4.3) + doc2text (0.4.8) + nokogiri (>= 1.18.2) rubyzip (~> 2.3.0) docile (1.4.0) - doorkeeper (5.7.1) + doorkeeper (5.8.1) railties (>= 5) doorkeeper-i18n (4.0.1) erb_lint (0.4.0) @@ -354,9 +355,10 @@ GEM smart_properties erbse (0.1.4) temple - erubi (1.13.0) - escape_utils (1.2.2) - excon (0.111.0) + erubi (1.13.1) + escape_utils (1.3.0) + excon (1.2.5) + logger extended-markdown-filter (0.7.0) html-pipeline (~> 2.9) factory_bot (6.4.6) @@ -366,21 +368,22 @@ GEM railties (>= 5.0.0) faker (3.3.1) i18n (>= 1.8.11, < 2) - faraday (2.10.0) - faraday-net_http (>= 2.0, < 3.2) + faraday (2.12.2) + faraday-net_http (>= 2.0, < 3.5) + json logger - faraday-net_http (3.1.0) - net-http - ffi (1.17.0) + faraday-net_http (3.4.0) + net-http (>= 0.5.0) + ffi (1.17.1) file_validators (3.0.0) activemodel (>= 3.2) mime-types (>= 1.0) - fog-core (2.4.0) + fog-core (2.6.0) builder - excon (~> 0.71) + excon (~> 1.0) formatador (>= 0.2, < 2.0) mime-types - fog-local (0.8.0) + fog-local (0.9.0) fog-core (>= 1.27, < 3.0) formatador (1.1.0) foundation_rails_helper (4.0.1) @@ -389,29 +392,29 @@ GEM activesupport (>= 4.1, < 7.1) railties (>= 4.1, < 7.1) gemoji (3.0.1) - geocoder (1.8.3) + geocoder (1.8.5) base64 (>= 0.1.0) csv (>= 3.0.0) globalid (1.2.1) activesupport (>= 6.1) - graphql (2.0.31) + graphql (2.2.17) base64 - graphql-docs (3.0.1) - commonmarker (~> 0.16) - escape_utils (~> 1.2.2) + graphql-docs (4.0.0) + commonmarker (~> 0.23, >= 0.23.6) + dartsass (~> 1.49) + escape_utils (~> 1.2) extended-markdown-filter (~> 0.4) gemoji (~> 3.0) graphql (~> 2.0) - html-pipeline (~> 2.9) - sass (~> 3.4) - hashdiff (1.1.0) + html-pipeline (~> 2.14, >= 2.14.3) + hashdiff (1.1.2) hashie (5.0.0) highline (3.0.1) html-pipeline (2.14.3) activesupport (>= 2) nokogiri (>= 1.4) htmlentities (4.3.4) - i18n (1.14.5) + i18n (1.14.7) concurrent-ruby (~> 1.0) i18n-tasks (1.0.14) activesupport (>= 4.0.2) @@ -424,16 +427,17 @@ GEM rainbow (>= 2.2.2, < 4.0) terminal-table (>= 1.5.1) i18n_data (0.11.0) - icalendar (2.10.1) + icalendar (2.10.3) ice_cube (~> 0.16) - ice_cube (0.16.4) - image_processing (1.12.2) - mini_magick (>= 4.9.5, < 5) + ostruct + ice_cube (0.17.0) + image_processing (1.14.0) + mini_magick (>= 4.9.5, < 6) ruby-vips (>= 2.0.17, < 3) invisible_captcha (0.13.0) rails (>= 3.2.0) - json (2.7.2) - jwt (2.8.2) + json (2.10.2) + jwt (2.10.1) base64 kaminari (1.2.2) activesupport (>= 4.1.0) @@ -447,6 +451,7 @@ GEM activerecord kaminari-core (= 1.2.2) kaminari-core (1.2.2) + language_server-protocol (3.17.0.4) launchy (3.1.0) addressable (~> 2.8) childprocess (~> 5.0) @@ -461,8 +466,8 @@ GEM listen (3.9.0) rb-fsevent (~> 0.10, >= 0.10.3) rb-inotify (~> 0.9, >= 0.9.10) - logger (1.6.0) - loofah (2.22.0) + logger (1.7.0) + loofah (2.24.0) crass (~> 1.0.2) nokogiri (>= 1.12.0) mail (2.8.1) @@ -473,17 +478,20 @@ GEM marcel (1.0.4) matrix (0.4.2) method_source (1.1.0) - mime-types (3.5.2) + mime-types (3.6.2) + logger mime-types-data (~> 3.2015) - mime-types-data (3.2024.0702) + mime-types-data (3.2025.0325) mini_magick (4.13.2) mini_mime (1.1.5) - minitest (5.24.1) + mini_portile2 (2.8.8) + minitest (5.25.5) msgpack (1.7.2) - multi_xml (0.6.0) - net-http (0.4.1) + multi_xml (0.7.1) + bigdecimal (~> 3.1) + net-http (0.6.0) uri - net-imap (0.4.14) + net-imap (0.5.6) date net-protocol net-pop (0.1.2) @@ -492,10 +500,9 @@ GEM timeout net-smtp (0.3.4) net-protocol - nio4r (2.7.3) - nokogiri (1.16.6-x86_64-darwin) - racc (~> 1.4) - nokogiri (1.16.6-x86_64-linux) + nio4r (2.7.4) + nokogiri (1.18.7) + mini_portile2 (~> 2.8.2) racc (~> 1.4) oauth (1.1.0) oauth-tty (~> 1.0, >= 1.0.1) @@ -510,20 +517,21 @@ GEM rack (>= 1.2, < 4) snaky_hash (~> 2.0) version_gem (~> 1.1) - omniauth (2.1.2) + omniauth (2.1.3) hashie (>= 3.4.6) rack (>= 2.2.3) rack-protection omniauth-facebook (5.0.0) omniauth-oauth2 (~> 1.2) - omniauth-google-oauth2 (1.1.2) - jwt (>= 2.0) + omniauth-google-oauth2 (1.2.1) + jwt (>= 2.9.2) oauth2 (~> 2.0) omniauth (~> 2.0) omniauth-oauth2 (~> 1.8) - omniauth-oauth (1.2.0) + omniauth-oauth (1.2.1) oauth omniauth (>= 1.0, < 3) + rack (>= 1.6.2, < 4) omniauth-oauth2 (1.8.0) oauth2 (>= 1.4, < 3) omniauth (~> 2.0) @@ -533,8 +541,9 @@ GEM omniauth-twitter (1.4.0) omniauth-oauth (~> 1.1) rack - openssl (3.2.0) + openssl (3.3.0) orm_adapter (0.5.0) + ostruct (0.6.1) paper_trail (12.3.0) activerecord (>= 5.2) request_store (~> 1.1) @@ -545,13 +554,13 @@ GEM ast (~> 2.4.1) racc pg (1.4.6) - pg_search (2.3.6) - activerecord (>= 5.2) - activesupport (>= 5.2) + pg_search (2.3.7) + activerecord (>= 6.1) + activesupport (>= 6.1) polyglot (0.3.5) - premailer (1.23.0) + premailer (1.27.0) addressable - css_parser (>= 1.12.0) + css_parser (>= 1.19.0) htmlentities (>= 4.0.0) premailer-rails (1.12.0) actionmailer (>= 3) @@ -559,11 +568,11 @@ GEM premailer (~> 1.7, >= 1.7.9) psych (4.0.6) stringio - public_suffix (6.0.0) + public_suffix (6.0.1) puma (6.4.2) nio4r (~> 2.0) - racc (1.8.0) - rack (2.2.9) + racc (1.8.1) + rack (2.2.13) rack-attack (6.7.0) rack (>= 1.0, < 4) rack-cors (1.1.1) @@ -573,23 +582,22 @@ GEM rack (~> 2.2, >= 2.2.4) rack-proxy (0.7.7) rack - rack-test (2.1.0) + rack-test (2.2.0) rack (>= 1.3) - rails (6.1.7.8) - actioncable (= 6.1.7.8) - actionmailbox (= 6.1.7.8) - actionmailer (= 6.1.7.8) - actionpack (= 6.1.7.8) - actiontext (= 6.1.7.8) - actionview (= 6.1.7.8) - activejob (= 6.1.7.8) - activemodel (= 6.1.7.8) - activerecord (= 6.1.7.8) - activestorage (= 6.1.7.8) - activesupport (= 6.1.7.8) + rails (7.0.8.7) + actioncable (= 7.0.8.7) + actionmailbox (= 7.0.8.7) + actionmailer (= 7.0.8.7) + actionpack (= 7.0.8.7) + actiontext (= 7.0.8.7) + actionview (= 7.0.8.7) + activejob (= 7.0.8.7) + activemodel (= 7.0.8.7) + activerecord (= 7.0.8.7) + activestorage (= 7.0.8.7) + activesupport (= 7.0.8.7) bundler (>= 1.15.0) - railties (= 6.1.7.8) - sprockets-rails (>= 2.0.0) + railties (= 7.0.8.7) rails-controller-testing (1.0.5) actionpack (>= 5.0.1.rc1) actionview (>= 5.0.1.rc1) @@ -598,18 +606,19 @@ GEM activesupport (>= 5.0.0) minitest nokogiri (>= 1.6) - rails-html-sanitizer (1.6.0) + rails-html-sanitizer (1.6.2) loofah (~> 2.21) - nokogiri (~> 1.14) - rails-i18n (6.0.0) + nokogiri (>= 1.15.7, != 1.16.7, != 1.16.6, != 1.16.5, != 1.16.4, != 1.16.3, != 1.16.2, != 1.16.1, != 1.16.0.rc1, != 1.16.0) + rails-i18n (7.0.10) i18n (>= 0.7, < 2) - railties (>= 6.0.0, < 7) - railties (6.1.7.8) - actionpack (= 6.1.7.8) - activesupport (= 6.1.7.8) + railties (>= 6.0.0, < 8) + railties (7.0.8.7) + actionpack (= 7.0.8.7) + activesupport (= 7.0.8.7) method_source rake (>= 12.2) thor (~> 1.0) + zeitwerk (~> 2.5) rainbow (3.1.1) rake (13.2.1) ransack (3.2.1) @@ -619,7 +628,7 @@ GEM rb-fsevent (0.11.2) rb-inotify (0.11.1) ffi (~> 1.0) - redcarpet (3.6.0) + redcarpet (3.6.1) redis (4.8.1) regexp_parser (2.9.2) request_store (1.5.1) @@ -660,57 +669,56 @@ GEM rspec-support (3.13.1) rspec_junit_formatter (0.6.0) rspec-core (>= 2, < 4, != 2.12.0) - rubocop (1.50.2) + rubocop (1.65.1) json (~> 2.3) + language_server-protocol (>= 3.17.0) parallel (~> 1.10) - parser (>= 3.2.0.0) + parser (>= 3.3.0.2) rainbow (>= 2.2.2, < 4.0) - regexp_parser (>= 1.8, < 3.0) + regexp_parser (>= 2.4, < 3.0) rexml (>= 3.2.5, < 4.0) - rubocop-ast (>= 1.28.0, < 2.0) + rubocop-ast (>= 1.31.1, < 2.0) ruby-progressbar (~> 1.7) unicode-display_width (>= 2.4.0, < 3.0) rubocop-ast (1.31.3) parser (>= 3.3.1.0) rubocop-capybara (2.21.0) rubocop (~> 1.41) - rubocop-factory_bot (2.25.1) - rubocop (~> 1.41) + rubocop-factory_bot (2.26.1) + rubocop (~> 1.61) rubocop-faker (1.1.0) faker (>= 2.12.0) rubocop (>= 0.82.0) + rubocop-performance (1.23.1) + rubocop (>= 1.48.1, < 2.0) + rubocop-ast (>= 1.31.1, < 2.0) rubocop-rails (2.25.1) activesupport (>= 4.2.0) rack (>= 1.1) rubocop (>= 1.33.0, < 2.0) rubocop-ast (>= 1.31.1, < 2.0) - rubocop-rspec (2.31.0) - rubocop (~> 1.40) - rubocop-capybara (~> 2.17) - rubocop-factory_bot (~> 2.22) - rubocop-rspec_rails (~> 2.28) - rubocop-rspec_rails (2.28.3) - rubocop (~> 1.40) + rubocop-rspec (3.4.0) + rubocop (~> 1.61) + rubocop-rspec_rails (2.30.0) + rubocop (~> 1.61) + rubocop-rspec (~> 3, >= 3.0.1) + rubocop-rubycw (0.1.6) + rubocop (~> 1.0) ruby-progressbar (1.13.0) - ruby-vips (2.2.1) + ruby-vips (2.2.3) ffi (~> 1.12) - rubyXL (3.4.27) + logger + rubyXL (3.4.33) nokogiri (>= 1.10.8) rubyzip (>= 1.3.0) rubyzip (2.3.2) - sass (3.7.4) - sass-listen (~> 4.0.0) - sass-listen (4.0.0) - rb-fsevent (~> 0.9, >= 0.9.4) - rb-inotify (~> 0.9, >= 0.9.7) selenium-webdriver (4.22.0) base64 (~> 0.2) logger (~> 1.4) rexml (~> 3.2, >= 3.2.5) rubyzip (>= 1.2.2, < 3.0) websocket (~> 1.0) - semantic_range (3.0.0) - seven_zip_ruby (1.3.0) + semantic_range (3.1.0) shakapacker (7.1.0) activesupport (>= 5.2) rack-proxy (>= 0.6.1) @@ -732,37 +740,30 @@ GEM version_gem (~> 1.1, >= 1.1.1) sort_alphabetical (1.1.0) unicode_utils (>= 1.2.2) - spring (2.1.1) - spring-watcher-listen (2.0.1) + spring (4.3.0) + spring-watcher-listen (2.1.0) listen (>= 2.7, < 4.0) - spring (>= 1.2, < 3.0) - sprockets (4.2.1) - concurrent-ruby (~> 1.0) - rack (>= 2.2.4, < 4) - sprockets-rails (3.5.1) - actionpack (>= 6.1) - activesupport (>= 6.1) - sprockets (>= 3.0.0) - ssrf_filter (1.1.2) - stringio (3.1.1) + spring (>= 4) + stringio (3.1.6) strscan (3.1.0) temple (0.10.3) terminal-table (3.0.2) unicode-display_width (>= 1.1.1, < 3) - thor (1.3.1) - tilt (2.4.0) - timeout (0.4.1) + thor (1.3.2) + tilt (2.6.0) + timeout (0.4.3) + trailblazer-option (0.1.2) tzinfo (2.0.6) concurrent-ruby (~> 1.0) uber (0.1.0) unicode-display_width (2.5.0) unicode_utils (1.4.0) uniform_notifier (1.16.0) - uri (0.13.0) + uri (1.0.3) valid_email2 (4.0.6) activemodel (>= 3.2) mail (~> 2.5) - version_gem (1.1.4) + version_gem (1.1.6) w3c_rspec_validators (0.3.0) rails rspec @@ -786,42 +787,37 @@ GEM crack (>= 0.3.2) hashdiff (>= 0.4.0, < 2.0.0) websocket (1.2.10) - websocket-driver (0.7.6) + websocket-driver (0.7.7) + base64 websocket-extensions (>= 0.1.0) websocket-extensions (0.1.5) - wicked_pdf (2.8.0) + wicked_pdf (2.8.2) activesupport + ostruct wisper (2.0.1) wisper-rspec (1.1.0) - wkhtmltopdf-binary (0.12.6.7) xpath (3.2.0) nokogiri (~> 1.8) - zeitwerk (2.6.16) + zeitwerk (2.7.2) PLATFORMS - x86_64-darwin-24 - x86_64-linux + ruby DEPENDENCIES - bootsnap (~> 1.3) + bootsnap (~> 1.7) byebug (~> 11.0) - country_select (~> 4.0) - decidim (~> 0.28) - decidim-dev (~> 0.28) + decidim (~> 0.29.2) + decidim-dev (~> 0.29.2) decidim-extra_user_fields! faker (~> 3.3.1) letter_opener_web (~> 2.0) listen (~> 3.1) - puma (>= 4.3) - rubocop-factory_bot (!= 2.26.0) + puma (>= 6.3.1) rubocop-faker - rubocop-rspec_rails (!= 2.29.0) - spring (~> 2.0) - spring-watcher-listen (~> 2.0) web-console (~> 4.2) RUBY VERSION - ruby 3.1.1p18 + ruby 3.2.6p234 BUNDLED WITH - 2.4.10 + 2.6.5 diff --git a/README.md b/README.md index 9eb281f..8823339 100644 --- a/README.md +++ b/README.md @@ -17,6 +17,12 @@ This module also enables an Export action in the participants admin panel, which Pick the version of the gem that matches your Decidim version. +For Decidim 0.28: + +```ruby +gem "decidim-extra_user_fields", git: "https://github.com/PopulateTools/decidim-module-extra_user_fields.git", branch: "release/0.28-stable" +``` + For Decidim 0.27: ```ruby diff --git a/app/commands/concerns/decidim/extra_user_fields/update_account_commands_overrides.rb b/app/commands/concerns/decidim/extra_user_fields/update_account_commands_overrides.rb index 2907c1e..41989f6 100644 --- a/app/commands/concerns/decidim/extra_user_fields/update_account_commands_overrides.rb +++ b/app/commands/concerns/decidim/extra_user_fields/update_account_commands_overrides.rb @@ -11,17 +11,17 @@ module UpdateAccountCommandsOverrides private def update_personal_data - @user.locale = @form.locale - @user.name = @form.name - @user.nickname = @form.nickname - @user.email = @form.email - @user.personal_url = @form.personal_url - @user.about = @form.about - @user.extended_data = extended_data + current_user.locale = @form.locale + current_user.name = @form.name + current_user.nickname = @form.nickname + current_user.email = @form.email + current_user.personal_url = @form.personal_url + current_user.about = @form.about + current_user.extended_data = extended_data end def extended_data - @extended_data ||= (@user&.extended_data || {}).merge( + @extended_data ||= (current_user&.extended_data || {}).merge( country: @form.country, postal_code: @form.postal_code, date_of_birth: @form.date_of_birth, diff --git a/app/forms/concerns/decidim/extra_user_fields/forms_definitions.rb b/app/forms/concerns/decidim/extra_user_fields/forms_definitions.rb index 982d7ac..d35b8bb 100644 --- a/app/forms/concerns/decidim/extra_user_fields/forms_definitions.rb +++ b/app/forms/concerns/decidim/extra_user_fields/forms_definitions.rb @@ -89,7 +89,7 @@ def phone_number? end def phone_number_format? - return unless phone_number? + return false unless phone_number? current_organization.extra_user_field_configuration(:phone_number)["pattern"].present? end diff --git a/app/overrides/decidim/account/show/extra_user_fields.html.erb.deface b/app/overrides/decidim/account/show/extra_user_fields.html.erb.deface index 87a24c9..5cbbd42 100644 --- a/app/overrides/decidim/account/show/extra_user_fields.html.erb.deface +++ b/app/overrides/decidim/account/show/extra_user_fields.html.erb.deface @@ -1,3 +1,3 @@ - + <%= render partial: "/decidim/extra_user_fields/profile_form", locals: { f: f } %> diff --git a/app/views/decidim/extra_user_fields/_profile_form.html.erb b/app/views/decidim/extra_user_fields/_profile_form.html.erb index 46473e0..e9d6218 100644 --- a/app/views/decidim/extra_user_fields/_profile_form.html.erb +++ b/app/views/decidim/extra_user_fields/_profile_form.html.erb @@ -1,6 +1,6 @@ <% if current_organization.extra_user_fields_enabled? %> <% if current_organization.activated_extra_field?(:date_of_birth) %> - <%= f.date_field :date_of_birth %> +
<%= f.date_field :date_of_birth %>
<% end %> <% if current_organization.activated_extra_field?(:gender) %> diff --git a/app/views/decidim/extra_user_fields/_registration_form.html.erb b/app/views/decidim/extra_user_fields/_registration_form.html.erb index 1445088..c03d28c 100644 --- a/app/views/decidim/extra_user_fields/_registration_form.html.erb +++ b/app/views/decidim/extra_user_fields/_registration_form.html.erb @@ -3,7 +3,7 @@

<%= t(".signup.legend") %>

<% if current_organization.activated_extra_field?(:date_of_birth) %> - <%= f.date_field :date_of_birth, id: "user_date_of_birth" %> +
<%= f.date_field :date_of_birth, id: "user_date_of_birth" %>
<% end %> <% if current_organization.activated_extra_field?(:gender) %> diff --git a/bin/dev b/bin/dev new file mode 100755 index 0000000..e009f8d --- /dev/null +++ b/bin/dev @@ -0,0 +1,5 @@ +#!/usr/bin/env sh + +cd development_app + +./bin/dev diff --git a/decidim-extra_user_fields.gemspec b/decidim-extra_user_fields.gemspec index 50077d9..a5935e2 100644 --- a/decidim-extra_user_fields.gemspec +++ b/decidim-extra_user_fields.gemspec @@ -10,7 +10,7 @@ Gem::Specification.new do |s| s.email = ["fernando@populate.tools"] s.license = "AGPL-3.0" s.homepage = "https://github.com/PopulateTools/decidim-module-extra_user_fields" - s.required_ruby_version = ">= 3.0.2" + s.required_ruby_version = ">= 3.2.0" s.name = "decidim-extra_user_fields" s.summary = "Decidim module to add extra fields to users." diff --git a/lib/decidim/extra_user_fields/admin_engine.rb b/lib/decidim/extra_user_fields/admin_engine.rb index 0c058a3..e398626 100644 --- a/lib/decidim/extra_user_fields/admin_engine.rb +++ b/lib/decidim/extra_user_fields/admin_engine.rb @@ -17,7 +17,7 @@ class AdminEngine < ::Rails::Engine end resources :extra_user_fields, only: [:index] - match "/extra_user_fields" => "extra_user_fields#update", :via => :patch, as: "update" + match "/extra_user_fields" => "extra_user_fields#update", :via => :patch, :as => "update" root to: "extra_user_fields#index" end diff --git a/lib/decidim/extra_user_fields/form_builder_methods.rb b/lib/decidim/extra_user_fields/form_builder_methods.rb index a1345a3..378d34a 100644 --- a/lib/decidim/extra_user_fields/form_builder_methods.rb +++ b/lib/decidim/extra_user_fields/form_builder_methods.rb @@ -5,13 +5,18 @@ module ExtraUserFields # This module adds the FormBuilder methods for extra user fields module FormBuilderMethods def custom_country_select(name, options = {}) - label_text = options[:label].to_s - label_text = label_for(name) if label_text.blank? + label_text = options[:label].presence || label_for(name) + html = +"" + html << (label_text + required_for_attribute(name)) if options.fetch(:label, true) + html << sanitize_country_select(country_select(name)) + html.html_safe + end + + private - template = "" - template += (label_text + required_for_attribute(name)) if options.fetch(:label, true) - template += country_select(name) - template.html_safe + # Remove non-standard attrs added by country_select that fail HTML/accessibility validation + def sanitize_country_select(html) + html.gsub(/\s(skip_default_ids|allow_method_names_outside_object)="[^"]*"/, "") end end end diff --git a/lib/decidim/extra_user_fields/version.rb b/lib/decidim/extra_user_fields/version.rb index f28f7fe..5349aae 100644 --- a/lib/decidim/extra_user_fields/version.rb +++ b/lib/decidim/extra_user_fields/version.rb @@ -4,11 +4,11 @@ module Decidim # This holds the decidim-extra_user_fields version. module ExtraUserFields def self.version - "0.28.0" + "0.29.0" end def self.decidim_version - [">= 0.28"].freeze + [">= 0.29"].freeze end end end diff --git a/spec/factories.rb b/spec/factories.rb index 3fda653..b362b31 100644 --- a/spec/factories.rb +++ b/spec/factories.rb @@ -9,7 +9,10 @@ create_static_pages { true } end - name { Faker::Company.unique.name } + name do + Decidim.available_locales.index_with { |_locale| Faker::Company.unique.name } + end + reference_prefix { Faker::Name.suffix } time_zone { "UTC" } twitter_handler { Faker::Hipster.word } @@ -34,7 +37,7 @@ admin_terms_of_service_body { Decidim::Faker::Localized.wrapped("

", "

") { generate_localized_title } } force_users_to_authenticate_before_access_organization { false } machine_translation_display_priority { "original" } - external_domain_whitelist { ["example.org", "twitter.com", "facebook.com", "youtube.com", "github.com", "mytesturl.me"] } + external_domain_allowlist { ["example.org", "twitter.com", "facebook.com", "youtube.com", "github.com", "mytesturl.me"] } smtp_settings do { "from" => "test@example.org", diff --git a/spec/forms/decidim/registration_form_spec.rb b/spec/forms/decidim/registration_form_spec.rb index 7d46383..b04f8f3 100644 --- a/spec/forms/decidim/registration_form_spec.rb +++ b/spec/forms/decidim/registration_form_spec.rb @@ -154,7 +154,7 @@ module Decidim context "when the nickname already exists" do context "and a user has the nickname" do - let!(:another_user) { create(:user, organization:, nickname: name.upcase) } + let!(:another_user) { create(:user, organization:, nickname: name) } it { is_expected.to be_valid } diff --git a/spec/lib/overrides_spec.rb b/spec/lib/overrides_spec.rb new file mode 100644 index 0000000..1f5cbe4 --- /dev/null +++ b/spec/lib/overrides_spec.rb @@ -0,0 +1,44 @@ +# frozen_string_literal: true + +require "spec_helper" + +# We make sure that the checksum of the file overriden is the same +# as the expected. If this test fails, it means that the overriden +# file should be updated to match any change/bug fix introduced in the core +checksums = [ + { + package: "decidim-core", + files: { + "/app/commands/decidim/create_registration.rb" => "c2fafd313dbe16624e3ef07584e946cd", + "/app/commands/decidim/create_omniauth_registration.rb" => "5bca48c990c3b82d47119902c0a56ca1", + "/app/commands/decidim/update_account.rb" => "d24090fdd9358c38e6e15c4607a78e18", + "/app/models/decidim/organization.rb" => "a72b9d9ef10aa06dbe5aef27c68d5c7a", + "/app/views/decidim/account/show.html.erb" => "f13218e2358a2d611996c2a197c0de25", + "/app/views/decidim/devise/registrations/new.html.erb" => "b30423406afd43bb9af2c98d59d43632", + "/app/views/decidim/devise/omniauth_registrations/new.html.erb" => "49f44efcd7ae6f87c04b309733ff28f6" + } + }, + { + package: "decidim-admin", + files: { + "/app/views/decidim/admin/officializations/index.html.erb" => "e849c5dbaf04379bf233c15e860e1a18" + } + } +] + +describe "Overriden files", type: :view do + checksums.each do |item| + spec = Gem::Specification.find_by_name(item[:package]) + item[:files].each do |file, signature| + it "#{spec.gem_dir}#{file} matches checksum" do + expect(md5("#{spec.gem_dir}#{file}")).to eq(signature) + end + end + end + + private + + def md5(file) + Digest::MD5.hexdigest(File.read(file)) + end +end diff --git a/spec/models/decidim/organization_spec.rb b/spec/models/decidim/organization_spec.rb index 4760cfc..57ff74a 100644 --- a/spec/models/decidim/organization_spec.rb +++ b/spec/models/decidim/organization_spec.rb @@ -32,6 +32,10 @@ module Decidim enabled: true, client_id: nil, client_secret: nil + }, + test: { + enabled: true, + icon: "tools-line" } } end diff --git a/spec/system/account_spec.rb b/spec/system/account_spec.rb index 5c66f68..94f4e08 100644 --- a/spec/system/account_spec.rb +++ b/spec/system/account_spec.rb @@ -80,7 +80,17 @@ visit decidim.account_path end - it_behaves_like "accessible page" + context "when all extra fields are accessible-compatible" do + let(:date_of_birth) { { "enabled" => false } } + + # NOTE: We skip running the accessibility test when `date_of_birth` is enabled + # because the custom Decidim datepicker JavaScript removes accessibility attributes + # like `title`, `aria-label`, and causes Axe validation errors. + # + # This test runs only when `date_of_birth` is disabled to avoid false negatives. + + it_behaves_like "accessible page" + end describe "updating personal data" do let!(:encrypted_password) { user.encrypted_password } @@ -92,7 +102,7 @@ fill_in :user_personal_url, with: "https://example.org" fill_in :user_about, with: "A Serbian-American inventor, electrical engineer, mechanical engineer, physicist, and futurist." - fill_in :user_date_of_birth, with: "01/01/2000" + fill_in :user_date_of_birth_date, with: "01/01/2000" select "Other", from: :user_gender select "Argentina", from: :user_country fill_in :user_postal_code, with: "00000" @@ -132,7 +142,7 @@ end it "shows error when image is too big" do - find("#user_avatar_button").click + find_by_id("user_avatar_button").click within ".upload-modal" do click_on "Remove" @@ -222,7 +232,7 @@ fill_in :user_personal_url, with: "https://example.org" fill_in :user_about, with: "A Serbian-American inventor, electrical engineer, mechanical engineer, physicist, and futurist." - fill_in :user_date_of_birth, with: "01/01/2000" + fill_in :user_date_of_birth_date, with: "01/01/2000" select "Other", from: :user_gender select "Argentina", from: :user_country fill_in :user_postal_code, with: "00000" @@ -282,7 +292,7 @@ fill_in :user_personal_url, with: "https://example.org" fill_in :user_about, with: "A Serbian-American inventor, electrical engineer, mechanical engineer, physicist, and futurist." - fill_in :user_date_of_birth, with: "01/01/2000" + fill_in :user_date_of_birth_date, with: "01/01/2000" select "Other", from: :user_gender select "Argentina", from: :user_country fill_in :user_postal_code, with: "00000" @@ -302,7 +312,7 @@ it "toggles the current password" do expect(page).to have_content("In order to confirm the changes to your account, please provide your current password.") - expect(find("#user_old_password")).to be_visible + expect(find_by_id("user_old_password")).to be_visible expect(page).to have_content "Current password" expect(page).to have_no_content "Password" end @@ -536,7 +546,7 @@ expect(page).to have_content("successfully") end - find(:css, "#allow_push_notifications", visible: false).execute_script("this.checked = true") + find_by_id("allow_push_notifications", visible: false).execute_script("this.checked = true") end end end diff --git a/spec/system/admin_manages_officializations_spec.rb b/spec/system/admin_manages_officializations_spec.rb index 93a1b69..815ef71 100644 --- a/spec/system/admin_manages_officializations_spec.rb +++ b/spec/system/admin_manages_officializations_spec.rb @@ -2,7 +2,7 @@ require "spec_helper" -describe "Admin manages officializations" do +describe "Admin manages officializations" do # rubocop:disable RSpec/DescribeClass include_context "with filterable context" let(:model_name) { Decidim::User.model_name } diff --git a/spec/system/admin_manages_organization_extra_user_fields_spec.rb b/spec/system/admin_manages_organization_extra_user_fields_spec.rb index 1c46fec..2cfcd72 100644 --- a/spec/system/admin_manages_organization_extra_user_fields_spec.rb +++ b/spec/system/admin_manages_organization_extra_user_fields_spec.rb @@ -2,7 +2,7 @@ require "spec_helper" -describe "Admin manages organization extra user fields" do +describe "Admin manages organization extra user fields" do # rubocop:disable RSpec/DescribeClass let(:organization) { create(:organization) } let(:user) { create(:user, :admin, :confirmed, organization:) } diff --git a/spec/system/registration_spec.rb b/spec/system/registration_spec.rb index 9250b93..317aab3 100644 --- a/spec/system/registration_spec.rb +++ b/spec/system/registration_spec.rb @@ -11,7 +11,7 @@ def fill_registration_form end def fill_extra_user_fields - fill_in :registration_user_date_of_birth, with: "01/01/2000" + fill_in :registration_user_date_of_birth_date, with: "01/01/2000" select "Other", from: :registration_user_gender select "Argentina", from: :registration_user_country fill_in :registration_user_postal_code, with: "00000" @@ -22,7 +22,7 @@ def fill_extra_user_fields # EndBlock end -describe "Extra user fields" do +describe "Extra user fields" do # rubocop:disable RSpec/DescribeClass shared_examples_for "mandatory extra user fields" do |field| it "displays #{field} as mandatory" do within "label[for='registration_user_#{field}']" do From fe9d06f5400683dd171aef58ac76ccfe7f05dddc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ivan=20Verg=C3=A9s?= Date: Fri, 9 May 2025 09:18:22 +0200 Subject: [PATCH 03/10] Release/0.29 stable (#2) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * upgrade to 0.29 * update CI * fix tests * fix tests * fix test * Apply suggestions from code review Co-authored-by: Ivan Vergés * Update Gemfile and lockfile for Decidim 0.29.2 * fix accessibility test * add overrides_spec * fix custom_country_select --------- Co-authored-by: Anna Topalidi Co-authored-by: Anna Topalidi <60363870+antopalidi@users.noreply.github.com> From ddd42d3390a970c1394bedc1c55ed25d8e7cd703 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ivan=20Verg=C3=A9s?= Date: Fri, 9 May 2025 11:20:13 +0200 Subject: [PATCH 04/10] add gender options (#3) * add gender options * add age range * add translations * add readme * fix locales --- README.md | 85 +++++++++++++------ ...create_registrations_commands_overrides.rb | 1 + .../omniauth_commands_overrides.rb | 1 + .../update_account_commands_overrides.rb | 1 + .../admin/update_extra_user_fields.rb | 8 +- .../admin/extra_user_fields_controller.rb | 2 +- .../extra_user_fields/forms_definitions.rb | 9 +- .../admin/extra_user_fields_form.rb | 4 +- .../extra_user_fields/application_helper.rb | 8 +- .../user_export_serializer.rb | 3 +- .../extra_user_fields/_profile_form.html.erb | 4 + .../_registration_form.html.erb | 4 + .../admin/extra_user_fields/_form.html.erb | 1 + .../fields/_age_range.html.erb | 5 ++ .../fields/_underage.html.erb | 2 +- config/i18n-tasks.yml | 1 + config/locales/ca.yml | 14 ++- config/locales/de.yml | 40 +++++++-- config/locales/en.yml | 14 ++- config/locales/es.yml | 14 ++- config/locales/eu.yml | 37 ++++++-- config/locales/fr.yml | 14 ++- lib/decidim/extra_user_fields.rb | 25 ++++++ lib/decidim/extra_user_fields/engine.rb | 6 -- ...cidim_extra_user_fields_upgrade_tasks.rake | 5 ++ .../create_omniauth_registration_spec.rb | 3 + .../decidim/create_registration_spec.rb | 3 + .../admin/update_extra_user_fields_spec.rb | 8 +- spec/forms/decidim/account_form_spec.rb | 1 + .../omniauth_registration_form_spec.rb | 2 + spec/forms/decidim/registration_form_spec.rb | 3 + .../user_export_serializer_spec.rb | 6 ++ spec/system/account_spec.rb | 16 ++++ spec/system/registration_spec.rb | 12 ++- 34 files changed, 293 insertions(+), 69 deletions(-) create mode 100644 app/views/decidim/extra_user_fields/admin/extra_user_fields/fields/_age_range.html.erb create mode 100644 lib/tasks/decidim_extra_user_fields_upgrade_tasks.rake diff --git a/README.md b/README.md index 8823339..4bd671e 100644 --- a/README.md +++ b/README.md @@ -15,45 +15,43 @@ This module also enables an Export action in the participants admin panel, which ## Installation -Pick the version of the gem that matches your Decidim version. - -For Decidim 0.28: +Add this line to your application's Gemfile: ```ruby -gem "decidim-extra_user_fields", git: "https://github.com/PopulateTools/decidim-module-extra_user_fields.git", branch: "release/0.28-stable" +gem 'decidim-extra_user_fields', github: 'openpoke/decidim-module-extra_user_fields' ``` -For Decidim 0.27: +or for the original one: ```ruby -gem "decidim-extra_user_fields", git: "https://github.com/PopulateTools/decidim-module-extra_user_fields.git", branch: "release/0.27-stable" +gem 'decidim-extra_user_fields', github: 'PopulateTools/decidim-module-extra_user_fields' ``` -For Decidim 0.26: +And then execute: -```ruby -gem "decidim-extra_user_fields", git: "https://github.com/PopulateTools/decidim-module-extra_user_fields.git", branch: "release/0.26-stable" +```bash +bundle +bin/rails decidim:upgrade +bin/rails db:migrate ``` -For Decidim 0.25: +> **EXPERTS ONLY** +> +> Under the hood, when running `bundle exec rails decidim:upgrade` the `decidim-extra_user_fields` gem will run the following (that can also be run manually if you consider): +> +> ```bash +> bin/rails decidim_extra_user_fields:install:migrations +> ``` -```ruby -gem "decidim-extra_user_fields", git: "https://github.com/PopulateTools/decidim-module-extra_user_fields.git", branch: "release/0.25-stable" -``` +You can also the version of the gem that matches your Decidim version: -For Decidim 0.24: ```ruby -gem "decidim-extra_user_fields", git: "https://github.com/PopulateTools/decidim-module-extra_user_fields.git", branch: "release/0.24-stable" -``` - -And then execute: - -```bash -bundle install -# For versions >= 0.27 -bundle exec rake railties:install:migrations -bundle exec rake db:migrate +gem "decidim-extra_user_fields", github: "PopulateTools/decidim-module-extra_user_fields", branch: "release/0.28-stable" +gem "decidim-extra_user_fields", github: "PopulateTools/decidim-module-extra_user_fields", branch: "release/0.27-stable" +gem "decidim-extra_user_fields", github: "PopulateTools/decidim-module-extra_user_fields", branch: "release/0.26-stable" +gem "decidim-extra_user_fields", github: "PopulateTools/decidim-module-extra_user_fields", branch: "release/0.25-stable" +gem "decidim-extra_user_fields", github: "PopulateTools/decidim-module-extra_user_fields", branch: "release/0.24-stable" ``` ## Usage @@ -62,7 +60,7 @@ bundle exec rake db:migrate After installing the gem and migrating the database, you can enable the extra fields in the admin panel of the organization. Go to Settings > Manage extra user fields. There you can enable the fields you want to use. By default all fields are required and don't include any format validation. -![Admin panel](https://github.com/PopulateTools/decidim-module-extra_user_fields/blob/extra-fields-0-27/docs/resources/extra_user_fields_admin.png) +![Admin panel](docs/resources/extra_user_fields_admin.png) Most of the fields are plain text inputs, but other have a special format: @@ -73,16 +71,47 @@ Most of the fields are plain text inputs, but other have a special format: Once the fields are enabled, they will be shown in the user signup form and in the user profile. -![User signup](https://github.com/PopulateTools/decidim-module-extra_user_fields/blob/extra-fields-0-27/docs/resources/extra_user_fields_signup.png) +![User signup](docs/resources/extra_user_fields_signup.png) -![User profile](https://github.com/PopulateTools/decidim-module-extra_user_fields/blob/extra-fields-0-27/docs/resources/extra_user_fields_profile.png) +![User profile](docs/resources/extra_user_fields_profile.png) ### Admin users export An extra feature of this plugin is to enable an Export action in the participants admin panel. This action allows to download a list of participants in CSV, JSON or Excel. The fields included in the export are the Decidim User attributes plus the extra fields enabled in the admin panel. -![User export](https://github.com/PopulateTools/decidim-module-extra_user_fields/blob/extra-fields-0-27/docs/resources/extra_user_fields_export.png) +![User export](docs/resources/extra_user_fields_export.png) + + +## Configuration + +By default, the module is configured to read the configuration from ENV variables. + +Currently, the following ENV variables are supported: + +| ENV variable | Description | Default value | +| ------------ | ----------- |-------| +| EXTRA_USER_FIELDS_UNDERAGE_LIMIT | The minimum age limit to consider a user as underage. This is used to determine if the user falls into the underage category. | `18` | +| EXTRA_USER_FIELDS_UNDERAGE_OPTIONS | Options for selecting the age for when someone is considered "underage". | `15 16 17 18 19 20 21` | +| EXTRA_USER_FIELDS_GENDERS | Options for the gender field (you need to add the corresponding I18n keys, ie: `decidim.extra_user_fields.genders.prefer_not_to_say` ) | `female male other prefer_not_to_say` | +| EXTRA_USER_FIELDS_AGE_RANGES | Options for the age range field (you need to add the corresponding I18n keys, e.g., `decidim.extra_user_fields.age_ranges.up_to_16`) | `up_to_16 17_to_30 31_to_60 61_or_more prefer_not_to_say` | + +### Configuration through an initializer + +It is also possible to configure the module using the an initializer: + +Create an initializer (for instance `config/initializers/extra_user_fields.rb`) and configure the following: + +```ruby +# config/initializers/extra_user_fields.rb + +Decidim::ExtraUserFields.configure do |config| + config.genders = [:female, :male, :other, :prefer_not_to_say] + config.age_ranges = ["30_or_younger", "31_or_older", "prefer_not_to_say"] + + ... +end +``` ## Contributing diff --git a/app/commands/concerns/decidim/extra_user_fields/create_registrations_commands_overrides.rb b/app/commands/concerns/decidim/extra_user_fields/create_registrations_commands_overrides.rb index dd93ac9..a45eb1b 100644 --- a/app/commands/concerns/decidim/extra_user_fields/create_registrations_commands_overrides.rb +++ b/app/commands/concerns/decidim/extra_user_fields/create_registrations_commands_overrides.rb @@ -50,6 +50,7 @@ def extended_data postal_code: form.postal_code, date_of_birth: form.date_of_birth, gender: form.gender, + age_range: form.age_range, phone_number: form.phone_number, location: form.location, underage: form.underage, diff --git a/app/commands/concerns/decidim/extra_user_fields/omniauth_commands_overrides.rb b/app/commands/concerns/decidim/extra_user_fields/omniauth_commands_overrides.rb index 1cfe973..d72de5d 100644 --- a/app/commands/concerns/decidim/extra_user_fields/omniauth_commands_overrides.rb +++ b/app/commands/concerns/decidim/extra_user_fields/omniauth_commands_overrides.rb @@ -77,6 +77,7 @@ def extended_data postal_code: form.postal_code, date_of_birth: form.date_of_birth, gender: form.gender, + age_range: form.age_range, phone_number: form.phone_number, location: form.location, underage: form.underage, diff --git a/app/commands/concerns/decidim/extra_user_fields/update_account_commands_overrides.rb b/app/commands/concerns/decidim/extra_user_fields/update_account_commands_overrides.rb index 41989f6..de11641 100644 --- a/app/commands/concerns/decidim/extra_user_fields/update_account_commands_overrides.rb +++ b/app/commands/concerns/decidim/extra_user_fields/update_account_commands_overrides.rb @@ -26,6 +26,7 @@ def extended_data postal_code: @form.postal_code, date_of_birth: @form.date_of_birth, gender: @form.gender, + age_range: @form.age_range, phone_number: @form.phone_number, location: @form.location, underage: @form.underage, diff --git a/app/commands/decidim/extra_user_fields/admin/update_extra_user_fields.rb b/app/commands/decidim/extra_user_fields/admin/update_extra_user_fields.rb index d2e7443..3492784 100644 --- a/app/commands/decidim/extra_user_fields/admin/update_extra_user_fields.rb +++ b/app/commands/decidim/extra_user_fields/admin/update_extra_user_fields.rb @@ -39,6 +39,7 @@ def update_extra_user_fields! end # rubocop:disable Metrics/CyclomaticComplexity + # rubocop:disable Metrics/PerceivedComplexity def extra_user_fields { "enabled" => form.enabled.presence || false, @@ -46,6 +47,7 @@ def extra_user_fields "country" => { "enabled" => form.country.presence || false }, "postal_code" => { "enabled" => form.postal_code.presence || false }, "gender" => { "enabled" => form.gender.presence || false }, + "age_range" => { "enabled" => form.age_range.presence || false }, "phone_number" => { "enabled" => form.phone_number.presence || false, "pattern" => form.phone_number_pattern.presence, @@ -53,13 +55,11 @@ def extra_user_fields }, "location" => { "enabled" => form.location.presence || false }, "underage" => { "enabled" => form.underage || false }, - "underage_limit" => form.underage_limit || Decidim::ExtraUserFields::Engine::DEFAULT_UNDERAGE_LIMIT - # Block ExtraUserFields SaveFieldInConfig - - # EndBlock + "underage_limit" => form.underage_limit || Decidim::ExtraUserFields.underage_limit } end # rubocop:enable Metrics/CyclomaticComplexity + # rubocop:enable Metrics/PerceivedComplexity end end end diff --git a/app/controllers/decidim/extra_user_fields/admin/extra_user_fields_controller.rb b/app/controllers/decidim/extra_user_fields/admin/extra_user_fields_controller.rb index 2216a53..76d66ff 100644 --- a/app/controllers/decidim/extra_user_fields/admin/extra_user_fields_controller.rb +++ b/app/controllers/decidim/extra_user_fields/admin/extra_user_fields_controller.rb @@ -25,7 +25,7 @@ def update UpdateExtraUserFields.call(@form) do on(:ok) do flash[:notice] = t(".success") - render action: "index" + redirect_to root_path end on(:invalid) do diff --git a/app/forms/concerns/decidim/extra_user_fields/forms_definitions.rb b/app/forms/concerns/decidim/extra_user_fields/forms_definitions.rb index d35b8bb..64f6c54 100644 --- a/app/forms/concerns/decidim/extra_user_fields/forms_definitions.rb +++ b/app/forms/concerns/decidim/extra_user_fields/forms_definitions.rb @@ -17,6 +17,7 @@ module FormsDefinitions attribute :postal_code, String attribute :date_of_birth, Decidim::Attributes::LocalizedDate attribute :gender, String + attribute :age_range, String attribute :phone_number, String attribute :location, String attribute :underage, ActiveRecord::Type::Boolean @@ -29,7 +30,8 @@ module FormsDefinitions validates :country, presence: true, if: :country? validates :postal_code, presence: true, if: :postal_code? validates :date_of_birth, presence: true, if: :date_of_birth? - validates :gender, presence: true, inclusion: { in: Decidim::ExtraUserFields::Engine::DEFAULT_GENDER_OPTIONS.map(&:to_s) }, if: :gender? + validates :gender, presence: true, inclusion: { in: Decidim::ExtraUserFields.genders.map(&:to_s) }, if: :gender? + validates :age_range, presence: true, inclusion: { in: Decidim::ExtraUserFields.age_ranges.map(&:to_s) }, if: :age_range? validates :phone_number, presence: true, if: :phone_number? validates( :phone_number, @@ -55,6 +57,7 @@ def map_model(model) self.postal_code = extended_data[:postal_code] self.date_of_birth = Date.parse(extended_data[:date_of_birth]) if extended_data[:date_of_birth].present? self.gender = extended_data[:gender] + self.age_range = extended_data[:age_range] self.phone_number = extended_data[:phone_number] self.location = extended_data[:location] self.underage = extended_data[:underage] @@ -80,6 +83,10 @@ def gender? extra_user_fields_enabled && current_organization.activated_extra_field?(:gender) end + def age_range? + extra_user_fields_enabled && current_organization.activated_extra_field?(:age_range) + end + def postal_code? extra_user_fields_enabled && current_organization.activated_extra_field?(:postal_code) end diff --git a/app/forms/decidim/extra_user_fields/admin/extra_user_fields_form.rb b/app/forms/decidim/extra_user_fields/admin/extra_user_fields_form.rb index 5354b5c..7e10f28 100644 --- a/app/forms/decidim/extra_user_fields/admin/extra_user_fields_form.rb +++ b/app/forms/decidim/extra_user_fields/admin/extra_user_fields_form.rb @@ -11,6 +11,7 @@ class ExtraUserFieldsForm < Decidim::Form attribute :postal_code, Boolean attribute :date_of_birth, Boolean attribute :gender, Boolean + attribute :age_range, Boolean attribute :phone_number, Boolean attribute :location, Boolean attribute :underage, Boolean @@ -28,10 +29,11 @@ def map_model(model) self.postal_code = model.extra_user_fields.dig("postal_code", "enabled") self.date_of_birth = model.extra_user_fields.dig("date_of_birth", "enabled") self.gender = model.extra_user_fields.dig("gender", "enabled") + self.age_range = model.extra_user_fields.dig("age_range", "enabled") self.phone_number = model.extra_user_fields.dig("phone_number", "enabled") self.location = model.extra_user_fields.dig("location", "enabled") self.underage = model.extra_user_fields.dig("underage", "enabled") - self.underage_limit = model.extra_user_fields.fetch("underage_limit", Decidim::ExtraUserFields::Engine::DEFAULT_UNDERAGE_LIMIT) + self.underage_limit = model.extra_user_fields.fetch("underage_limit", Decidim::ExtraUserFields.underage_limit) self.phone_number_pattern = model.extra_user_fields.dig("phone_number", "pattern") self.phone_number_placeholder = model.extra_user_fields.dig("phone_number", "placeholder") # Block ExtraUserFields MapModel diff --git a/app/helpers/decidim/extra_user_fields/application_helper.rb b/app/helpers/decidim/extra_user_fields/application_helper.rb index edad20d..78253d8 100644 --- a/app/helpers/decidim/extra_user_fields/application_helper.rb +++ b/app/helpers/decidim/extra_user_fields/application_helper.rb @@ -6,11 +6,17 @@ module ExtraUserFields # module ApplicationHelper def gender_options_for_select - Decidim::ExtraUserFields::Engine::DEFAULT_GENDER_OPTIONS.map do |gender| + Decidim::ExtraUserFields.genders.map do |gender| [gender, I18n.t(gender, scope: "decidim.extra_user_fields.genders")] end end + def age_range_options_for_select + Decidim::ExtraUserFields.age_ranges.map do |age_range| + [age_range, I18n.t(age_range, scope: "decidim.extra_user_fields.age_ranges")] + end + end + def phone_number_extra_user_field_pattern current_organization.extra_user_field_configuration(:phone_number)["pattern"] end diff --git a/app/serializers/decidim/extra_user_fields/user_export_serializer.rb b/app/serializers/decidim/extra_user_fields/user_export_serializer.rb index 848d24c..8ff9a75 100644 --- a/app/serializers/decidim/extra_user_fields/user_export_serializer.rb +++ b/app/serializers/decidim/extra_user_fields/user_export_serializer.rb @@ -13,7 +13,7 @@ def serialize def extra_user_fields extended_data = resource.extended_data.symbolize_keys - [:gender, :country, :postal_code, :date_of_birth, :phone_number, :location, :underage, :statutory_representative_email].index_with do |key| + [:gender, :age_range, :country, :postal_code, :date_of_birth, :phone_number, :location, :underage, :statutory_representative_email].index_with do |key| extended_data[key] end end @@ -29,6 +29,7 @@ def blocking_data def extra_fields [ :gender, + :age_range, :country, :postal_code, :date_of_birth, diff --git a/app/views/decidim/extra_user_fields/_profile_form.html.erb b/app/views/decidim/extra_user_fields/_profile_form.html.erb index e9d6218..9f20e9c 100644 --- a/app/views/decidim/extra_user_fields/_profile_form.html.erb +++ b/app/views/decidim/extra_user_fields/_profile_form.html.erb @@ -7,6 +7,10 @@ <%= f.collection_select :gender, f.object.gender_options_for_select, :first, :last %> <% end %> + <% if current_organization.activated_extra_field?(:age_range) %> + <%= f.collection_select :age_range, f.object.age_range_options_for_select, :first, :last %> + <% end %> + <% if current_organization.activated_extra_field?(:country) %> <%= f.label :country do %> <%= f.custom_country_select :country %> diff --git a/app/views/decidim/extra_user_fields/_registration_form.html.erb b/app/views/decidim/extra_user_fields/_registration_form.html.erb index c03d28c..f43b5eb 100644 --- a/app/views/decidim/extra_user_fields/_registration_form.html.erb +++ b/app/views/decidim/extra_user_fields/_registration_form.html.erb @@ -10,6 +10,10 @@ <%= f.collection_select :gender, f.object.gender_options_for_select, :first, :last %> <% end %> + <% if current_organization.activated_extra_field?(:age_range) %> + <%= f.collection_select :age_range, f.object.age_range_options_for_select, :first, :last %> + <% end %> + <% if current_organization.activated_extra_field?(:country) %> <%= f.label :country do %> <%= f.custom_country_select :country %> diff --git a/app/views/decidim/extra_user_fields/admin/extra_user_fields/_form.html.erb b/app/views/decidim/extra_user_fields/admin/extra_user_fields/_form.html.erb index dc61bb0..64d1ea7 100644 --- a/app/views/decidim/extra_user_fields/admin/extra_user_fields/_form.html.erb +++ b/app/views/decidim/extra_user_fields/admin/extra_user_fields/_form.html.erb @@ -29,6 +29,7 @@ <%= render partial: "decidim/extra_user_fields/admin/extra_user_fields/fields/country", locals: { form: form } %> <%= render partial: "decidim/extra_user_fields/admin/extra_user_fields/fields/postal_code", locals: { form: form } %> <%= render partial: "decidim/extra_user_fields/admin/extra_user_fields/fields/gender", locals: { form: form } %> + <%= render partial: "decidim/extra_user_fields/admin/extra_user_fields/fields/age_range", locals: { form: form } %> <%= render partial: "decidim/extra_user_fields/admin/extra_user_fields/fields/phone_number", locals: { form: form } %> <%= render partial: "decidim/extra_user_fields/admin/extra_user_fields/fields/location", locals: { form: form } %> <%= render partial: "decidim/extra_user_fields/admin/extra_user_fields/fields/underage", locals: { form: form } %> diff --git a/app/views/decidim/extra_user_fields/admin/extra_user_fields/fields/_age_range.html.erb b/app/views/decidim/extra_user_fields/admin/extra_user_fields/fields/_age_range.html.erb new file mode 100644 index 0000000..59ecb9b --- /dev/null +++ b/app/views/decidim/extra_user_fields/admin/extra_user_fields/fields/_age_range.html.erb @@ -0,0 +1,5 @@ +
+
+ <%= form.check_box :age_range, label: t(".label"), help_text: t(".description") %> +
+
diff --git a/app/views/decidim/extra_user_fields/admin/extra_user_fields/fields/_underage.html.erb b/app/views/decidim/extra_user_fields/admin/extra_user_fields/fields/_underage.html.erb index 2713630..0f23eb8 100644 --- a/app/views/decidim/extra_user_fields/admin/extra_user_fields/fields/_underage.html.erb +++ b/app/views/decidim/extra_user_fields/admin/extra_user_fields/fields/_underage.html.erb @@ -2,6 +2,6 @@

<%= t(".description") %>

<%= form.check_box :underage, label: t(".label") %> - <%= form.select :underage_limit, ( Decidim::ExtraUserFields::Engine::DEFAULT_UNDERAGE_OPTIONS).to_a, selected: current_organization.extra_user_fields["underage_limit"] || Decidim::ExtraUserFields::Engine::DEFAULT_UNDERAGE_LIMIT, label: t(".limit") %> + <%= form.select :underage_limit, ( Decidim::ExtraUserFields.underage_options).to_a, selected: current_organization.extra_user_fields["underage_limit"] || Decidim::ExtraUserFields.underage_limit, label: t(".limit") %>
diff --git a/config/i18n-tasks.yml b/config/i18n-tasks.yml index aa01e24..d31a358 100644 --- a/config/i18n-tasks.yml +++ b/config/i18n-tasks.yml @@ -9,6 +9,7 @@ ignore_unused: - activemodel.errors.models.user.* - decidim.admin.extra_user_fields.menu.title - decidim.extra_user_fields.genders.* + - decidim.extra_user_fields.age_ranges.* ignore_missing: - decidim.participatory_processes.scopes.global diff --git a/config/locales/ca.yml b/config/locales/ca.yml index 3e2a517..3686b2c 100644 --- a/config/locales/ca.yml +++ b/config/locales/ca.yml @@ -3,9 +3,10 @@ ca: activemodel: attributes: user: + age_range: Quina edat tens? country: País date_of_birth: Data de naixement - gender: Gènere + gender: Quin gènere identifiques? location: Localització phone_number: Telèfon postal_code: Codi postal @@ -36,6 +37,10 @@ ca: users: Participants extra_user_fields: fields: + age_range: + description: Aquest camp és una llista de rangs d'edat. Si está activat, + l'usuari haurà de triar un rang d'edat. + label: Habilitar camp de rang d'edat country: description: Aquest camp és una llista de països. Si está activat, l'usuari haurà de triar un país. @@ -89,10 +94,17 @@ ca: update: failure: S'ha produït un error en l'actualització success: Camps d'usuari addicionals actualitzats correctament a l'organització + age_ranges: + 17_to_30: De 17 a 30 + 31_to_60: De 31 a 60 + 61_or_more: 61 o més + prefer_not_to_say: Prefereixo no dir-ho + up_to_16: 16 o menys genders: female: Dona male: Home other: Altre + prefer_not_to_say: Prefereixo no dir-ho registration_form: signup: legend: Més informació diff --git a/config/locales/de.yml b/config/locales/de.yml index 50d9c8d..f9f7066 100644 --- a/config/locales/de.yml +++ b/config/locales/de.yml @@ -3,9 +3,10 @@ de: activemodel: attributes: user: + age_range: Wie alt sind Sie? country: Land date_of_birth: Geburtsdatum - gender: Geschlecht + gender: Welches Geschlecht identifizieren Sie? location: Standort phone_number: Telefonnummer postal_code: Postleitzahl @@ -14,7 +15,8 @@ de: user: attributes: date_of_birth: - underage: ungültig. Wenn Sie minderjährig sind, müssen Sie die Erlaubnis der Eltern einholen + underage: ungültig. Wenn Sie minderjährig sind, müssen Sie die Erlaubnis + der Eltern einholen decidim: admin: actions: @@ -33,27 +35,40 @@ de: users: Teilnehmer extra_user_fields: fields: + age_range: + description: Dieses Feld ist eine Liste von Altersgruppen. Der Benutzer + kann eine Altersgruppe auswählen. + label: Das Feld Altersgruppe aktivieren country: - description: Dieses Feld enthält eine Liste von Ländern. Der Benutzer kann ein Land auswählen. + description: Dieses Feld enthält eine Liste von Ländern. Der Benutzer + kann ein Land auswählen. label: Das Feld Land aktivieren date_of_birth: - description: Dieses Feld ist ein Feld für das Geburtsdatum. Der Benutzer kann ein Datum auswählen. + description: Dieses Feld ist ein Feld für das Geburtsdatum. Der Benutzer + kann ein Datum auswählen. label: Das Feld Geburtsdatum aktivieren gender: - description: Dieses Feld ist ein Feld für die Geschlechtsidentität. Der Benutzer kann ein Geschlecht auswählen. + description: Dieses Feld ist ein Feld für die Geschlechtsidentität. + Der Benutzer kann ein Geschlecht auswählen. label: Das Feld Geschlecht aktivieren location: - description: Dieses Feld ermöglicht das Hinzufügen von Text. Der Benutzer kann einen Ort auswählen. + description: Dieses Feld ermöglicht das Hinzufügen von Text. Der Benutzer + kann einen Ort auswählen. label: Das Feld Standort aktivieren phone_number: - description: Dieses Feld ist ein Telefonnummernfeld. Der Benutzer kann eine Nummer auswählen. + description: Dieses Feld ist ein Telefonnummernfeld. Der Benutzer kann + eine Nummer auswählen. label: Das Feld Telefonnummer aktivieren postal_code: - description: Dieses Feld ist für die Postleitzahl. Der Benutzer kann eine Postleitzahl auswählen. + description: Dieses Feld ist für die Postleitzahl. Der Benutzer kann + eine Postleitzahl auswählen. label: Das Postleitzahlenfeld aktivieren. form: callout: - help: Aktivieren Sie die Funktion für benutzerdefinierte Anmeldefelder, um zusätzliche Felder in Ihrem Anmeldeformular zu verwalten. Auch bei aktivierter Option wird das Anmeldeformular nur aktualisiert, wenn mindestens ein zusätzliches Feld aktiviert ist. + help: Aktivieren Sie die Funktion für benutzerdefinierte Anmeldefelder, + um zusätzliche Felder in Ihrem Anmeldeformular zu verwalten. Auch + bei aktivierter Option wird das Anmeldeformular nur aktualisiert, + wenn mindestens ein zusätzliches Feld aktiviert ist. extra_user_fields: extra_user_fields_enabled: Benutzerdefinierte Anmeldefelder aktivieren section: Verfügbare Anmeldefelder für das Anmeldeformular @@ -65,10 +80,17 @@ de: update: failure: Bei der Aktualisierung ist ein Fehler aufgetreten. success: Die Anmeldefelder wurden erfolgreich aktualisiert. + age_ranges: + 17_to_30: 17 bis 30 + 31_to_60: 31 bis 60 + 61_or_more: 61 oder älter + prefer_not_to_say: Bevorzuge es, nicht zu sagen + up_to_16: 16 oder jünger genders: female: Frau male: Mann other: Divers + prefer_not_to_say: Bevorzuge es, nicht zu sagen registration_form: signup: legend: Weitere Informationen diff --git a/config/locales/en.yml b/config/locales/en.yml index af86e18..57f0bb5 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -3,9 +3,10 @@ en: activemodel: attributes: user: + age_range: How old are you? country: Country date_of_birth: Date of birth - gender: Gender + gender: Which gender do you identify with? location: Location phone_number: Phone Number postal_code: Postal code @@ -35,6 +36,10 @@ en: users: Participants extra_user_fields: fields: + age_range: + description: This field is a list of age ranges. If checked, user will + have to choose an age range + label: Enable age range field country: description: This field is a list of countries. If checked, user will have to choose a country @@ -86,10 +91,17 @@ en: update: failure: An error occurred on update success: Extra user fields correctly updated in organization + age_ranges: + 17_to_30: 17 to 30 + 31_to_60: 31 to 60 + 61_or_more: 61 or older + prefer_not_to_say: Prefer not to say + up_to_16: 16 or younger genders: female: Female male: Male other: Other + prefer_not_to_say: Prefer not to say registration_form: signup: legend: More information diff --git a/config/locales/es.yml b/config/locales/es.yml index 5df4c30..79836b9 100644 --- a/config/locales/es.yml +++ b/config/locales/es.yml @@ -3,9 +3,10 @@ es: activemodel: attributes: user: + age_range: Cuántos años tienes? country: País date_of_birth: Fecha de nacimiento - gender: Género + gender: Con qué género te identificas? location: Localización phone_number: Teléfono postal_code: Código postal @@ -36,6 +37,10 @@ es: users: Participantes extra_user_fields: fields: + age_range: + description: Este campo es una lista de rangos de edad. Si está marcado, + el usuario tendrá que elegir un rango de edad. + label: Habilitar campo de rango de edad country: description: Este campo es una lista de países. Si está marcado, el usuario tendrá que elegir un país. @@ -89,10 +94,17 @@ es: failure: Se ha producido un error en la actualización success: Campos de usuario adicionales actualizados correctamente en la organización + age_ranges: + 17_to_30: 17 a 30 + 31_to_60: 31 a 60 + 61_or_more: 61 o más + prefer_not_to_say: Prefiero no decirlo + up_to_16: 16 o menos genders: female: Mujer male: Hombre other: Otro + prefer_not_to_say: Prefiero no decirlo registration_form: signup: legend: Más información diff --git a/config/locales/eu.yml b/config/locales/eu.yml index 45d7d97..dcbe168 100644 --- a/config/locales/eu.yml +++ b/config/locales/eu.yml @@ -3,9 +3,10 @@ eu: activemodel: attributes: user: + age_range: Zenbat urte dituzu? country: Herria date_of_birth: Jaioteguna - gender: Generoa + gender: Zer generotako pertsona zara? location: Helbidea phone_number: Telefono zenbakia postal_code: Posta kodea @@ -27,27 +28,40 @@ eu: users: Parte-hartzaileak extra_user_fields: fields: + age_range: + description: Eremu hau adin tarte bat da. Erabiltzaileek adin tarte + bat aukeratu ahal izango dute. + label: Adin tartearen eremua aktibatu country: - description: Eremu hau herrien zerrenda bat da. Erabiltzaileek herri bat aukeratu ahal izango dute. + description: Eremu hau herrien zerrenda bat da. Erabiltzaileek herri + bat aukeratu ahal izango dute. label: Herriaren eremua aktibatu date_of_birth: - description: Eremu hau data bat da. Erabiltzaileak bere jaioteguna jarri ahal izango du data aukeratuz. + description: Eremu hau data bat da. Erabiltzaileak bere jaioteguna jarri + ahal izango du data aukeratuz. label: Jaiotegunaren eremua aktibatu gender: - description: Eremu hau generoen zerrenda bat da. Erabiltzaileak generoa aukeratu ahal izango du erregistroa egitean. + description: Eremu hau generoen zerrenda bat da. Erabiltzaileak generoa + aukeratu ahal izango du erregistroa egitean. label: Generoaren eremua aktibatu location: - description: Eremu hau testua da. Erabiltzaileak helbidea idatzi ahal izango du bertan. + description: Eremu hau testua da. Erabiltzaileak helbidea idatzi ahal + izango du bertan. label: Helbidearen eremua aktibatu phone_number: - description: Eremu hau testua da. Erabiltzaileak bere telefono zenbakia idatzi ahal izango du bertan. + description: Eremu hau testua da. Erabiltzaileak bere telefono zenbakia + idatzi ahal izango du bertan. label: Telefono zenbakiaren eremua aktibatu postal_code: - description: Eremu hau testua da. Erabiltzaileak bere posta kodea idatzi ahal izango du bertan. + description: Eremu hau testua da. Erabiltzaileak bere posta kodea idatzi + ahal izango du bertan. label: Posta kodearen eremua aktibatu form: callout: - help: Extra user fields-en funtzionaltasunak aktibatu. Honi esker erregistroa egiteko unean eremu gehigarriak agertuko dira. Gogoratu aukera hau aktibatuta ere, erregistroaren formularioan behean aktibatutako eremuak baino ez dituela gehituko. + help: Extra user fields-en funtzionaltasunak aktibatu. Honi esker erregistroa + egiteko unean eremu gehigarriak agertuko dira. Gogoratu aukera hau + aktibatuta ere, erregistroaren formularioan behean aktibatutako + eremuak baino ez dituela gehituko. extra_user_fields: extra_user_fields_enabled: Extra User Fields aktibatu section: Eregistroa egiteko formularioan erabilgarri dauden eremu gehigarriak. @@ -59,10 +73,17 @@ eu: update: failure: Erakundearen datuak eguneratzean errore bat sortu da success: Extra user fields zuzen eguneratu dira erakundean + age_ranges: + 17_to_30: 17tik 30era + 31_to_60: 31tik 60ra + 61_or_more: 61 edo gehiago + prefer_not_to_say: Ez esan nahi + up_to_16: 16 edo gutxiago genders: female: Emakumea male: Gizona other: Beste bat + prefer_not_to_say: Ez esan nahi registration_form: signup: legend: Argibide gehiago diff --git a/config/locales/fr.yml b/config/locales/fr.yml index fd9beea..a7a4793 100644 --- a/config/locales/fr.yml +++ b/config/locales/fr.yml @@ -3,9 +3,10 @@ fr: activemodel: attributes: user: + age_range: Quel âge avez-vous? country: Pays date_of_birth: Date de naissance - gender: Genre + gender: Quel genre identifiez-vous? location: Localisation phone_number: Numéro de téléphone postal_code: Code postal @@ -36,6 +37,10 @@ fr: users: Participants extra_user_fields: fields: + age_range: + description: Ce champ est une liste de tranches d'âge. L'utilisateur + pourra choisir une tranche d'âge. + label: Activer le champ tranche d'âge country: description: Ce champ contient une liste de pays. L'utilisateur pourra choisir un pays. @@ -88,10 +93,17 @@ fr: update: failure: Une erreur est survenue lors de la mise à jour success: Les champs d'inscription ont été mis à jour avec succ§s + age_ranges: + 17_to_30: 17 à 30 + 31_to_60: 31 à 60 + 61_or_more: 61 ou plus + prefer_not_to_say: Préfère ne pas dire + up_to_16: 16 ou moins genders: female: Femme male: Homme other: Autre + prefer_not_to_say: Préfère ne pas dire registration_form: signup: legend: Plus d'information diff --git a/lib/decidim/extra_user_fields.rb b/lib/decidim/extra_user_fields.rb index e21bce3..5d245b7 100644 --- a/lib/decidim/extra_user_fields.rb +++ b/lib/decidim/extra_user_fields.rb @@ -8,5 +8,30 @@ module Decidim # This namespace holds the logic of the `ExtraUserFields` module. module ExtraUserFields + include ActiveSupport::Configurable + + config_accessor :underage_limit do + ENV.fetch("EXTRA_USER_FIELDS_UNDERAGE_LIMIT", 18).to_i + end + + config_accessor :underage_options do + ENV.fetch("EXTRA_USER_FIELDS_UNDERAGE_OPTIONS", "15 16 17 18 19 20 21").split.map(&:to_i) + end + + # These options require the I18n translations to be set in the locale files. + # decidim.extra_user_fields.genders.female + # decidim.extra_user_fields.genders.male + # decidim.extra_user_fields.genders. ... + config_accessor :genders do + ENV.fetch("EXTRA_USER_FIELDS_GENDERS", "female male other prefer_not_to_say").split + end + + # These options require the I18n translations to be set in the locale files. + # decidim.extra_user_fields.age_range.up_to_16 + # decidim.extra_user_fields.age_range.17_to_30 + # decidim.extra_user_fields.age_range. ... + config_accessor :age_ranges do + ENV.fetch("EXTRA_USER_FIELDS_AGE_RANGES", "up_to_16 17_to_30 31_to_60 61_or_more prefer_not_to_say").split + end end end diff --git a/lib/decidim/extra_user_fields/engine.rb b/lib/decidim/extra_user_fields/engine.rb index e6a1cb6..7894dc7 100644 --- a/lib/decidim/extra_user_fields/engine.rb +++ b/lib/decidim/extra_user_fields/engine.rb @@ -11,12 +11,6 @@ module ExtraUserFields class Engine < ::Rails::Engine isolate_namespace Decidim::ExtraUserFields - DEFAULT_GENDER_OPTIONS = [:male, :female, :other].freeze - - DEFAULT_UNDERAGE_LIMIT = 18 - - DEFAULT_UNDERAGE_OPTIONS = (15..21) - routes do # Add engine routes here # resources :extra_user_fields diff --git a/lib/tasks/decidim_extra_user_fields_upgrade_tasks.rake b/lib/tasks/decidim_extra_user_fields_upgrade_tasks.rake new file mode 100644 index 0000000..5fdb868 --- /dev/null +++ b/lib/tasks/decidim_extra_user_fields_upgrade_tasks.rake @@ -0,0 +1,5 @@ +# frozen_string_literal: true + +Rake::Task["decidim:choose_target_plugins"].enhance do + ENV["FROM"] = "#{ENV.fetch("FROM", nil)},decidim_extra_user_fields" +end diff --git a/spec/commands/decidim/create_omniauth_registration_spec.rb b/spec/commands/decidim/create_omniauth_registration_spec.rb index a87436a..2d169ff 100644 --- a/spec/commands/decidim/create_omniauth_registration_spec.rb +++ b/spec/commands/decidim/create_omniauth_registration_spec.rb @@ -15,6 +15,7 @@ module Comments let(:country) { "Argentina" } let(:date_of_birth) { "01/01/2000" } let(:gender) { "other" } + let(:age_range) { "17_to_30" } let(:location) { "Paris" } let(:phone_number) { "0123456789" } let(:postal_code) { "75001" } @@ -25,6 +26,7 @@ module Comments country:, date_of_birth:, gender:, + age_range:, location:, phone_number:, postal_code:, @@ -48,6 +50,7 @@ module Comments "postal_code" => postal_code, "date_of_birth" => date_of_birth, "gender" => gender, + "age_range" => age_range, "phone_number" => phone_number, "location" => location, "underage" => underage, diff --git a/spec/commands/decidim/create_registration_spec.rb b/spec/commands/decidim/create_registration_spec.rb index 080fde6..6f7859f 100644 --- a/spec/commands/decidim/create_registration_spec.rb +++ b/spec/commands/decidim/create_registration_spec.rb @@ -18,6 +18,7 @@ module Comments let(:country) { "Argentina" } let(:date_of_birth) { "01/01/2000" } let(:gender) { "other" } + let(:age_range) { "17_to_30" } let(:location) { "Paris" } let(:phone_number) { "0123456789" } let(:postal_code) { "75001" } @@ -49,6 +50,7 @@ module Comments "postal_code" => postal_code, "date_of_birth" => date_of_birth, "gender" => gender, + "age_range" => age_range, "phone_number" => phone_number, "location" => location, "underage" => underage, @@ -122,6 +124,7 @@ module Comments country:, date_of_birth: Date.parse(date_of_birth), gender:, + age_range:, location:, phone_number:, postal_code:, diff --git a/spec/commands/decidim/extra_user_fields/admin/update_extra_user_fields_spec.rb b/spec/commands/decidim/extra_user_fields/admin/update_extra_user_fields_spec.rb index 3631000..cfbd60e 100644 --- a/spec/commands/decidim/extra_user_fields/admin/update_extra_user_fields_spec.rb +++ b/spec/commands/decidim/extra_user_fields/admin/update_extra_user_fields_spec.rb @@ -9,10 +9,11 @@ module Admin let(:organization) { create(:organization, extra_user_fields: {}) } let(:user) { create(:user, :admin, :confirmed, organization:) } - let(:extra_user_fields_enabled) { true } let(:postal_code) { true } + let(:extra_user_fields_enabled) { true } let(:country) { true } let(:gender) { true } + let(:age_range) { true } let(:date_of_birth) { true } let(:phone_number) { true } let(:phone_number_pattern) { "^(\\+34)?[0-9 ]{9,12}$" } @@ -27,10 +28,11 @@ module Admin # rubocop:disable Style/TrailingCommaInHashLiteral let(:form_params) do { - "enabled" => extra_user_fields_enabled, "postal_code" => postal_code, + "enabled" => extra_user_fields_enabled, "country" => country, "gender" => gender, + "age_range" => age_range, "date_of_birth" => date_of_birth, "phone_number" => phone_number, "phone_number_pattern" => phone_number_pattern, @@ -86,7 +88,9 @@ module Admin expect(extra_user_fields).to include("enabled" => true) expect(extra_user_fields).to include("country" => { "enabled" => true }) expect(extra_user_fields).to include("date_of_birth" => { "enabled" => true }) + expect(extra_user_fields).to include("postal_code" => { "enabled" => true }) expect(extra_user_fields).to include("gender" => { "enabled" => true }) + expect(extra_user_fields).to include("age_range" => { "enabled" => true }) expect(extra_user_fields).to include("country" => { "enabled" => true }) expect(extra_user_fields).to include("phone_number" => { "enabled" => true, "pattern" => phone_number_pattern, "placeholder" => phone_number_placeholder }) expect(extra_user_fields).to include("location" => { "enabled" => true }) diff --git a/spec/forms/decidim/account_form_spec.rb b/spec/forms/decidim/account_form_spec.rb index ad76c2d..ab9cd51 100644 --- a/spec/forms/decidim/account_form_spec.rb +++ b/spec/forms/decidim/account_form_spec.rb @@ -62,6 +62,7 @@ module Decidim let(:country) { "Argentina" } let(:date_of_birth) { "01/01/2000" } let(:gender) { "other" } + let(:age_range) { "17_to_30" } let(:location) { "Paris" } let(:phone_number) { "0123456789" } let(:postal_code) { "75001" } diff --git a/spec/forms/decidim/omniauth_registration_form_spec.rb b/spec/forms/decidim/omniauth_registration_form_spec.rb index 3b25b82..a09acd1 100644 --- a/spec/forms/decidim/omniauth_registration_form_spec.rb +++ b/spec/forms/decidim/omniauth_registration_form_spec.rb @@ -21,6 +21,7 @@ module Decidim let(:country) { "Argentina" } let(:date_of_birth) { "01/01/2000" } let(:gender) { "other" } + let(:age_range) { "17_to_30" } let(:location) { "Paris" } let(:phone_number) { "0123456789" } let(:postal_code) { "75001" } @@ -38,6 +39,7 @@ module Decidim postal_code:, date_of_birth:, gender:, + age_range:, phone_number:, location: } diff --git a/spec/forms/decidim/registration_form_spec.rb b/spec/forms/decidim/registration_form_spec.rb index b04f8f3..68f0484 100644 --- a/spec/forms/decidim/registration_form_spec.rb +++ b/spec/forms/decidim/registration_form_spec.rb @@ -22,6 +22,7 @@ module Decidim "postal_code" => { "enabled" => true }, "date_of_birth" => { "enabled" => true }, "gender" => { "enabled" => true }, + "age_range" => { "enabled" => true }, "phone_number" => { "enabled" => true, "pattern" => phone_number_pattern, "placeholder" => nil }, "location" => { "enabled" => true } } @@ -35,6 +36,7 @@ module Decidim let(:country) { "Argentina" } let(:date_of_birth) { "01/01/2000" } let(:gender) { "other" } + let(:age_range) { "17_to_30" } let(:location) { "Paris" } let(:phone_number) { "0123456789" } let(:postal_code) { "75001" } @@ -50,6 +52,7 @@ module Decidim postal_code:, date_of_birth:, gender:, + age_range:, phone_number:, location: } diff --git a/spec/serializers/decidim/extra_user_fields/user_export_serializer_spec.rb b/spec/serializers/decidim/extra_user_fields/user_export_serializer_spec.rb index 6d4d12c..1403850 100644 --- a/spec/serializers/decidim/extra_user_fields/user_export_serializer_spec.rb +++ b/spec/serializers/decidim/extra_user_fields/user_export_serializer_spec.rb @@ -10,6 +10,7 @@ let(:registration_metadata) do { gender:, + age_range:, postal_code:, date_of_birth:, country:, @@ -25,6 +26,7 @@ # rubocop:enable Style/TrailingCommaInHashLiteral let(:gender) { "other" } + let(:age_range) { "17_to_30" } let(:postal_code) { "00000" } let(:date_of_birth) { "01/01/2000" } let(:country) { "Argentina" } @@ -47,6 +49,10 @@ expect(serialized).to include(gender: resource.extended_data["gender"]) end + it "includes the age range" do + expect(serialized).to include(age_range: resource.extended_data["age_range"]) + end + it "includes the postal code" do expect(serialized).to include(postal_code: resource.extended_data["postal_code"]) end diff --git a/spec/system/account_spec.rb b/spec/system/account_spec.rb index 94f4e08..b286f3e 100644 --- a/spec/system/account_spec.rb +++ b/spec/system/account_spec.rb @@ -19,6 +19,7 @@ "date_of_birth" => date_of_birth, "postal_code" => postal_code, "gender" => gender, + "age_range" => age_range, "country" => country, "phone_number" => phone_number, "location" => location, @@ -45,6 +46,10 @@ { "enabled" => true } end + let(:age_range) do + { "enabled" => true } + end + let(:phone_number) do { "enabled" => true, "pattern" => phone_number_pattern, "placeholder" => nil } end @@ -104,6 +109,7 @@ fill_in :user_date_of_birth_date, with: "01/01/2000" select "Other", from: :user_gender + select "17 to 30", from: :user_age_range select "Argentina", from: :user_country fill_in :user_postal_code, with: "00000" fill_in :user_phone_number, with: "0123456789" @@ -208,6 +214,14 @@ it_behaves_like "does not display extra user field", "gender", "Gender" end + context "when age_range is not enabled" do + let(:age_range) do + { "enabled" => false } + end + + it_behaves_like "does not display extra user field", "age_range", "Age range" + end + context "when phone number is not enabled" do let(:phone_number) do { "enabled" => false } @@ -234,6 +248,7 @@ fill_in :user_date_of_birth_date, with: "01/01/2000" select "Other", from: :user_gender + select "17 to 30", from: :user_age_range select "Argentina", from: :user_country fill_in :user_postal_code, with: "00000" fill_in :user_phone_number, with: "0123456789" @@ -294,6 +309,7 @@ fill_in :user_date_of_birth_date, with: "01/01/2000" select "Other", from: :user_gender + select "17 to 30", from: :user_age_range select "Argentina", from: :user_country fill_in :user_postal_code, with: "00000" fill_in :user_phone_number, with: "0123456789" diff --git a/spec/system/registration_spec.rb b/spec/system/registration_spec.rb index 317aab3..d9e083f 100644 --- a/spec/system/registration_spec.rb +++ b/spec/system/registration_spec.rb @@ -13,6 +13,7 @@ def fill_registration_form def fill_extra_user_fields fill_in :registration_user_date_of_birth_date, with: "01/01/2000" select "Other", from: :registration_user_gender + select "17 to 30", from: :registration_user_age_range select "Argentina", from: :registration_user_country fill_in :registration_user_postal_code, with: "00000" fill_in :registration_user_phone_number, with: "0123456789" @@ -41,6 +42,7 @@ def fill_extra_user_fields "date_of_birth" => date_of_birth, "postal_code" => postal_code, "gender" => gender, + "age_range" => age_range, "country" => country, "phone_number" => phone_number, "location" => location, @@ -65,6 +67,10 @@ def fill_extra_user_fields { "enabled" => true } end + let(:age_range) do + { "enabled" => true } + end + let(:phone_number) do { "enabled" => true, "pattern" => phone_number_pattern, "placeholder" => nil } end @@ -86,7 +92,7 @@ def fill_extra_user_fields it "contains extra user fields" do within "#card__extra_user_fields" do expect(page).to have_content("Date of birth") - expect(page).to have_content("Gender") + expect(page).to have_content("Which gender do you identify with?") expect(page).to have_content("Country") expect(page).to have_content("Postal code") expect(page).to have_content("Phone Number") @@ -143,6 +149,7 @@ def fill_extra_user_fields it_behaves_like "mandatory extra user fields", "date_of_birth" it_behaves_like "mandatory extra user fields", "gender" + it_behaves_like "mandatory extra user fields", "age_range" it_behaves_like "mandatory extra user fields", "country" it_behaves_like "mandatory extra user fields", "postal_code" it_behaves_like "mandatory extra user fields", "phone_number" @@ -156,7 +163,8 @@ def fill_extra_user_fields it "does not contain extra user fields" do expect(page).to have_no_content("Date of birth") - expect(page).to have_no_content("Gender") + expect(page).to have_no_content("Which gender do you identify with?") + expect(page).to have_no_content("How old are you?") expect(page).to have_no_content("Country") expect(page).to have_no_content("Postal code") expect(page).to have_no_content("Phone Number") From 260a632a15500a475376a92e1c4753b72b50ccf1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ivan=20Verg=C3=A9s?= Date: Mon, 12 May 2025 12:48:27 +0200 Subject: [PATCH 05/10] add custom select fields (#4) * add custom select fields * specs * erb lint * specfix * fix specs * readme --- .gitignore | 3 ++ README.md | 34 +++++++++++++++ ...create_registrations_commands_overrides.rb | 1 + .../omniauth_commands_overrides.rb | 1 + .../update_account_commands_overrides.rb | 1 + .../admin/update_extra_user_fields.rb | 3 +- .../extra_user_fields/forms_definitions.rb | 26 +++++++++-- .../admin/extra_user_fields_form.rb | 11 +++-- .../admin/application_helper.rb | 8 ++++ .../extra_user_fields/application_helper.rb | 16 +++++++ .../organization_overrides.rb | 29 +++++++++---- .../user_export_serializer.rb | 6 +-- .../extra_user_fields/_profile_form.html.erb | 4 ++ .../_registration_form.html.erb | 7 +-- .../extra_user_fields/_select_fields.html.erb | 14 ++++++ .../admin/extra_user_fields/_form.html.erb | 7 +++ .../fields/_select_fields.html.erb | 15 +++++++ bin/rails | 14 +----- bin/shakapacker | 6 +++ bin/shakapacker-dev-server | 6 +++ config/locales/en.yml | 15 +++++++ config/locales/fr.yml | 14 ++++++ lib/decidim/extra_user_fields.rb | 19 ++++++++ .../create_omniauth_registration_spec.rb | 17 ++++++++ .../decidim/create_registration_spec.rb | 8 ++++ .../admin/update_extra_user_fields_spec.rb | 14 +----- spec/forms/decidim/account_form_spec.rb | 35 ++++++++++++++- .../omniauth_registration_form_spec.rb | 10 ++++- .../user_export_serializer_spec.rb | 19 ++++---- spec/system/account_spec.rb | 30 +++++++++---- ...ges_organization_extra_user_fields_spec.rb | 43 +++++++++++++++++++ spec/system/registration_spec.rb | 28 +++++------- 32 files changed, 380 insertions(+), 84 deletions(-) create mode 100644 app/views/decidim/extra_user_fields/_select_fields.html.erb create mode 100644 app/views/decidim/extra_user_fields/admin/extra_user_fields/fields/_select_fields.html.erb create mode 100755 bin/shakapacker create mode 100755 bin/shakapacker-dev-server diff --git a/.gitignore b/.gitignore index c8b0927..4c126b1 100644 --- a/.gitignore +++ b/.gitignore @@ -16,3 +16,6 @@ spec/decidim_dummy_app # default development application development_app .rubocop-https*-yml +.byebug_history +.rbenv-vars +.env \ No newline at end of file diff --git a/README.md b/README.md index 4bd671e..61e4ac1 100644 --- a/README.md +++ b/README.md @@ -96,6 +96,16 @@ Currently, the following ENV variables are supported: | EXTRA_USER_FIELDS_GENDERS | Options for the gender field (you need to add the corresponding I18n keys, ie: `decidim.extra_user_fields.genders.prefer_not_to_say` ) | `female male other prefer_not_to_say` | | EXTRA_USER_FIELDS_AGE_RANGES | Options for the age range field (you need to add the corresponding I18n keys, e.g., `decidim.extra_user_fields.age_ranges.up_to_16`) | `up_to_16 17_to_30 31_to_60 61_or_more prefer_not_to_say` | +## Custom fields + +If your use case include fields not defined in this module, it is possible to define custom fields of different types: + +1. **Select fields** This configuration option allows you to define any number of extra user fields of the type "Select". + + +See the next section "Configuration through an initializer" for more information. + + ### Configuration through an initializer It is also possible to configure the module using the an initializer: @@ -110,6 +120,30 @@ Decidim::ExtraUserFields.configure do |config| config.age_ranges = ["30_or_younger", "31_or_older", "prefer_not_to_say"] ... + + + # I extra select fields are needed, they can be added here. + # The key is the field name and the value is a hash with the options. + # You can (optionally) add I18n keys for the options (if not the text will be used as it is). + # For the user interface, you can defined labels and descriptions for the fields (optionally): + # decidim.extra_user_fields.select_fields.field_name.label + # decidim.extra_user_fields.select_fields.field_name.description + # For the admin interface, you can defined labels and descriptions for the fields (optionally): + # decidim.extra_user_fields.admin.extra_user_fields.select_fields.field_name.label + # decidim.extra_user_fields.admin.extra_user_fields.select_fields.field_name.description + config_accessor :select_fields do + { + participant_type: { + # "" => "", + "individual" => "decidim.extra_user_fields.participant_types.individual", + "organization" => "decidim.extra_user_fields.participant_types.organization" + }, + favorite_pet: { + "cat" => "my_app.favorite_pets.cat". + "dog" => "my_app.favorite_pets.dog" + } + } + end end ``` diff --git a/app/commands/concerns/decidim/extra_user_fields/create_registrations_commands_overrides.rb b/app/commands/concerns/decidim/extra_user_fields/create_registrations_commands_overrides.rb index a45eb1b..514136c 100644 --- a/app/commands/concerns/decidim/extra_user_fields/create_registrations_commands_overrides.rb +++ b/app/commands/concerns/decidim/extra_user_fields/create_registrations_commands_overrides.rb @@ -54,6 +54,7 @@ def extended_data phone_number: form.phone_number, location: form.location, underage: form.underage, + select_fields: form.select_fields, statutory_representative_email: form.statutory_representative_email ) end diff --git a/app/commands/concerns/decidim/extra_user_fields/omniauth_commands_overrides.rb b/app/commands/concerns/decidim/extra_user_fields/omniauth_commands_overrides.rb index d72de5d..1f28375 100644 --- a/app/commands/concerns/decidim/extra_user_fields/omniauth_commands_overrides.rb +++ b/app/commands/concerns/decidim/extra_user_fields/omniauth_commands_overrides.rb @@ -81,6 +81,7 @@ def extended_data phone_number: form.phone_number, location: form.location, underage: form.underage, + select_fields: form.select_fields, statutory_representative_email: form.statutory_representative_email ) end diff --git a/app/commands/concerns/decidim/extra_user_fields/update_account_commands_overrides.rb b/app/commands/concerns/decidim/extra_user_fields/update_account_commands_overrides.rb index de11641..c9ecc58 100644 --- a/app/commands/concerns/decidim/extra_user_fields/update_account_commands_overrides.rb +++ b/app/commands/concerns/decidim/extra_user_fields/update_account_commands_overrides.rb @@ -30,6 +30,7 @@ def extended_data phone_number: @form.phone_number, location: @form.location, underage: @form.underage, + select_fields: @form.select_fields, statutory_representative_email: @form.statutory_representative_email ) end diff --git a/app/commands/decidim/extra_user_fields/admin/update_extra_user_fields.rb b/app/commands/decidim/extra_user_fields/admin/update_extra_user_fields.rb index 3492784..90dc420 100644 --- a/app/commands/decidim/extra_user_fields/admin/update_extra_user_fields.rb +++ b/app/commands/decidim/extra_user_fields/admin/update_extra_user_fields.rb @@ -55,7 +55,8 @@ def extra_user_fields }, "location" => { "enabled" => form.location.presence || false }, "underage" => { "enabled" => form.underage || false }, - "underage_limit" => form.underage_limit || Decidim::ExtraUserFields.underage_limit + "underage_limit" => form.underage_limit || Decidim::ExtraUserFields.underage_limit, + "select_fields" => form.select_fields.to_a } end # rubocop:enable Metrics/CyclomaticComplexity diff --git a/app/forms/concerns/decidim/extra_user_fields/forms_definitions.rb b/app/forms/concerns/decidim/extra_user_fields/forms_definitions.rb index 64f6c54..4c6bd6f 100644 --- a/app/forms/concerns/decidim/extra_user_fields/forms_definitions.rb +++ b/app/forms/concerns/decidim/extra_user_fields/forms_definitions.rb @@ -22,6 +22,7 @@ module FormsDefinitions attribute :location, String attribute :underage, ActiveRecord::Type::Boolean attribute :statutory_representative_email, String + attribute :select_fields, Hash, default: {} # EndBlock @@ -46,6 +47,7 @@ module FormsDefinitions "valid_email_2/email": { disposable: true }, if: :underage_accepted? validate :birth_date_under_limit + validate :select_fields_configured # EndBlock end @@ -61,11 +63,8 @@ def map_model(model) self.phone_number = extended_data[:phone_number] self.location = extended_data[:location] self.underage = extended_data[:underage] + self.select_fields = extended_data[:select_fields] || {} self.statutory_representative_email = extended_data[:statutory_representative_email] - - # Block ExtraUserFields MapModel - - # EndBlock end private @@ -109,6 +108,10 @@ def underage? extra_user_fields_enabled && current_organization.activated_extra_field?(:underage) end + def select_fields? + extra_user_fields_enabled && current_organization.activated_extra_field?(:select_fields) + end + def underage_accepted? underage? && underage == "1" end @@ -146,6 +149,21 @@ def underage_within_limit?(age) def underage_limit current_organization.extra_user_fields["underage_limit"] end + + def select_fields_configured + return unless select_fields? + + select_fields.each do |field, value| + next unless current_organization.extra_user_field_configuration(:select_fields).include?(field.to_s) + + conf = Decidim::ExtraUserFields.select_fields.with_indifferent_access[field] + next unless conf.is_a?(Hash) + next if conf.with_indifferent_access.has_key?(value) + + label = I18n.t("decidim.extra_user_fields.select_fields.#{field}.label", default: field.to_s.humanize) + errors.add(:base, I18n.t("decidim.extra_user_fields.errors.select_fields", field: label)) + end + end end end end diff --git a/app/forms/decidim/extra_user_fields/admin/extra_user_fields_form.rb b/app/forms/decidim/extra_user_fields/admin/extra_user_fields_form.rb index 7e10f28..30c15a3 100644 --- a/app/forms/decidim/extra_user_fields/admin/extra_user_fields_form.rb +++ b/app/forms/decidim/extra_user_fields/admin/extra_user_fields_form.rb @@ -19,9 +19,8 @@ class ExtraUserFieldsForm < Decidim::Form attribute :phone_number_pattern, String translatable_attribute :phone_number_placeholder, String - # Block ExtraUserFields Attributes - # EndBlock + attribute :select_fields, Array, default: [] def map_model(model) self.enabled = model.extra_user_fields["enabled"] @@ -36,9 +35,13 @@ def map_model(model) self.underage_limit = model.extra_user_fields.fetch("underage_limit", Decidim::ExtraUserFields.underage_limit) self.phone_number_pattern = model.extra_user_fields.dig("phone_number", "pattern") self.phone_number_placeholder = model.extra_user_fields.dig("phone_number", "placeholder") - # Block ExtraUserFields MapModel + self.select_fields = model.extra_user_fields["select_fields"] || [] + end - # EndBlock + def select_fields + super.filter do |field| + Decidim::ExtraUserFields.select_fields.keys.map(&:to_s).include?(field) + end end end end diff --git a/app/helpers/decidim/extra_user_fields/admin/application_helper.rb b/app/helpers/decidim/extra_user_fields/admin/application_helper.rb index 2d47155..9657b34 100644 --- a/app/helpers/decidim/extra_user_fields/admin/application_helper.rb +++ b/app/helpers/decidim/extra_user_fields/admin/application_helper.rb @@ -18,6 +18,14 @@ def extra_user_fields_export_users_dropdown end.join.html_safe end end + + def custom_select_fields(form) + return {} unless Decidim::ExtraUserFields.select_fields.is_a?(Hash) + + Decidim::ExtraUserFields.select_fields.keys.index_with do |field| + form.object.select_fields.include?(field.to_s) + end + end end end end diff --git a/app/helpers/decidim/extra_user_fields/application_helper.rb b/app/helpers/decidim/extra_user_fields/application_helper.rb index 78253d8..2b6a989 100644 --- a/app/helpers/decidim/extra_user_fields/application_helper.rb +++ b/app/helpers/decidim/extra_user_fields/application_helper.rb @@ -24,6 +24,22 @@ def phone_number_extra_user_field_pattern def phone_number_extra_user_field_placeholder current_organization.extra_user_field_configuration(:phone_number)["placeholder"] end + + def custom_select_fields_options + Decidim::ExtraUserFields.select_fields.filter_map do |field, options| + next unless options.is_a?(Hash) + next if options.blank? + next if current_organization.extra_user_field_configuration(:select_fields).include?(field) + + [ + field, + options.map do |option, label| + label = I18n.t(label, default: label.split(".").last.to_s.humanize) if label.present? + [label, option] + end + ] + end.to_h + end end end end diff --git a/app/models/concerns/decidim/extra_user_fields/organization_overrides.rb b/app/models/concerns/decidim/extra_user_fields/organization_overrides.rb index 241c2ed..9305da8 100644 --- a/app/models/concerns/decidim/extra_user_fields/organization_overrides.rb +++ b/app/models/concerns/decidim/extra_user_fields/organization_overrides.rb @@ -10,27 +10,40 @@ module OrganizationOverrides # If true display registration field in signup form def extra_user_fields_enabled? - extra_user_fields["enabled"].presence && at_least_one_extra_field? + extra_user_fields["enabled"].present? && at_least_one_extra_field? end def at_least_one_extra_field? - extra_user_fields.reject { |key| %w(enabled underage_limit).include?(key) } - .map { |_, value| value["enabled"] }.any? + extra_user_fields.filter_map do |field, _value| + next if %w(enabled underage_limit).include?(field) + + activated_extra_field?(field) + end.any? end # Check if the given value is enabled in extra_user_fields - def activated_extra_field?(sym) - extra_user_fields.dig(sym.to_s, "enabled") == true + def activated_extra_field?(field) + value = extra_user_fields[field.to_s] + + if value.is_a?(Hash) + value["enabled"] + else + value + end.present? end def age_limit? extra_user_fields["underage_limit"].to_i end - def extra_user_field_configuration(sym) - return {} unless activated_extra_field?(sym) + def extra_user_field_configuration(field) + return {} unless activated_extra_field?(field) + + value = extra_user_fields[field.to_s] + + return value.except("enabled") if value.is_a?(Hash) - extra_user_fields[sym.to_s].except("enabled") + value end end end diff --git a/app/serializers/decidim/extra_user_fields/user_export_serializer.rb b/app/serializers/decidim/extra_user_fields/user_export_serializer.rb index 8ff9a75..006830b 100644 --- a/app/serializers/decidim/extra_user_fields/user_export_serializer.rb +++ b/app/serializers/decidim/extra_user_fields/user_export_serializer.rb @@ -13,7 +13,7 @@ def serialize def extra_user_fields extended_data = resource.extended_data.symbolize_keys - [:gender, :age_range, :country, :postal_code, :date_of_birth, :phone_number, :location, :underage, :statutory_representative_email].index_with do |key| + extra_fields.index_with do |key| extended_data[key] end end @@ -36,10 +36,8 @@ def extra_fields :phone_number, :location, :underage, + :select_fields, :statutory_representative_email - # Block ExtraUserFields AddExtraField - - # EndBlock ] end end diff --git a/app/views/decidim/extra_user_fields/_profile_form.html.erb b/app/views/decidim/extra_user_fields/_profile_form.html.erb index 9f20e9c..fe07d66 100644 --- a/app/views/decidim/extra_user_fields/_profile_form.html.erb +++ b/app/views/decidim/extra_user_fields/_profile_form.html.erb @@ -33,4 +33,8 @@ <%= f.hidden_field :underage, value: current_user.extended_data["underage"] || "0" %> <%= f.hidden_field :statutory_representative_email, value: current_user.extended_data["statutory_representative_email"] || "" %> <% end %> + + <% if current_organization.activated_extra_field?(:select_fields) %> + <%= render partial: "decidim/extra_user_fields/select_fields", locals: { f: f } %> + <% end %> <% end %> diff --git a/app/views/decidim/extra_user_fields/_registration_form.html.erb b/app/views/decidim/extra_user_fields/_registration_form.html.erb index f43b5eb..97b08c8 100644 --- a/app/views/decidim/extra_user_fields/_registration_form.html.erb +++ b/app/views/decidim/extra_user_fields/_registration_form.html.erb @@ -3,7 +3,7 @@

<%= t(".signup.legend") %>

<% if current_organization.activated_extra_field?(:date_of_birth) %> -
<%= f.date_field :date_of_birth, id: "user_date_of_birth" %>
+
<%= f.date_field :date_of_birth %>
<% end %> <% if current_organization.activated_extra_field?(:gender) %> @@ -49,9 +49,10 @@ <% end %> <% end %> - <%# Block ExtraUserFields SignUpFormFields %> - <%# EndBlock %> + <% if current_organization.activated_extra_field?(:select_fields) %> + <%= render partial: "decidim/extra_user_fields/select_fields", locals: { f: f } %> + <% end %> <%= append_javascript_pack_tag "decidim_extra_user_fields.js" %> diff --git a/app/views/decidim/extra_user_fields/_select_fields.html.erb b/app/views/decidim/extra_user_fields/_select_fields.html.erb new file mode 100644 index 0000000..489dafe --- /dev/null +++ b/app/views/decidim/extra_user_fields/_select_fields.html.erb @@ -0,0 +1,14 @@ + <% f.object.custom_select_fields_options.each do |field, options| %> +
+ <%= label_tag f.field_id("select_fields_#{field}") do %> + <%= t("decidim.extra_user_fields.select_fields.#{field}.label", default: field.to_s.humanize) %> + <% if (help = t("decidim.extra_user_fields.select_fields.#{field}.description", default: "")).present? %> + <%= help %> + <% end %> + + <%= select_tag "user[select_fields][#{field}]", + options_for_select(options, f.object.select_fields[field]), + id: f.field_id("select_fields_#{field}") %> + <% end %> +
+ <% end %> diff --git a/app/views/decidim/extra_user_fields/admin/extra_user_fields/_form.html.erb b/app/views/decidim/extra_user_fields/admin/extra_user_fields/_form.html.erb index 64d1ea7..8b4f6fe 100644 --- a/app/views/decidim/extra_user_fields/admin/extra_user_fields/_form.html.erb +++ b/app/views/decidim/extra_user_fields/admin/extra_user_fields/_form.html.erb @@ -33,6 +33,13 @@ <%= render partial: "decidim/extra_user_fields/admin/extra_user_fields/fields/phone_number", locals: { form: form } %> <%= render partial: "decidim/extra_user_fields/admin/extra_user_fields/fields/location", locals: { form: form } %> <%= render partial: "decidim/extra_user_fields/admin/extra_user_fields/fields/underage", locals: { form: form } %> + +
+

<%= t(".extra_user_fields.section_extras") %>

+

<%= t(".extra_user_fields.section_extras_description") %>

+
+ + <%= render partial: "decidim/extra_user_fields/admin/extra_user_fields/fields/select_fields", locals: { form: form } %> diff --git a/app/views/decidim/extra_user_fields/admin/extra_user_fields/fields/_select_fields.html.erb b/app/views/decidim/extra_user_fields/admin/extra_user_fields/fields/_select_fields.html.erb new file mode 100644 index 0000000..f648e7e --- /dev/null +++ b/app/views/decidim/extra_user_fields/admin/extra_user_fields/fields/_select_fields.html.erb @@ -0,0 +1,15 @@ +<% custom_select_fields(form).each do |field, checked| %> +
+
+ <%= label_tag "extra_user_fields_select_field_#{field}" do %> + + <%= check_box_tag "extra_user_fields[select_fields][]", + field, + checked, + id: "extra_user_fields_select_field_#{field}" %> + <%= t("decidim.extra_user_fields.admin.extra_user_fields.select_fields.#{field}.label", default: field.to_s.humanize ) %> + <%= t("decidim.extra_user_fields.admin.extra_user_fields.select_fields.#{field}.description", default: "") %> + <% end %> +
+
+<% end %> diff --git a/bin/rails b/bin/rails index a721644..961aa72 100755 --- a/bin/rails +++ b/bin/rails @@ -1,16 +1,6 @@ #!/usr/bin/env ruby # frozen_string_literal: true -# This command will automatically be run when you run "rails" with Rails gems -# installed from the root of your application. +Dir.chdir("development_app") -ENGINE_ROOT = File.expand_path("..", __dir__) -ENGINE_PATH = File.expand_path("../lib/decidim/extra_user_fields/engine", __dir__) - -# Set up gems listed in the Gemfile. -ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../Gemfile", __dir__) - -require "bundler/setup" - -require "rails/all" -require "rails/engine/commands" +load "bin/rails" diff --git a/bin/shakapacker b/bin/shakapacker new file mode 100755 index 0000000..86aefe8 --- /dev/null +++ b/bin/shakapacker @@ -0,0 +1,6 @@ +#!/usr/bin/env ruby +# frozen_string_literal: true + +Dir.chdir("development_app") + +load "bin/shakapacker" diff --git a/bin/shakapacker-dev-server b/bin/shakapacker-dev-server new file mode 100755 index 0000000..0226ffe --- /dev/null +++ b/bin/shakapacker-dev-server @@ -0,0 +1,6 @@ +#!/usr/bin/env ruby +# frozen_string_literal: true + +Dir.chdir("development_app") + +load "bin/shakapacker-dev-server" diff --git a/config/locales/en.yml b/config/locales/en.yml index 57f0bb5..bd8edff 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -83,11 +83,20 @@ en: extra_user_fields: extra_user_fields_enabled: Enable extra user fields section: Available extra fields for signup form + section_extras: Additional custom fields + section_extras_description: If you have configured any extra user fields, + you can manage them here (See section "Configuration through an initializer" + in the plugin README). global: title: Activate / deactivate functionality index: save: Save configuration title: Manage extra user fields + select_fields: + participant_type: + description: This field is a list of participant types. If checked, + user will have to choose a participant type + label: Enable participant type field update: failure: An error occurred on update success: Extra user fields correctly updated in organization @@ -97,6 +106,8 @@ en: 61_or_more: 61 or older prefer_not_to_say: Prefer not to say up_to_16: 16 or younger + errors: + select_fields: The field "%{field}" is not valid. genders: female: Female male: Male @@ -106,6 +117,10 @@ en: signup: legend: More information underage: I am under %{limit} years old and I agree to get a parental authorization + select_fields: + participant_type: + label: Are you participating as an individual, or officially on behalf of + an organization? statutory_representative: inform: body: | diff --git a/config/locales/fr.yml b/config/locales/fr.yml index a7a4793..7bab8e8 100644 --- a/config/locales/fr.yml +++ b/config/locales/fr.yml @@ -85,11 +85,20 @@ fr: extra_user_fields: extra_user_fields_enabled: Activer les champs d'inscription personnalisés section: Champs d'inscription disponibles pour le formulaire d'inscription + section_extras: Champs supplémentaires personnalisés + section_extras_description: Si vous avez configuré des champs d'utilisateur + supplémentaires, vous pouvez les gérer ici (Voir la section "Configuration + via un initializer" dans le README du plugin). global: title: Activer / Désactiver les champs d'inscription personnalisés index: save: Sauvegarder title: Gérer les champs d'inscription personnalisés + select_fields: + participant_type: + description: Ce champ est une liste de types de participants. L'utilisateur + devra choisir un type de participant. + label: Activer le champ type de participant update: failure: Une erreur est survenue lors de la mise à jour success: Les champs d'inscription ont été mis à jour avec succ§s @@ -99,6 +108,8 @@ fr: 61_or_more: 61 ou plus prefer_not_to_say: Préfère ne pas dire up_to_16: 16 ou moins + errors: + select_fields: Le champ "%{field}" n'est pas valide. genders: female: Femme male: Homme @@ -109,6 +120,9 @@ fr: legend: Plus d'information underage: Je suis âgé de moins de %{limit} ans et j'accepte d'obtenir une autorisation parentale + select_fields: + participant_type: + label: Activer le champ type de participant statutory_representative: inform: body: | diff --git a/lib/decidim/extra_user_fields.rb b/lib/decidim/extra_user_fields.rb index 5d245b7..7f3db65 100644 --- a/lib/decidim/extra_user_fields.rb +++ b/lib/decidim/extra_user_fields.rb @@ -33,5 +33,24 @@ module ExtraUserFields config_accessor :age_ranges do ENV.fetch("EXTRA_USER_FIELDS_AGE_RANGES", "up_to_16 17_to_30 31_to_60 61_or_more prefer_not_to_say").split end + + # I extra select fields are needed, they can be added here. + # The key is the field name and the value is a hash with the options. + # You can (optionally) add I18n keys for the options (if not the text will be used as it is). + # For the user interface, you can defined labels and descriptions for the fields (optionally): + # decidim.extra_user_fields.select_fields.field_name.label + # decidim.extra_user_fields.select_fields.field_name.description + # For the admin interface, you can defined labels and descriptions for the fields (optionally): + # decidim.extra_user_fields.admin.extra_user_fields.select_fields.field_name.label + # decidim.extra_user_fields.admin.extra_user_fields.select_fields.field_name.description + config_accessor :select_fields do + { + participant_type: { + # "" => "", + "individual" => "decidim.extra_user_fields.participant_types.individual", + "organization" => "decidim.extra_user_fields.participant_types.organization" + } + } + end end end diff --git a/spec/commands/decidim/create_omniauth_registration_spec.rb b/spec/commands/decidim/create_omniauth_registration_spec.rb index 2d169ff..61ea0c2 100644 --- a/spec/commands/decidim/create_omniauth_registration_spec.rb +++ b/spec/commands/decidim/create_omniauth_registration_spec.rb @@ -20,6 +20,11 @@ module Comments let(:phone_number) { "0123456789" } let(:postal_code) { "75001" } let(:underage) { false } + let(:select_fields) do + { + "participant_type" => "individual" + } + end let(:statutory_representative_email) { nil } let(:extended_data) do { @@ -31,6 +36,7 @@ module Comments phone_number:, postal_code:, underage:, + select_fields:, statutory_representative_email: } end @@ -54,6 +60,7 @@ module Comments "phone_number" => phone_number, "location" => location, "underage" => underage, + "select_fields" => select_fields, "statutory_representative_email" => statutory_representative_email } } @@ -115,6 +122,16 @@ module Comments expect(user.newsletter_notifications_at).to be_nil expect(user).to be_confirmed expect(user.valid_password?("decidim123456789")).to be(true) + + expect(user.extended_data["country"]).to eq(country) + expect(user.extended_data["postal_code"]).to eq(postal_code) + expect(user.extended_data["date_of_birth"]).to eq(date_of_birth.to_date.iso8601) + expect(user.extended_data["gender"]).to eq(gender) + expect(user.extended_data["age_range"]).to eq(age_range) + expect(user.extended_data["phone_number"]).to eq(phone_number) + expect(user.extended_data["location"]).to eq(location) + expect(user.extended_data["underage"]).to eq(underage) + expect(user.extended_data["select_fields"]).to eq(select_fields) end # NOTE: This is important so that the users who are only diff --git a/spec/commands/decidim/create_registration_spec.rb b/spec/commands/decidim/create_registration_spec.rb index 6f7859f..c409cc4 100644 --- a/spec/commands/decidim/create_registration_spec.rb +++ b/spec/commands/decidim/create_registration_spec.rb @@ -23,6 +23,11 @@ module Comments let(:phone_number) { "0123456789" } let(:postal_code) { "75001" } let(:underage) { "0" } + let(:select_fields) do + { + participant_type: "individual" + } + end let(:statutory_representative_email) { nil } let(:extended_data) do { @@ -33,6 +38,7 @@ module Comments phone_number:, postal_code:, underage:, + age_range:, statutory_representative_email: } end @@ -54,6 +60,7 @@ module Comments "phone_number" => phone_number, "location" => location, "underage" => underage, + "select_fields" => select_fields, "statutory_representative_email" => statutory_representative_email } } @@ -129,6 +136,7 @@ module Comments phone_number:, postal_code:, underage:, + select_fields:, statutory_representative_email: } ).and_call_original diff --git a/spec/commands/decidim/extra_user_fields/admin/update_extra_user_fields_spec.rb b/spec/commands/decidim/extra_user_fields/admin/update_extra_user_fields_spec.rb index cfbd60e..4453cf8 100644 --- a/spec/commands/decidim/extra_user_fields/admin/update_extra_user_fields_spec.rb +++ b/spec/commands/decidim/extra_user_fields/admin/update_extra_user_fields_spec.rb @@ -21,11 +21,7 @@ module Admin let(:location) { true } let(:underage) { true } let(:underage_limit) { 18 } - # Block ExtraUserFields RspecVar - # EndBlock - - # rubocop:disable Style/TrailingCommaInHashLiteral let(:form_params) do { "postal_code" => postal_code, @@ -40,13 +36,9 @@ module Admin "location" => location, "underage" => underage, "underage_limit" => underage_limit, - # Block ExtraUserFields ExtraUserFields - - # EndBlock + "select_fields" => %w(participant_type non_existing_field) } end - # rubocop:enable Style/TrailingCommaInHashLiteral - let(:form) do ExtraUserFieldsForm.from_params( form_params @@ -96,9 +88,7 @@ module Admin expect(extra_user_fields).to include("location" => { "enabled" => true }) expect(extra_user_fields).to include("underage" => { "enabled" => true }) expect(extra_user_fields).to include("underage_limit" => 18) - # Block ExtraUserFields InclusionSpec - - # EndBlock + expect(extra_user_fields).to include("select_fields" => ["participant_type"]) end end end diff --git a/spec/forms/decidim/account_form_spec.rb b/spec/forms/decidim/account_form_spec.rb index ab9cd51..fd0615f 100644 --- a/spec/forms/decidim/account_form_spec.rb +++ b/spec/forms/decidim/account_form_spec.rb @@ -22,9 +22,11 @@ module Decidim postal_code:, date_of_birth:, gender:, + age_range:, phone_number:, location:, underage:, + select_fields:, statutory_representative_email: ).with_context( current_organization: organization, @@ -44,7 +46,8 @@ module Decidim "phone_number" => { "enabled" => true, "pattern" => phone_number_pattern, "placeholder" => nil }, "location" => { "enabled" => true }, "underage" => { "enabled" => true }, - "underage_limit" => 18 + "underage_limit" => 18, + "select_fields" => ["participant_type"] } end let(:phone_number_pattern) { "^(\\+34)?[0-9 ]{9,12}$" } @@ -67,6 +70,11 @@ module Decidim let(:phone_number) { "0123456789" } let(:postal_code) { "75001" } let(:underage) { "0" } + let(:select_fields) do + { + participant_type: "individual" + } + end let(:statutory_representative_email) { nil } context "with correct data" do @@ -91,6 +99,31 @@ module Decidim end end + context "with non configured select fields" do + let(:select_fields) do + { + participant_type: "individual", + foo: "bar" + } + end + + it "is invalid" do + expect(subject).to be_valid + end + end + + context "with incorrect select fields" do + let(:select_fields) do + { + participant_type: "i_dont_exist" + } + end + + it "is invalid" do + expect(subject).not_to be_valid + end + end + describe "name" do context "with an empty name" do let(:name) { "" } diff --git a/spec/forms/decidim/omniauth_registration_form_spec.rb b/spec/forms/decidim/omniauth_registration_form_spec.rb index a09acd1..c0758da 100644 --- a/spec/forms/decidim/omniauth_registration_form_spec.rb +++ b/spec/forms/decidim/omniauth_registration_form_spec.rb @@ -25,6 +25,12 @@ module Decidim let(:location) { "Paris" } let(:phone_number) { "0123456789" } let(:postal_code) { "75001" } + let(:underage) { false } + let(:select_fields) do + { + "participant_type" => "individual" + } + end let(:attributes) do { @@ -41,7 +47,9 @@ module Decidim gender:, age_range:, phone_number:, - location: + location:, + underage:, + select_fields: } end diff --git a/spec/serializers/decidim/extra_user_fields/user_export_serializer_spec.rb b/spec/serializers/decidim/extra_user_fields/user_export_serializer_spec.rb index 1403850..f18cd3e 100644 --- a/spec/serializers/decidim/extra_user_fields/user_export_serializer_spec.rb +++ b/spec/serializers/decidim/extra_user_fields/user_export_serializer_spec.rb @@ -6,7 +6,6 @@ subject { described_class.new(resource) } let(:resource) { create(:user, extended_data: registration_metadata) } - # rubocop:disable Style/TrailingCommaInHashLiteral let(:registration_metadata) do { gender:, @@ -17,13 +16,10 @@ phone_number:, location:, underage:, - statutory_representative_email:, - # Block ExtraUserFields ExtraUserFields - - # EndBlock + select_fields:, + statutory_representative_email: } end - # rubocop:enable Style/TrailingCommaInHashLiteral let(:gender) { "other" } let(:age_range) { "17_to_30" } @@ -35,9 +31,12 @@ let(:underage) { true } let(:underage_limit) { 18 } let(:statutory_representative_email) { "parent@example.org" } - # Block ExtraUserFields RspecVar + let(:select_fields) do + { + "participant_type" => "individual" + } + end - # EndBlock let(:serialized) { subject.serialize } describe "#serialize" do @@ -73,6 +72,10 @@ expect(serialized).to include(location: resource.extended_data["location"]) end + it "includes the select fields" do + expect(serialized).to include(select_fields: resource.extended_data["select_fields"]) + end + context "when users are blocked" do let(:resource) { create(:user, :blocked, extended_data: registration_metadata, blocked_at:) } let(:blocked_at) { Time.zone.now } diff --git a/spec/system/account_spec.rb b/spec/system/account_spec.rb index b286f3e..23ab8da 100644 --- a/spec/system/account_spec.rb +++ b/spec/system/account_spec.rb @@ -12,23 +12,20 @@ let(:organization) { create(:organization, extra_user_fields:) } let(:user) { create(:user, :confirmed, organization:, password:) } let(:password) { "dqCFgjfDbC7dPbrv" } - # rubocop:disable Style/TrailingCommaInHashLiteral + let(:extra_user_fields) do { "enabled" => true, "date_of_birth" => date_of_birth, "postal_code" => postal_code, "gender" => gender, + "select_fields" => select_fields, "age_range" => age_range, "country" => country, "phone_number" => phone_number, - "location" => location, - # Block ExtraUserFields ExtraUserFields - - # EndBlock + "location" => location } end - # rubocop:enable Style/TrailingCommaInHashLiteral let(:date_of_birth) do { "enabled" => true } @@ -59,6 +56,10 @@ { "enabled" => true } end + let(:select_fields) do + ["participant_type"] + end + # Block ExtraUserFields RspecVar # EndBlock @@ -107,10 +108,11 @@ fill_in :user_personal_url, with: "https://example.org" fill_in :user_about, with: "A Serbian-American inventor, electrical engineer, mechanical engineer, physicist, and futurist." - fill_in :user_date_of_birth_date, with: "01/01/2000" + fill_in_datepicker :user_date_of_birth_date, with: "01/01/2000" select "Other", from: :user_gender select "17 to 30", from: :user_age_range select "Argentina", from: :user_country + select "Individual", from: :user_select_fields_participant_type fill_in :user_postal_code, with: "00000" fill_in :user_phone_number, with: "0123456789" fill_in :user_location, with: "Cahors" @@ -238,6 +240,14 @@ it_behaves_like "does not display extra user field", "location", "Location" end + context "when select_fields is not enabled" do + let(:select_fields) do + ["another_field"] + end + + it_behaves_like "does not display extra user field", "select_fields", "Select fields" + end + describe "when update password" do before do within "form.edit_user" do @@ -246,10 +256,11 @@ fill_in :user_personal_url, with: "https://example.org" fill_in :user_about, with: "A Serbian-American inventor, electrical engineer, mechanical engineer, physicist, and futurist." - fill_in :user_date_of_birth_date, with: "01/01/2000" + fill_in_datepicker :user_date_of_birth_date, with: "01/01/2000" select "Other", from: :user_gender select "17 to 30", from: :user_age_range select "Argentina", from: :user_country + select "Individual", from: :user_select_fields_participant_type fill_in :user_postal_code, with: "00000" fill_in :user_phone_number, with: "0123456789" fill_in :user_location, with: "Cahors" @@ -307,10 +318,11 @@ fill_in :user_personal_url, with: "https://example.org" fill_in :user_about, with: "A Serbian-American inventor, electrical engineer, mechanical engineer, physicist, and futurist." - fill_in :user_date_of_birth_date, with: "01/01/2000" + fill_in_datepicker :user_date_of_birth_date, with: "01/01/2000" select "Other", from: :user_gender select "17 to 30", from: :user_age_range select "Argentina", from: :user_country + select "Individual", from: :user_select_fields_participant_type fill_in :user_postal_code, with: "00000" fill_in :user_phone_number, with: "0123456789" fill_in :user_location, with: "Cahors" diff --git a/spec/system/admin_manages_organization_extra_user_fields_spec.rb b/spec/system/admin_manages_organization_extra_user_fields_spec.rb index 2cfcd72..419adf4 100644 --- a/spec/system/admin_manages_organization_extra_user_fields_spec.rb +++ b/spec/system/admin_manages_organization_extra_user_fields_spec.rb @@ -46,5 +46,48 @@ expect(page).to have_content("Extra user fields correctly updated in organization") end end + + context "when custom select_fields" do + it "displays the custom select fields" do + within "#accordion-setup" do + expect(page).to have_content("Additional custom fields") + expect(page).to have_content("Enable participant type") + expect(page).to have_content("This field is a list of participant types") + + page.check("Enable participant type field") + end + + find("*[type=submit]", text: "Save configuration").click + expect(page).to have_content("Extra user fields correctly updated in organization") + end + end + end + + context "and no translations are provided" do + let(:custom_select_fields) do + { + animal_type: { + dog: "I love dogs", + cat: "I love cats" + } + } + end + + before do + allow(Decidim::ExtraUserFields).to receive(:select_fields).and_return(custom_select_fields) + visit decidim_extra_user_fields.root_path + end + + it "displays the custom select fields" do + within "#accordion-setup" do + expect(page).to have_content("Additional custom fields") + expect(page).to have_content("Animal type") + + page.check("Animal type") + end + + find("*[type=submit]", text: "Save configuration").click + expect(page).to have_content("Extra user fields correctly updated in organization") + end end end diff --git a/spec/system/registration_spec.rb b/spec/system/registration_spec.rb index d9e083f..dccc1bb 100644 --- a/spec/system/registration_spec.rb +++ b/spec/system/registration_spec.rb @@ -11,10 +11,11 @@ def fill_registration_form end def fill_extra_user_fields - fill_in :registration_user_date_of_birth_date, with: "01/01/2000" + fill_in_datepicker :registration_user_date_of_birth_date, with: "01/01/2000" select "Other", from: :registration_user_gender select "17 to 30", from: :registration_user_age_range select "Argentina", from: :registration_user_country + select "Individual", from: :registration_user_select_fields_participant_type fill_in :registration_user_postal_code, with: "00000" fill_in :registration_user_phone_number, with: "0123456789" fill_in :registration_user_location, with: "Cahors" @@ -34,10 +35,9 @@ def fill_extra_user_fields let(:organization) { create(:organization, extra_user_fields:) } let!(:terms_and_conditions_page) { Decidim::StaticPage.find_by(slug: "terms-and-conditions", organization:) } - # rubocop:disable Style/TrailingCommaInHashLiteral + let(:extra_user_fields) do { - # Block ExtraUserFields ExtraUserFields "enabled" => true, "date_of_birth" => date_of_birth, "postal_code" => postal_code, @@ -46,10 +46,9 @@ def fill_extra_user_fields "country" => country, "phone_number" => phone_number, "location" => location, - # EndBlock + "select_fields" => select_fields } end - # rubocop:enable Style/TrailingCommaInHashLiteral let(:date_of_birth) do { "enabled" => true } @@ -80,9 +79,9 @@ def fill_extra_user_fields { "enabled" => true } end - # Block ExtraUserFields RspecVar - - # EndBlock + let(:select_fields) do + ["participant_type"] + end before do switch_to_host(organization.host) @@ -97,9 +96,8 @@ def fill_extra_user_fields expect(page).to have_content("Postal code") expect(page).to have_content("Phone Number") expect(page).to have_content("Location") - # Block ExtraUserFields ContainsFieldSpec - - # EndBlock + expect(page).to have_content("How old are you?") + expect(page).to have_content("Are you participating as an individual, or officially on behalf of an organization?") end end @@ -154,9 +152,6 @@ def fill_extra_user_fields it_behaves_like "mandatory extra user fields", "postal_code" it_behaves_like "mandatory extra user fields", "phone_number" it_behaves_like "mandatory extra user fields", "location" - # Block ExtraUserFields ItBehavesLikeSpec - - # EndBlock context "when extra_user_fields is disabled" do let(:organization) { create(:organization, :extra_user_fields_disabled) } @@ -169,9 +164,8 @@ def fill_extra_user_fields expect(page).to have_no_content("Postal code") expect(page).to have_no_content("Phone Number") expect(page).to have_no_content("Location") - # Block ExtraUserFields DoesNotContainFieldSpec - - # EndBlock + expect(page).to have_no_content("Which gender do you identify with?") + expect(page).to have_no_content("Are you participating as an individual, or officially on behalf of an organization?") end it "allows to create a new account" do From 1442d52e966aee0614a80cd8ae1f5be2c135ff31 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ivan=20Verg=C3=A9s?= Date: Mon, 12 May 2025 15:02:49 +0200 Subject: [PATCH 06/10] add custom boolean fields (#5) * add custom boolean fields * fix specs --- README.md | 42 +++++++++---------- ...create_registrations_commands_overrides.rb | 1 + .../omniauth_commands_overrides.rb | 1 + .../update_account_commands_overrides.rb | 1 + .../admin/update_extra_user_fields.rb | 3 +- .../extra_user_fields/forms_definitions.rb | 13 +----- .../admin/extra_user_fields_form.rb | 8 ++++ .../admin/application_helper.rb | 8 ++++ .../extra_user_fields/application_helper.rb | 12 +++++- .../user_export_serializer.rb | 1 + .../_boolean_fields.html.erb | 15 +++++++ .../extra_user_fields/_profile_form.html.erb | 4 ++ .../_registration_form.html.erb | 3 ++ .../admin/extra_user_fields/_form.html.erb | 1 + .../fields/_boolean_fields.html.erb | 15 +++++++ config/locales/en.yml | 8 ++++ config/locales/fr.yml | 8 ++++ lib/decidim/extra_user_fields.rb | 13 +++++- .../create_omniauth_registration_spec.rb | 6 +++ .../decidim/create_registration_spec.rb | 5 +++ .../admin/update_extra_user_fields_spec.rb | 4 +- spec/forms/decidim/account_form_spec.rb | 19 ++++++++- .../omniauth_registration_form_spec.rb | 6 ++- .../user_export_serializer_spec.rb | 8 ++++ spec/system/account_spec.rb | 16 +++++++ ...ges_organization_extra_user_fields_spec.rb | 31 ++++++++++++++ spec/system/registration_spec.rb | 13 ++++-- 27 files changed, 222 insertions(+), 43 deletions(-) create mode 100644 app/views/decidim/extra_user_fields/_boolean_fields.html.erb create mode 100644 app/views/decidim/extra_user_fields/admin/extra_user_fields/fields/_boolean_fields.html.erb diff --git a/README.md b/README.md index 61e4ac1..be0db96 100644 --- a/README.md +++ b/README.md @@ -122,28 +122,28 @@ Decidim::ExtraUserFields.configure do |config| ... - # I extra select fields are needed, they can be added here. - # The key is the field name and the value is a hash with the options. - # You can (optionally) add I18n keys for the options (if not the text will be used as it is). - # For the user interface, you can defined labels and descriptions for the fields (optionally): - # decidim.extra_user_fields.select_fields.field_name.label - # decidim.extra_user_fields.select_fields.field_name.description - # For the admin interface, you can defined labels and descriptions for the fields (optionally): - # decidim.extra_user_fields.admin.extra_user_fields.select_fields.field_name.label - # decidim.extra_user_fields.admin.extra_user_fields.select_fields.field_name.description - config_accessor :select_fields do - { - participant_type: { - # "" => "", - "individual" => "decidim.extra_user_fields.participant_types.individual", - "organization" => "decidim.extra_user_fields.participant_types.organization" - }, - favorite_pet: { - "cat" => "my_app.favorite_pets.cat". - "dog" => "my_app.favorite_pets.dog" - } + # I extra select fields are needed, they can be added here. + # The key is the field name and the value is a hash with the options. + # You can (optionally) add I18n keys for the options (if not the text will be used as it is). + # For the user interface, you can defined labels and descriptions for the fields (optionally): + # decidim.extra_user_fields.select_fields.field_name.label + # decidim.extra_user_fields.select_fields.field_name.description + # For the admin interface, you can defined labels and descriptions for the fields (optionally): + # decidim.extra_user_fields.admin.extra_user_fields.select_fields.field_name.label + # decidim.extra_user_fields.admin.extra_user_fields.select_fields.field_name.description + config_accessor :select_fields do + { + participant_type: { + # "" => "", + "individual" => "decidim.extra_user_fields.participant_types.individual", + "organization" => "decidim.extra_user_fields.participant_types.organization" + }, + favorite_pet: { + "cat" => "my_app.favorite_pets.cat". + "dog" => "my_app.favorite_pets.dog" } - end + } + end end ``` diff --git a/app/commands/concerns/decidim/extra_user_fields/create_registrations_commands_overrides.rb b/app/commands/concerns/decidim/extra_user_fields/create_registrations_commands_overrides.rb index 514136c..dba02b2 100644 --- a/app/commands/concerns/decidim/extra_user_fields/create_registrations_commands_overrides.rb +++ b/app/commands/concerns/decidim/extra_user_fields/create_registrations_commands_overrides.rb @@ -55,6 +55,7 @@ def extended_data location: form.location, underage: form.underage, select_fields: form.select_fields, + boolean_fields: form.boolean_fields, statutory_representative_email: form.statutory_representative_email ) end diff --git a/app/commands/concerns/decidim/extra_user_fields/omniauth_commands_overrides.rb b/app/commands/concerns/decidim/extra_user_fields/omniauth_commands_overrides.rb index 1f28375..859d895 100644 --- a/app/commands/concerns/decidim/extra_user_fields/omniauth_commands_overrides.rb +++ b/app/commands/concerns/decidim/extra_user_fields/omniauth_commands_overrides.rb @@ -82,6 +82,7 @@ def extended_data location: form.location, underage: form.underage, select_fields: form.select_fields, + boolean_fields: form.boolean_fields, statutory_representative_email: form.statutory_representative_email ) end diff --git a/app/commands/concerns/decidim/extra_user_fields/update_account_commands_overrides.rb b/app/commands/concerns/decidim/extra_user_fields/update_account_commands_overrides.rb index c9ecc58..3aa1629 100644 --- a/app/commands/concerns/decidim/extra_user_fields/update_account_commands_overrides.rb +++ b/app/commands/concerns/decidim/extra_user_fields/update_account_commands_overrides.rb @@ -31,6 +31,7 @@ def extended_data location: @form.location, underage: @form.underage, select_fields: @form.select_fields, + boolean_fields: @form.boolean_fields, statutory_representative_email: @form.statutory_representative_email ) end diff --git a/app/commands/decidim/extra_user_fields/admin/update_extra_user_fields.rb b/app/commands/decidim/extra_user_fields/admin/update_extra_user_fields.rb index 90dc420..e88eb2e 100644 --- a/app/commands/decidim/extra_user_fields/admin/update_extra_user_fields.rb +++ b/app/commands/decidim/extra_user_fields/admin/update_extra_user_fields.rb @@ -56,7 +56,8 @@ def extra_user_fields "location" => { "enabled" => form.location.presence || false }, "underage" => { "enabled" => form.underage || false }, "underage_limit" => form.underage_limit || Decidim::ExtraUserFields.underage_limit, - "select_fields" => form.select_fields.to_a + "select_fields" => form.select_fields.to_a, + "boolean_fields" => form.boolean_fields.to_a } end # rubocop:enable Metrics/CyclomaticComplexity diff --git a/app/forms/concerns/decidim/extra_user_fields/forms_definitions.rb b/app/forms/concerns/decidim/extra_user_fields/forms_definitions.rb index 4c6bd6f..a100ffe 100644 --- a/app/forms/concerns/decidim/extra_user_fields/forms_definitions.rb +++ b/app/forms/concerns/decidim/extra_user_fields/forms_definitions.rb @@ -11,8 +11,6 @@ module FormsDefinitions included do include ::Decidim::ExtraUserFields::ApplicationHelper - # Block ExtraUserFields Attributes - attribute :country, String attribute :postal_code, String attribute :date_of_birth, Decidim::Attributes::LocalizedDate @@ -23,10 +21,7 @@ module FormsDefinitions attribute :underage, ActiveRecord::Type::Boolean attribute :statutory_representative_email, String attribute :select_fields, Hash, default: {} - - # EndBlock - - # Block ExtraUserFields Validations + attribute :boolean_fields, Array, default: [] validates :country, presence: true, if: :country? validates :postal_code, presence: true, if: :postal_code? @@ -48,8 +43,6 @@ module FormsDefinitions if: :underage_accepted? validate :birth_date_under_limit validate :select_fields_configured - - # EndBlock end def map_model(model) @@ -64,12 +57,12 @@ def map_model(model) self.location = extended_data[:location] self.underage = extended_data[:underage] self.select_fields = extended_data[:select_fields] || {} + self.boolean_fields = extended_data[:boolean_fields] || {} self.statutory_representative_email = extended_data[:statutory_representative_email] end private - # Block ExtraUserFields EnableFieldMethod def country? extra_user_fields_enabled && current_organization.activated_extra_field?(:country) end @@ -116,8 +109,6 @@ def underage_accepted? underage? && underage == "1" end - # EndBlock - def extra_user_fields_enabled @extra_user_fields_enabled ||= current_organization.extra_user_fields_enabled? end diff --git a/app/forms/decidim/extra_user_fields/admin/extra_user_fields_form.rb b/app/forms/decidim/extra_user_fields/admin/extra_user_fields_form.rb index 30c15a3..e274c07 100644 --- a/app/forms/decidim/extra_user_fields/admin/extra_user_fields_form.rb +++ b/app/forms/decidim/extra_user_fields/admin/extra_user_fields_form.rb @@ -21,6 +21,7 @@ class ExtraUserFieldsForm < Decidim::Form translatable_attribute :phone_number_placeholder, String attribute :select_fields, Array, default: [] + attribute :boolean_fields, Array, default: [] def map_model(model) self.enabled = model.extra_user_fields["enabled"] @@ -36,6 +37,7 @@ def map_model(model) self.phone_number_pattern = model.extra_user_fields.dig("phone_number", "pattern") self.phone_number_placeholder = model.extra_user_fields.dig("phone_number", "placeholder") self.select_fields = model.extra_user_fields["select_fields"] || [] + self.boolean_fields = model.extra_user_fields["boolean_fields"] || [] end def select_fields @@ -43,6 +45,12 @@ def select_fields Decidim::ExtraUserFields.select_fields.keys.map(&:to_s).include?(field) end end + + def boolean_fields + super.filter do |field| + Decidim::ExtraUserFields.boolean_fields.map(&:to_s).include?(field) + end + end end end end diff --git a/app/helpers/decidim/extra_user_fields/admin/application_helper.rb b/app/helpers/decidim/extra_user_fields/admin/application_helper.rb index 9657b34..bef51e1 100644 --- a/app/helpers/decidim/extra_user_fields/admin/application_helper.rb +++ b/app/helpers/decidim/extra_user_fields/admin/application_helper.rb @@ -26,6 +26,14 @@ def custom_select_fields(form) form.object.select_fields.include?(field.to_s) end end + + def custom_boolean_fields(form) + return {} unless Decidim::ExtraUserFields.boolean_fields.is_a?(Array) + + Decidim::ExtraUserFields.boolean_fields.index_with do |field| + form.object.boolean_fields.include?(field.to_s) + end + end end end end diff --git a/app/helpers/decidim/extra_user_fields/application_helper.rb b/app/helpers/decidim/extra_user_fields/application_helper.rb index 2b6a989..3d79a7a 100644 --- a/app/helpers/decidim/extra_user_fields/application_helper.rb +++ b/app/helpers/decidim/extra_user_fields/application_helper.rb @@ -26,10 +26,12 @@ def phone_number_extra_user_field_placeholder end def custom_select_fields_options + return {} unless Decidim::ExtraUserFields.select_fields.is_a?(Hash) + Decidim::ExtraUserFields.select_fields.filter_map do |field, options| next unless options.is_a?(Hash) next if options.blank? - next if current_organization.extra_user_field_configuration(:select_fields).include?(field) + next unless current_organization.extra_user_field_configuration(:select_fields).include?(field.to_s) [ field, @@ -40,6 +42,14 @@ def custom_select_fields_options ] end.to_h end + + def custom_boolean_fields + return [] unless Decidim::ExtraUserFields.boolean_fields.is_a?(Array) + + Decidim::ExtraUserFields.boolean_fields.filter do |field| + current_organization.extra_user_field_configuration(:boolean_fields).include?(field.to_s) + end + end end end end diff --git a/app/serializers/decidim/extra_user_fields/user_export_serializer.rb b/app/serializers/decidim/extra_user_fields/user_export_serializer.rb index 006830b..26dcda5 100644 --- a/app/serializers/decidim/extra_user_fields/user_export_serializer.rb +++ b/app/serializers/decidim/extra_user_fields/user_export_serializer.rb @@ -37,6 +37,7 @@ def extra_fields :location, :underage, :select_fields, + :boolean_fields, :statutory_representative_email ] end diff --git a/app/views/decidim/extra_user_fields/_boolean_fields.html.erb b/app/views/decidim/extra_user_fields/_boolean_fields.html.erb new file mode 100644 index 0000000..f5fec82 --- /dev/null +++ b/app/views/decidim/extra_user_fields/_boolean_fields.html.erb @@ -0,0 +1,15 @@ + <% f.object.custom_boolean_fields.each do |field, label| %> +
+ <%= label_tag f.field_id("boolean_fields_#{field}") do %> + <%= check_box_tag "user[boolean_fields][]", + field, + f.object.boolean_fields.map(&:to_s).include?(field.to_s), + id: f.field_id("boolean_fields_#{field}") %> + + <%= t("decidim.extra_user_fields.boolean_fields.#{field}.label", default: field.to_s.humanize) %> + <% if (help = t("decidim.extra_user_fields.boolean_fields.#{field}.description", default: "")).present? %> + <%= help %> + <% end %> + <% end %> +
+ <% end %> diff --git a/app/views/decidim/extra_user_fields/_profile_form.html.erb b/app/views/decidim/extra_user_fields/_profile_form.html.erb index fe07d66..eef8ecc 100644 --- a/app/views/decidim/extra_user_fields/_profile_form.html.erb +++ b/app/views/decidim/extra_user_fields/_profile_form.html.erb @@ -37,4 +37,8 @@ <% if current_organization.activated_extra_field?(:select_fields) %> <%= render partial: "decidim/extra_user_fields/select_fields", locals: { f: f } %> <% end %> + + <% if current_organization.activated_extra_field?(:boolean_fields) %> + <%= render partial: "decidim/extra_user_fields/boolean_fields", locals: { f: f } %> + <% end %> <% end %> diff --git a/app/views/decidim/extra_user_fields/_registration_form.html.erb b/app/views/decidim/extra_user_fields/_registration_form.html.erb index 97b08c8..44aded2 100644 --- a/app/views/decidim/extra_user_fields/_registration_form.html.erb +++ b/app/views/decidim/extra_user_fields/_registration_form.html.erb @@ -54,6 +54,9 @@ <%= render partial: "decidim/extra_user_fields/select_fields", locals: { f: f } %> <% end %> + <% if current_organization.activated_extra_field?(:boolean_fields) %> + <%= render partial: "decidim/extra_user_fields/boolean_fields", locals: { f: f } %> + <% end %> <%= append_javascript_pack_tag "decidim_extra_user_fields.js" %> <%= append_stylesheet_pack_tag "decidim_extra_user_fields_css" %> diff --git a/app/views/decidim/extra_user_fields/admin/extra_user_fields/_form.html.erb b/app/views/decidim/extra_user_fields/admin/extra_user_fields/_form.html.erb index 8b4f6fe..cea3f50 100644 --- a/app/views/decidim/extra_user_fields/admin/extra_user_fields/_form.html.erb +++ b/app/views/decidim/extra_user_fields/admin/extra_user_fields/_form.html.erb @@ -40,6 +40,7 @@ <%= render partial: "decidim/extra_user_fields/admin/extra_user_fields/fields/select_fields", locals: { form: form } %> + <%= render partial: "decidim/extra_user_fields/admin/extra_user_fields/fields/boolean_fields", locals: { form: form } %> diff --git a/app/views/decidim/extra_user_fields/admin/extra_user_fields/fields/_boolean_fields.html.erb b/app/views/decidim/extra_user_fields/admin/extra_user_fields/fields/_boolean_fields.html.erb new file mode 100644 index 0000000..f3713f6 --- /dev/null +++ b/app/views/decidim/extra_user_fields/admin/extra_user_fields/fields/_boolean_fields.html.erb @@ -0,0 +1,15 @@ +<% custom_boolean_fields(form).each do |field, checked| %> +
+
+ <%= label_tag "extra_user_fields_select_field_#{field}" do %> + + <%= check_box_tag "extra_user_fields[boolean_fields][]", + field, + checked, + id: "extra_user_fields_select_field_#{field}" %> + <%= t("decidim.extra_user_fields.admin.extra_user_fields.boolean_fields.#{field}.label", default: field.to_s.humanize ) %> + <%= t("decidim.extra_user_fields.admin.extra_user_fields.boolean_fields.#{field}.description", default: "") %> + <% end %> +
+
+<% end %> diff --git a/config/locales/en.yml b/config/locales/en.yml index bd8edff..0af7206 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -35,6 +35,11 @@ en: exports: users: Participants extra_user_fields: + boolean_fields: + ngo: + description: This field is a Boolean field. User will be able to check + if is a NGO + label: Enable NGO field fields: age_range: description: This field is a list of age ranges. If checked, user will @@ -106,6 +111,9 @@ en: 61_or_more: 61 or older prefer_not_to_say: Prefer not to say up_to_16: 16 or younger + boolean_fields: + ngo: + label: I am a member of a non-governmental organization (NGO) errors: select_fields: The field "%{field}" is not valid. genders: diff --git a/config/locales/fr.yml b/config/locales/fr.yml index 7bab8e8..b25e768 100644 --- a/config/locales/fr.yml +++ b/config/locales/fr.yml @@ -36,6 +36,11 @@ fr: exports: users: Participants extra_user_fields: + boolean_fields: + ngo: + description: Ce champ est un champ booléen. L'utilisateur pourra cocher + s'il représente une ONG. + label: Activer le champ ONG fields: age_range: description: Ce champ est une liste de tranches d'âge. L'utilisateur @@ -108,6 +113,9 @@ fr: 61_or_more: 61 ou plus prefer_not_to_say: Préfère ne pas dire up_to_16: 16 ou moins + boolean_fields: + ngo: + label: Activer le champ ONG errors: select_fields: Le champ "%{field}" n'est pas valide. genders: diff --git a/lib/decidim/extra_user_fields.rb b/lib/decidim/extra_user_fields.rb index 7f3db65..5950b2f 100644 --- a/lib/decidim/extra_user_fields.rb +++ b/lib/decidim/extra_user_fields.rb @@ -34,7 +34,7 @@ module ExtraUserFields ENV.fetch("EXTRA_USER_FIELDS_AGE_RANGES", "up_to_16 17_to_30 31_to_60 61_or_more prefer_not_to_say").split end - # I extra select fields are needed, they can be added here. + # If extra select fields are needed, they can be added as a Hash here. # The key is the field name and the value is a hash with the options. # You can (optionally) add I18n keys for the options (if not the text will be used as it is). # For the user interface, you can defined labels and descriptions for the fields (optionally): @@ -52,5 +52,16 @@ module ExtraUserFields } } end + + # If extra boolean fields are needed, they can be added as an Array here. + # For the user interface, you can defined labels and descriptions for the fields (optionally): + # decidim.extra_user_fields.boolean_fields.field_name.label + # decidim.extra_user_fields.boolean_fields.field_name.description + # For the admin interface, you can defined labels and descriptions for the fields (optionally): + # decidim.extra_user_fields.admin.extra_user_fields.boolean_fields.field_name.label + # decidim.extra_user_fields.admin.extra_user_fields.boolean_fields.field_name.description + config_accessor :boolean_fields do + [:ngo] + end end end diff --git a/spec/commands/decidim/create_omniauth_registration_spec.rb b/spec/commands/decidim/create_omniauth_registration_spec.rb index 61ea0c2..d86a1de 100644 --- a/spec/commands/decidim/create_omniauth_registration_spec.rb +++ b/spec/commands/decidim/create_omniauth_registration_spec.rb @@ -25,6 +25,9 @@ module Comments "participant_type" => "individual" } end + let(:boolean_fields) do + ["ngo"] + end let(:statutory_representative_email) { nil } let(:extended_data) do { @@ -37,6 +40,7 @@ module Comments postal_code:, underage:, select_fields:, + boolean_fields:, statutory_representative_email: } end @@ -61,6 +65,7 @@ module Comments "location" => location, "underage" => underage, "select_fields" => select_fields, + "boolean_fields" => boolean_fields, "statutory_representative_email" => statutory_representative_email } } @@ -132,6 +137,7 @@ module Comments expect(user.extended_data["location"]).to eq(location) expect(user.extended_data["underage"]).to eq(underage) expect(user.extended_data["select_fields"]).to eq(select_fields) + expect(user.extended_data["boolean_fields"]).to eq(boolean_fields) end # NOTE: This is important so that the users who are only diff --git a/spec/commands/decidim/create_registration_spec.rb b/spec/commands/decidim/create_registration_spec.rb index c409cc4..0db36aa 100644 --- a/spec/commands/decidim/create_registration_spec.rb +++ b/spec/commands/decidim/create_registration_spec.rb @@ -28,6 +28,9 @@ module Comments participant_type: "individual" } end + let(:boolean_fields) do + ["ngo"] + end let(:statutory_representative_email) { nil } let(:extended_data) do { @@ -61,6 +64,7 @@ module Comments "location" => location, "underage" => underage, "select_fields" => select_fields, + "boolean_fields" => boolean_fields, "statutory_representative_email" => statutory_representative_email } } @@ -137,6 +141,7 @@ module Comments postal_code:, underage:, select_fields:, + boolean_fields:, statutory_representative_email: } ).and_call_original diff --git a/spec/commands/decidim/extra_user_fields/admin/update_extra_user_fields_spec.rb b/spec/commands/decidim/extra_user_fields/admin/update_extra_user_fields_spec.rb index 4453cf8..c1a02c4 100644 --- a/spec/commands/decidim/extra_user_fields/admin/update_extra_user_fields_spec.rb +++ b/spec/commands/decidim/extra_user_fields/admin/update_extra_user_fields_spec.rb @@ -36,7 +36,8 @@ module Admin "location" => location, "underage" => underage, "underage_limit" => underage_limit, - "select_fields" => %w(participant_type non_existing_field) + "select_fields" => %w(participant_type non_existing_field), + "boolean_fields" => %w(ngo non_existing_field) } end let(:form) do @@ -89,6 +90,7 @@ module Admin expect(extra_user_fields).to include("underage" => { "enabled" => true }) expect(extra_user_fields).to include("underage_limit" => 18) expect(extra_user_fields).to include("select_fields" => ["participant_type"]) + expect(extra_user_fields).to include("boolean_fields" => ["ngo"]) end end end diff --git a/spec/forms/decidim/account_form_spec.rb b/spec/forms/decidim/account_form_spec.rb index fd0615f..d3bbde3 100644 --- a/spec/forms/decidim/account_form_spec.rb +++ b/spec/forms/decidim/account_form_spec.rb @@ -27,6 +27,7 @@ module Decidim location:, underage:, select_fields:, + boolean_fields:, statutory_representative_email: ).with_context( current_organization: organization, @@ -47,7 +48,8 @@ module Decidim "location" => { "enabled" => true }, "underage" => { "enabled" => true }, "underage_limit" => 18, - "select_fields" => ["participant_type"] + "select_fields" => ["participant_type"], + "boolean_fields" => ["ngo"] } end let(:phone_number_pattern) { "^(\\+34)?[0-9 ]{9,12}$" } @@ -75,6 +77,9 @@ module Decidim participant_type: "individual" } end + let(:boolean_fields) do + ["ngo"] + end let(:statutory_representative_email) { nil } context "with correct data" do @@ -107,7 +112,7 @@ module Decidim } end - it "is invalid" do + it "is valid" do expect(subject).to be_valid end end @@ -124,6 +129,16 @@ module Decidim end end + context "with non configured boolean fields" do + let(:boolean_fields) do + [:ngo, :foo] + end + + it "is valid" do + expect(subject).to be_valid + end + end + describe "name" do context "with an empty name" do let(:name) { "" } diff --git a/spec/forms/decidim/omniauth_registration_form_spec.rb b/spec/forms/decidim/omniauth_registration_form_spec.rb index c0758da..9fc7100 100644 --- a/spec/forms/decidim/omniauth_registration_form_spec.rb +++ b/spec/forms/decidim/omniauth_registration_form_spec.rb @@ -31,6 +31,9 @@ module Decidim "participant_type" => "individual" } end + let(:boolean_fields) do + ["ngo"] + end let(:attributes) do { @@ -49,7 +52,8 @@ module Decidim phone_number:, location:, underage:, - select_fields: + select_fields:, + boolean_fields: } end diff --git a/spec/serializers/decidim/extra_user_fields/user_export_serializer_spec.rb b/spec/serializers/decidim/extra_user_fields/user_export_serializer_spec.rb index f18cd3e..ac8a1ac 100644 --- a/spec/serializers/decidim/extra_user_fields/user_export_serializer_spec.rb +++ b/spec/serializers/decidim/extra_user_fields/user_export_serializer_spec.rb @@ -17,6 +17,7 @@ location:, underage:, select_fields:, + boolean_fields:, statutory_representative_email: } end @@ -36,6 +37,9 @@ "participant_type" => "individual" } end + let(:boolean_fields) do + ["ngo"] + end let(:serialized) { subject.serialize } @@ -76,6 +80,10 @@ expect(serialized).to include(select_fields: resource.extended_data["select_fields"]) end + it "includes the boolean fields" do + expect(serialized).to include(boolean_fields: resource.extended_data["boolean_fields"]) + end + context "when users are blocked" do let(:resource) { create(:user, :blocked, extended_data: registration_metadata, blocked_at:) } let(:blocked_at) { Time.zone.now } diff --git a/spec/system/account_spec.rb b/spec/system/account_spec.rb index 23ab8da..ff99285 100644 --- a/spec/system/account_spec.rb +++ b/spec/system/account_spec.rb @@ -20,6 +20,7 @@ "postal_code" => postal_code, "gender" => gender, "select_fields" => select_fields, + "boolean_fields" => boolean_fields, "age_range" => age_range, "country" => country, "phone_number" => phone_number, @@ -60,6 +61,10 @@ ["participant_type"] end + let(:boolean_fields) do + ["ngo"] + end + # Block ExtraUserFields RspecVar # EndBlock @@ -113,6 +118,7 @@ select "17 to 30", from: :user_age_range select "Argentina", from: :user_country select "Individual", from: :user_select_fields_participant_type + check "I am a member of a non-governmental organization (NGO)" fill_in :user_postal_code, with: "00000" fill_in :user_phone_number, with: "0123456789" fill_in :user_location, with: "Cahors" @@ -248,6 +254,14 @@ it_behaves_like "does not display extra user field", "select_fields", "Select fields" end + context "when boolean_fields is not enabled" do + let(:boolean_fields) do + ["another_field"] + end + + it_behaves_like "does not display extra user field", "boolean_fields", "Boolean fields" + end + describe "when update password" do before do within "form.edit_user" do @@ -261,6 +275,7 @@ select "17 to 30", from: :user_age_range select "Argentina", from: :user_country select "Individual", from: :user_select_fields_participant_type + check "I am a member of a non-governmental organization (NGO)" fill_in :user_postal_code, with: "00000" fill_in :user_phone_number, with: "0123456789" fill_in :user_location, with: "Cahors" @@ -323,6 +338,7 @@ select "17 to 30", from: :user_age_range select "Argentina", from: :user_country select "Individual", from: :user_select_fields_participant_type + check "I am a member of a non-governmental organization (NGO)" fill_in :user_postal_code, with: "00000" fill_in :user_phone_number, with: "0123456789" fill_in :user_location, with: "Cahors" diff --git a/spec/system/admin_manages_organization_extra_user_fields_spec.rb b/spec/system/admin_manages_organization_extra_user_fields_spec.rb index 419adf4..5ac8096 100644 --- a/spec/system/admin_manages_organization_extra_user_fields_spec.rb +++ b/spec/system/admin_manages_organization_extra_user_fields_spec.rb @@ -61,6 +61,21 @@ expect(page).to have_content("Extra user fields correctly updated in organization") end end + + context "when custom boolean_fields" do + it "displays the custom boolean fields" do + within "#accordion-setup" do + expect(page).to have_content("Additional custom fields") + expect(page).to have_content("Enable NGO field") + expect(page).to have_content("This field is a Boolean field. User will be able to check if is a NGO") + + page.check("Enable NGO field") + end + + find("*[type=submit]", text: "Save configuration").click + expect(page).to have_content("Extra user fields correctly updated in organization") + end + end end context "and no translations are provided" do @@ -72,9 +87,13 @@ } } end + let(:custom_boolean_fields) do + [:dog_person] + end before do allow(Decidim::ExtraUserFields).to receive(:select_fields).and_return(custom_select_fields) + allow(Decidim::ExtraUserFields).to receive(:boolean_fields).and_return(custom_boolean_fields) visit decidim_extra_user_fields.root_path end @@ -89,5 +108,17 @@ find("*[type=submit]", text: "Save configuration").click expect(page).to have_content("Extra user fields correctly updated in organization") end + + it "displays the custom boolean fields" do + within "#accordion-setup" do + expect(page).to have_content("Additional custom fields") + expect(page).to have_content("Dog person") + + page.check("Dog person") + end + + find("*[type=submit]", text: "Save configuration").click + expect(page).to have_content("Extra user fields correctly updated in organization") + end end end diff --git a/spec/system/registration_spec.rb b/spec/system/registration_spec.rb index dccc1bb..aaa36d1 100644 --- a/spec/system/registration_spec.rb +++ b/spec/system/registration_spec.rb @@ -16,12 +16,10 @@ def fill_extra_user_fields select "17 to 30", from: :registration_user_age_range select "Argentina", from: :registration_user_country select "Individual", from: :registration_user_select_fields_participant_type + check "registration_user_boolean_fields_ngo" fill_in :registration_user_postal_code, with: "00000" fill_in :registration_user_phone_number, with: "0123456789" fill_in :registration_user_location, with: "Cahors" - # Block ExtraUserFields FillExtraUserFields - - # EndBlock end describe "Extra user fields" do # rubocop:disable RSpec/DescribeClass @@ -46,7 +44,8 @@ def fill_extra_user_fields "country" => country, "phone_number" => phone_number, "location" => location, - "select_fields" => select_fields + "select_fields" => select_fields, + "boolean_fields" => boolean_fields } end @@ -83,6 +82,10 @@ def fill_extra_user_fields ["participant_type"] end + let(:boolean_fields) do + ["ngo"] + end + before do switch_to_host(organization.host) visit decidim.new_user_registration_path @@ -98,6 +101,7 @@ def fill_extra_user_fields expect(page).to have_content("Location") expect(page).to have_content("How old are you?") expect(page).to have_content("Are you participating as an individual, or officially on behalf of an organization?") + expect(page).to have_content("I am a member of a non-governmental organization (NGO)") end end @@ -166,6 +170,7 @@ def fill_extra_user_fields expect(page).to have_no_content("Location") expect(page).to have_no_content("Which gender do you identify with?") expect(page).to have_no_content("Are you participating as an individual, or officially on behalf of an organization?") + expect(page).to have_no_content("I am a member of a non-governmental organization (NGO)") end it "allows to create a new account" do From 903e31586477842fb0b84f84adff5fabfb068e33 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ivan=20Verg=C3=A9s?= Date: Tue, 13 May 2025 12:01:37 +0200 Subject: [PATCH 07/10] add custom text fields (#6) * add custom text fields * add custom text fields * readme --- README.md | 27 ++++++++ ...create_registrations_commands_overrides.rb | 1 + .../omniauth_commands_overrides.rb | 1 + .../update_account_commands_overrides.rb | 1 + .../admin/update_extra_user_fields.rb | 3 +- .../extra_user_fields/forms_definitions.rb | 4 +- .../admin/extra_user_fields_form.rb | 8 +++ .../admin/application_helper.rb | 8 +++ .../extra_user_fields/application_helper.rb | 10 +++ .../user_export_serializer.rb | 1 + .../_boolean_fields.html.erb | 26 ++++---- .../extra_user_fields/_profile_form.html.erb | 4 ++ .../_registration_form.html.erb | 5 ++ .../extra_user_fields/_select_fields.html.erb | 24 +++---- .../extra_user_fields/_text_fields.html.erb | 13 ++++ .../admin/extra_user_fields/_form.html.erb | 1 + .../fields/_text_fields.html.erb | 15 +++++ config/locales/en.yml | 8 +++ config/locales/fr.yml | 8 +++ lib/decidim/extra_user_fields.rb | 13 ++++ .../create_omniauth_registration_spec.rb | 8 +++ .../decidim/create_registration_spec.rb | 7 ++ .../admin/update_extra_user_fields_spec.rb | 4 +- spec/forms/decidim/account_form_spec.rb | 22 ++++++- .../omniauth_registration_form_spec.rb | 8 ++- .../user_export_serializer_spec.rb | 10 +++ spec/system/account_spec.rb | 65 ++++++++++++++++++- ...ges_organization_extra_user_fields_spec.rb | 33 ++++++++++ spec/system/registration_spec.rb | 21 +++++- 29 files changed, 326 insertions(+), 33 deletions(-) create mode 100644 app/views/decidim/extra_user_fields/_text_fields.html.erb create mode 100644 app/views/decidim/extra_user_fields/admin/extra_user_fields/fields/_text_fields.html.erb diff --git a/README.md b/README.md index be0db96..14d7856 100644 --- a/README.md +++ b/README.md @@ -101,6 +101,8 @@ Currently, the following ENV variables are supported: If your use case include fields not defined in this module, it is possible to define custom fields of different types: 1. **Select fields** This configuration option allows you to define any number of extra user fields of the type "Select". +2. **Boolean fields** This configuration option allows you to define any number of extra user fields of the type "Boolean". These fields can be used for true/false values, such as "Accept terms and conditions" or "Subscribe to newsletter". +3. **Text fields** This configuration option allows you to define any number of extra user fields of the type "Text". These fields can be used for free-form text input, such as "Hobbies" or "Favorite quote". See the next section "Configuration through an initializer" for more information. @@ -144,6 +146,31 @@ Decidim::ExtraUserFields.configure do |config| } } end + + # If extra boolean fields are needed, they can be added as an Array here. + # For the user interface, you can defined labels and descriptions for the fields (optionally): + # decidim.extra_user_fields.boolean_fields.field_name.label + # decidim.extra_user_fields.boolean_fields.field_name.description + # For the admin interface, you can defined labels and descriptions for the fields (optionally): + # decidim.extra_user_fields.admin.extra_user_fields.boolean_fields.field_name.label + # decidim.extra_user_fields.admin.extra_user_fields.boolean_fields.field_name.description + config_accessor :boolean_fields do + [:ngo, :newsletter] + end + + # If extra text fields are needed, they can be added as a Hash here (key is the field, value whether mandatory or not). + # For the user interface, you can define labels and descriptions for the fields (optionally): + # decidim.extra_user_fields.text_fields.field_name.label + # decidim.extra_user_fields.text_fields.field_name.description + # For the admin interface, you can define labels and descriptions for the fields (optionally): + # decidim.extra_user_fields.admin.extra_user_fields.text_fields.field_name.label + # decidim.extra_user_fields.admin.extra_user_fields.text_fields.field_name.description + config_accessor :text_fields do + { + hobbies: false, + favorite_quote: true + } + end end ``` diff --git a/app/commands/concerns/decidim/extra_user_fields/create_registrations_commands_overrides.rb b/app/commands/concerns/decidim/extra_user_fields/create_registrations_commands_overrides.rb index dba02b2..561a098 100644 --- a/app/commands/concerns/decidim/extra_user_fields/create_registrations_commands_overrides.rb +++ b/app/commands/concerns/decidim/extra_user_fields/create_registrations_commands_overrides.rb @@ -56,6 +56,7 @@ def extended_data underage: form.underage, select_fields: form.select_fields, boolean_fields: form.boolean_fields, + text_fields: form.text_fields, statutory_representative_email: form.statutory_representative_email ) end diff --git a/app/commands/concerns/decidim/extra_user_fields/omniauth_commands_overrides.rb b/app/commands/concerns/decidim/extra_user_fields/omniauth_commands_overrides.rb index 859d895..5755012 100644 --- a/app/commands/concerns/decidim/extra_user_fields/omniauth_commands_overrides.rb +++ b/app/commands/concerns/decidim/extra_user_fields/omniauth_commands_overrides.rb @@ -83,6 +83,7 @@ def extended_data underage: form.underage, select_fields: form.select_fields, boolean_fields: form.boolean_fields, + text_fields: form.text_fields, statutory_representative_email: form.statutory_representative_email ) end diff --git a/app/commands/concerns/decidim/extra_user_fields/update_account_commands_overrides.rb b/app/commands/concerns/decidim/extra_user_fields/update_account_commands_overrides.rb index 3aa1629..ebaa942 100644 --- a/app/commands/concerns/decidim/extra_user_fields/update_account_commands_overrides.rb +++ b/app/commands/concerns/decidim/extra_user_fields/update_account_commands_overrides.rb @@ -32,6 +32,7 @@ def extended_data underage: @form.underage, select_fields: @form.select_fields, boolean_fields: @form.boolean_fields, + text_fields: @form.text_fields, statutory_representative_email: @form.statutory_representative_email ) end diff --git a/app/commands/decidim/extra_user_fields/admin/update_extra_user_fields.rb b/app/commands/decidim/extra_user_fields/admin/update_extra_user_fields.rb index e88eb2e..7cc4e87 100644 --- a/app/commands/decidim/extra_user_fields/admin/update_extra_user_fields.rb +++ b/app/commands/decidim/extra_user_fields/admin/update_extra_user_fields.rb @@ -57,7 +57,8 @@ def extra_user_fields "underage" => { "enabled" => form.underage || false }, "underage_limit" => form.underage_limit || Decidim::ExtraUserFields.underage_limit, "select_fields" => form.select_fields.to_a, - "boolean_fields" => form.boolean_fields.to_a + "boolean_fields" => form.boolean_fields.to_a, + "text_fields" => form.text_fields.to_a } end # rubocop:enable Metrics/CyclomaticComplexity diff --git a/app/forms/concerns/decidim/extra_user_fields/forms_definitions.rb b/app/forms/concerns/decidim/extra_user_fields/forms_definitions.rb index a100ffe..84da508 100644 --- a/app/forms/concerns/decidim/extra_user_fields/forms_definitions.rb +++ b/app/forms/concerns/decidim/extra_user_fields/forms_definitions.rb @@ -22,6 +22,7 @@ module FormsDefinitions attribute :statutory_representative_email, String attribute :select_fields, Hash, default: {} attribute :boolean_fields, Array, default: [] + attribute :text_fields, Hash, default: {} validates :country, presence: true, if: :country? validates :postal_code, presence: true, if: :postal_code? @@ -57,7 +58,8 @@ def map_model(model) self.location = extended_data[:location] self.underage = extended_data[:underage] self.select_fields = extended_data[:select_fields] || {} - self.boolean_fields = extended_data[:boolean_fields] || {} + self.boolean_fields = extended_data[:boolean_fields] || [] + self.text_fields = extended_data[:text_fields] || {} self.statutory_representative_email = extended_data[:statutory_representative_email] end diff --git a/app/forms/decidim/extra_user_fields/admin/extra_user_fields_form.rb b/app/forms/decidim/extra_user_fields/admin/extra_user_fields_form.rb index e274c07..564b889 100644 --- a/app/forms/decidim/extra_user_fields/admin/extra_user_fields_form.rb +++ b/app/forms/decidim/extra_user_fields/admin/extra_user_fields_form.rb @@ -22,6 +22,7 @@ class ExtraUserFieldsForm < Decidim::Form attribute :select_fields, Array, default: [] attribute :boolean_fields, Array, default: [] + attribute :text_fields, Array, default: [] def map_model(model) self.enabled = model.extra_user_fields["enabled"] @@ -38,6 +39,7 @@ def map_model(model) self.phone_number_placeholder = model.extra_user_fields.dig("phone_number", "placeholder") self.select_fields = model.extra_user_fields["select_fields"] || [] self.boolean_fields = model.extra_user_fields["boolean_fields"] || [] + self.text_fields = model.extra_user_fields["text_fields"] || [] end def select_fields @@ -51,6 +53,12 @@ def boolean_fields Decidim::ExtraUserFields.boolean_fields.map(&:to_s).include?(field) end end + + def text_fields + super.filter do |field| + Decidim::ExtraUserFields.text_fields.keys.map(&:to_s).include?(field) + end + end end end end diff --git a/app/helpers/decidim/extra_user_fields/admin/application_helper.rb b/app/helpers/decidim/extra_user_fields/admin/application_helper.rb index bef51e1..91eb1f1 100644 --- a/app/helpers/decidim/extra_user_fields/admin/application_helper.rb +++ b/app/helpers/decidim/extra_user_fields/admin/application_helper.rb @@ -34,6 +34,14 @@ def custom_boolean_fields(form) form.object.boolean_fields.include?(field.to_s) end end + + def custom_text_fields(form) + return {} unless Decidim::ExtraUserFields.text_fields.is_a?(Hash) + + Decidim::ExtraUserFields.text_fields.keys.index_with do |field| + form.object.text_fields.include?(field.to_s) + end + end end end end diff --git a/app/helpers/decidim/extra_user_fields/application_helper.rb b/app/helpers/decidim/extra_user_fields/application_helper.rb index 3d79a7a..d7b9655 100644 --- a/app/helpers/decidim/extra_user_fields/application_helper.rb +++ b/app/helpers/decidim/extra_user_fields/application_helper.rb @@ -50,6 +50,16 @@ def custom_boolean_fields current_organization.extra_user_field_configuration(:boolean_fields).include?(field.to_s) end end + + def custom_text_fields + return [] unless Decidim::ExtraUserFields.text_fields.is_a?(Hash) + + Decidim::ExtraUserFields.text_fields.filter_map do |field, mandatory| + current_organization.extra_user_field_configuration(:text_fields).include?(field.to_s) + + [field, mandatory.present?] + end.to_h + end end end end diff --git a/app/serializers/decidim/extra_user_fields/user_export_serializer.rb b/app/serializers/decidim/extra_user_fields/user_export_serializer.rb index 26dcda5..4a07478 100644 --- a/app/serializers/decidim/extra_user_fields/user_export_serializer.rb +++ b/app/serializers/decidim/extra_user_fields/user_export_serializer.rb @@ -38,6 +38,7 @@ def extra_fields :underage, :select_fields, :boolean_fields, + :text_fields, :statutory_representative_email ] end diff --git a/app/views/decidim/extra_user_fields/_boolean_fields.html.erb b/app/views/decidim/extra_user_fields/_boolean_fields.html.erb index f5fec82..6fd240f 100644 --- a/app/views/decidim/extra_user_fields/_boolean_fields.html.erb +++ b/app/views/decidim/extra_user_fields/_boolean_fields.html.erb @@ -1,15 +1,15 @@ - <% f.object.custom_boolean_fields.each do |field, label| %> -
- <%= label_tag f.field_id("boolean_fields_#{field}") do %> - <%= check_box_tag "user[boolean_fields][]", - field, - f.object.boolean_fields.map(&:to_s).include?(field.to_s), - id: f.field_id("boolean_fields_#{field}") %> +<% f.object.custom_boolean_fields.each do |field, label| %> +
+ <%= label_tag f.field_id("boolean_fields_#{field}") do %> + <%= check_box_tag "user[boolean_fields][]", + field, + f.object.boolean_fields.include?(field), + id: f.field_id("boolean_fields_#{field}") %> - <%= t("decidim.extra_user_fields.boolean_fields.#{field}.label", default: field.to_s.humanize) %> - <% if (help = t("decidim.extra_user_fields.boolean_fields.#{field}.description", default: "")).present? %> - <%= help %> - <% end %> - <% end %> -
+ <%= t("decidim.extra_user_fields.boolean_fields.#{field}.label", default: field.to_s.humanize) %> + <% if (help = t("decidim.extra_user_fields.boolean_fields.#{field}.description", default: "")).present? %> + <%= help %> + <% end %> <% end %> +
+<% end %> diff --git a/app/views/decidim/extra_user_fields/_profile_form.html.erb b/app/views/decidim/extra_user_fields/_profile_form.html.erb index eef8ecc..586b59c 100644 --- a/app/views/decidim/extra_user_fields/_profile_form.html.erb +++ b/app/views/decidim/extra_user_fields/_profile_form.html.erb @@ -41,4 +41,8 @@ <% if current_organization.activated_extra_field?(:boolean_fields) %> <%= render partial: "decidim/extra_user_fields/boolean_fields", locals: { f: f } %> <% end %> + + <% if current_organization.activated_extra_field?(:text_fields) %> + <%= render partial: "decidim/extra_user_fields/text_fields", locals: { f: f } %> + <% end %> <% end %> diff --git a/app/views/decidim/extra_user_fields/_registration_form.html.erb b/app/views/decidim/extra_user_fields/_registration_form.html.erb index 44aded2..11ae57a 100644 --- a/app/views/decidim/extra_user_fields/_registration_form.html.erb +++ b/app/views/decidim/extra_user_fields/_registration_form.html.erb @@ -57,7 +57,12 @@ <% if current_organization.activated_extra_field?(:boolean_fields) %> <%= render partial: "decidim/extra_user_fields/boolean_fields", locals: { f: f } %> <% end %> + + <% if current_organization.activated_extra_field?(:text_fields) %> + <%= render partial: "decidim/extra_user_fields/text_fields", locals: { f: f } %> + <% end %> + <%= append_javascript_pack_tag "decidim_extra_user_fields.js" %> <%= append_stylesheet_pack_tag "decidim_extra_user_fields_css" %> <% end %> diff --git a/app/views/decidim/extra_user_fields/_select_fields.html.erb b/app/views/decidim/extra_user_fields/_select_fields.html.erb index 489dafe..e96e681 100644 --- a/app/views/decidim/extra_user_fields/_select_fields.html.erb +++ b/app/views/decidim/extra_user_fields/_select_fields.html.erb @@ -1,14 +1,14 @@ - <% f.object.custom_select_fields_options.each do |field, options| %> -
- <%= label_tag f.field_id("select_fields_#{field}") do %> - <%= t("decidim.extra_user_fields.select_fields.#{field}.label", default: field.to_s.humanize) %> - <% if (help = t("decidim.extra_user_fields.select_fields.#{field}.description", default: "")).present? %> - <%= help %> - <% end %> +<% f.object.custom_select_fields_options.each do |field, options| %> +
+ <%= label_tag f.field_id("select_fields_#{field}") do %> + <%= t("decidim.extra_user_fields.select_fields.#{field}.label", default: field.to_s.humanize) %> + <% if (help = t("decidim.extra_user_fields.select_fields.#{field}.description", default: "")).present? %> + <%= help %> + <% end %> - <%= select_tag "user[select_fields][#{field}]", - options_for_select(options, f.object.select_fields[field]), - id: f.field_id("select_fields_#{field}") %> - <% end %> -
+ <%= select_tag "user[select_fields][#{field}]", + options_for_select(options, f.object.select_fields[field]), + id: f.field_id("select_fields_#{field}") %> <% end %> +
+<% end %> diff --git a/app/views/decidim/extra_user_fields/_text_fields.html.erb b/app/views/decidim/extra_user_fields/_text_fields.html.erb new file mode 100644 index 0000000..e9e604b --- /dev/null +++ b/app/views/decidim/extra_user_fields/_text_fields.html.erb @@ -0,0 +1,13 @@ +<% f.object.custom_text_fields.each do |field, required| %> +
+ <%= f.text_field :text_fields, name: "user[text_fields][#{field}]", + value: f.object.text_fields[field], + label: t("decidim.extra_user_fields.text_fields.#{field}.label", default: field.to_s.humanize), + help_text: t("decidim.extra_user_fields.text_fields.#{field}.description", default: nil), + id: f.field_id("text_fields_#{field}"), + label_options: { + for: f.field_id("text_fields_#{field}"), + }, + required: %> +
+<% end %> diff --git a/app/views/decidim/extra_user_fields/admin/extra_user_fields/_form.html.erb b/app/views/decidim/extra_user_fields/admin/extra_user_fields/_form.html.erb index cea3f50..a345e27 100644 --- a/app/views/decidim/extra_user_fields/admin/extra_user_fields/_form.html.erb +++ b/app/views/decidim/extra_user_fields/admin/extra_user_fields/_form.html.erb @@ -41,6 +41,7 @@ <%= render partial: "decidim/extra_user_fields/admin/extra_user_fields/fields/select_fields", locals: { form: form } %> <%= render partial: "decidim/extra_user_fields/admin/extra_user_fields/fields/boolean_fields", locals: { form: form } %> + <%= render partial: "decidim/extra_user_fields/admin/extra_user_fields/fields/text_fields", locals: { form: form } %> diff --git a/app/views/decidim/extra_user_fields/admin/extra_user_fields/fields/_text_fields.html.erb b/app/views/decidim/extra_user_fields/admin/extra_user_fields/fields/_text_fields.html.erb new file mode 100644 index 0000000..74b5d23 --- /dev/null +++ b/app/views/decidim/extra_user_fields/admin/extra_user_fields/fields/_text_fields.html.erb @@ -0,0 +1,15 @@ +<% custom_text_fields(form).each do |field, checked| %> +
+
+ <%= label_tag "extra_user_fields_select_field_#{field}" do %> + + <%= check_box_tag "extra_user_fields[text_fields][]", + field, + checked, + id: "extra_user_fields_select_field_#{field}" %> + <%= t("decidim.extra_user_fields.admin.extra_user_fields.text_fields.#{field}.label", default: field.to_s.humanize ) %> + <%= t("decidim.extra_user_fields.admin.extra_user_fields.text_fields.#{field}.description", default: "") %> + <% end %> +
+
+<% end %> diff --git a/config/locales/en.yml b/config/locales/en.yml index 0af7206..4390e29 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -102,6 +102,11 @@ en: description: This field is a list of participant types. If checked, user will have to choose a participant type label: Enable participant type field + text_fields: + motto: + description: This field is a String field. If checked, user can fill + in a personal phrase or motto + label: Enable "My Motto" field update: failure: An error occurred on update success: Extra user fields correctly updated in organization @@ -129,6 +134,9 @@ en: participant_type: label: Are you participating as an individual, or officially on behalf of an organization? + text_fields: + motto: + label: What is your motto? statutory_representative: inform: body: | diff --git a/config/locales/fr.yml b/config/locales/fr.yml index b25e768..32842e0 100644 --- a/config/locales/fr.yml +++ b/config/locales/fr.yml @@ -104,6 +104,11 @@ fr: description: Ce champ est une liste de types de participants. L'utilisateur devra choisir un type de participant. label: Activer le champ type de participant + text_fields: + motto: + description: Ce champ permet l'ajout de texte. L'utilisateur pourra + choisir un slogan. + label: Activer le champ slogan update: failure: Une erreur est survenue lors de la mise à jour success: Les champs d'inscription ont été mis à jour avec succ§s @@ -131,6 +136,9 @@ fr: select_fields: participant_type: label: Activer le champ type de participant + text_fields: + motto: + label: Activer le champ "Mon slogan" statutory_representative: inform: body: | diff --git a/lib/decidim/extra_user_fields.rb b/lib/decidim/extra_user_fields.rb index 5950b2f..022dc46 100644 --- a/lib/decidim/extra_user_fields.rb +++ b/lib/decidim/extra_user_fields.rb @@ -63,5 +63,18 @@ module ExtraUserFields config_accessor :boolean_fields do [:ngo] end + + # If extra text fields are needed, they can be added as a Hash here (key is the field, value whether mandatory or not). + # For the user interface, you can defined labels and descriptions for the fields (optionally): + # decidim.extra_user_fields.text_fields.field_name.label + # decidim.extra_user_fields.text_fields.field_name.description + # For the admin interface, you can defined labels and descriptions for the fields (optionally): + # decidim.extra_user_fields.admin.extra_user_fields.text_fields.field_name.label + # decidim.extra_user_fields.admin.extra_user_fields.text_fields.field_name.description + config_accessor :text_fields do + { + motto: false + } + end end end diff --git a/spec/commands/decidim/create_omniauth_registration_spec.rb b/spec/commands/decidim/create_omniauth_registration_spec.rb index d86a1de..dd9366c 100644 --- a/spec/commands/decidim/create_omniauth_registration_spec.rb +++ b/spec/commands/decidim/create_omniauth_registration_spec.rb @@ -28,6 +28,11 @@ module Comments let(:boolean_fields) do ["ngo"] end + let(:text_fields) do + { + "motto" => "I think, therefore I am" + } + end let(:statutory_representative_email) { nil } let(:extended_data) do { @@ -41,6 +46,7 @@ module Comments underage:, select_fields:, boolean_fields:, + text_fields:, statutory_representative_email: } end @@ -66,6 +72,7 @@ module Comments "underage" => underage, "select_fields" => select_fields, "boolean_fields" => boolean_fields, + "text_fields" => text_fields, "statutory_representative_email" => statutory_representative_email } } @@ -138,6 +145,7 @@ module Comments expect(user.extended_data["underage"]).to eq(underage) expect(user.extended_data["select_fields"]).to eq(select_fields) expect(user.extended_data["boolean_fields"]).to eq(boolean_fields) + expect(user.extended_data["text_fields"]).to eq(text_fields) end # NOTE: This is important so that the users who are only diff --git a/spec/commands/decidim/create_registration_spec.rb b/spec/commands/decidim/create_registration_spec.rb index 0db36aa..3fdbcb2 100644 --- a/spec/commands/decidim/create_registration_spec.rb +++ b/spec/commands/decidim/create_registration_spec.rb @@ -31,6 +31,11 @@ module Comments let(:boolean_fields) do ["ngo"] end + let(:text_fields) do + { + motto: "I think, therefore I am" + } + end let(:statutory_representative_email) { nil } let(:extended_data) do { @@ -65,6 +70,7 @@ module Comments "underage" => underage, "select_fields" => select_fields, "boolean_fields" => boolean_fields, + "text_fields" => text_fields, "statutory_representative_email" => statutory_representative_email } } @@ -142,6 +148,7 @@ module Comments underage:, select_fields:, boolean_fields:, + text_fields:, statutory_representative_email: } ).and_call_original diff --git a/spec/commands/decidim/extra_user_fields/admin/update_extra_user_fields_spec.rb b/spec/commands/decidim/extra_user_fields/admin/update_extra_user_fields_spec.rb index c1a02c4..72b4e5b 100644 --- a/spec/commands/decidim/extra_user_fields/admin/update_extra_user_fields_spec.rb +++ b/spec/commands/decidim/extra_user_fields/admin/update_extra_user_fields_spec.rb @@ -37,7 +37,8 @@ module Admin "underage" => underage, "underage_limit" => underage_limit, "select_fields" => %w(participant_type non_existing_field), - "boolean_fields" => %w(ngo non_existing_field) + "boolean_fields" => %w(ngo non_existing_field), + "text_fields" => %w(motto non_existing_field) } end let(:form) do @@ -91,6 +92,7 @@ module Admin expect(extra_user_fields).to include("underage_limit" => 18) expect(extra_user_fields).to include("select_fields" => ["participant_type"]) expect(extra_user_fields).to include("boolean_fields" => ["ngo"]) + expect(extra_user_fields).to include("text_fields" => ["motto"]) end end end diff --git a/spec/forms/decidim/account_form_spec.rb b/spec/forms/decidim/account_form_spec.rb index d3bbde3..799b039 100644 --- a/spec/forms/decidim/account_form_spec.rb +++ b/spec/forms/decidim/account_form_spec.rb @@ -28,6 +28,7 @@ module Decidim underage:, select_fields:, boolean_fields:, + text_fields:, statutory_representative_email: ).with_context( current_organization: organization, @@ -49,7 +50,8 @@ module Decidim "underage" => { "enabled" => true }, "underage_limit" => 18, "select_fields" => ["participant_type"], - "boolean_fields" => ["ngo"] + "boolean_fields" => ["ngo"], + "text_fields" => ["motto"] } end let(:phone_number_pattern) { "^(\\+34)?[0-9 ]{9,12}$" } @@ -80,6 +82,11 @@ module Decidim let(:boolean_fields) do ["ngo"] end + let(:text_fields) do + { + motto: false + } + end let(:statutory_representative_email) { nil } context "with correct data" do @@ -139,6 +146,19 @@ module Decidim end end + context "with non configured text fields" do + let(:text_fields) do + { + motto: false, + foo: true + } + end + + it "is valid" do + expect(subject).to be_valid + end + end + describe "name" do context "with an empty name" do let(:name) { "" } diff --git a/spec/forms/decidim/omniauth_registration_form_spec.rb b/spec/forms/decidim/omniauth_registration_form_spec.rb index 9fc7100..9650070 100644 --- a/spec/forms/decidim/omniauth_registration_form_spec.rb +++ b/spec/forms/decidim/omniauth_registration_form_spec.rb @@ -34,6 +34,11 @@ module Decidim let(:boolean_fields) do ["ngo"] end + let(:text_fields) do + { + "motto" => false + } + end let(:attributes) do { @@ -53,7 +58,8 @@ module Decidim location:, underage:, select_fields:, - boolean_fields: + boolean_fields:, + text_fields: } end diff --git a/spec/serializers/decidim/extra_user_fields/user_export_serializer_spec.rb b/spec/serializers/decidim/extra_user_fields/user_export_serializer_spec.rb index ac8a1ac..7864323 100644 --- a/spec/serializers/decidim/extra_user_fields/user_export_serializer_spec.rb +++ b/spec/serializers/decidim/extra_user_fields/user_export_serializer_spec.rb @@ -18,6 +18,7 @@ underage:, select_fields:, boolean_fields:, + text_fields:, statutory_representative_email: } end @@ -40,6 +41,11 @@ let(:boolean_fields) do ["ngo"] end + let(:text_fields) do + { + "motto" => "I think, therefore I am" + } + end let(:serialized) { subject.serialize } @@ -84,6 +90,10 @@ expect(serialized).to include(boolean_fields: resource.extended_data["boolean_fields"]) end + it "includes the text fields" do + expect(serialized).to include(text_fields: resource.extended_data["text_fields"]) + end + context "when users are blocked" do let(:resource) { create(:user, :blocked, extended_data: registration_metadata, blocked_at:) } let(:blocked_at) { Time.zone.now } diff --git a/spec/system/account_spec.rb b/spec/system/account_spec.rb index ff99285..54da721 100644 --- a/spec/system/account_spec.rb +++ b/spec/system/account_spec.rb @@ -21,6 +21,7 @@ "gender" => gender, "select_fields" => select_fields, "boolean_fields" => boolean_fields, + "text_fields" => text_fields, "age_range" => age_range, "country" => country, "phone_number" => phone_number, @@ -65,11 +66,18 @@ ["ngo"] end - # Block ExtraUserFields RspecVar + let(:text_fields) do + ["motto"] + end - # EndBlock + let(:enabled_text_fields) do + { + motto: false + } + end before do + allow(Decidim::ExtraUserFields).to receive(:text_fields).and_return(enabled_text_fields) switch_to_host(organization.host) login_as user, scope: :user end @@ -105,6 +113,7 @@ describe "updating personal data" do let!(:encrypted_password) { user.encrypted_password } + let(:motto) { "I think, therefore I am." } before do within "form.edit_user" do @@ -119,6 +128,7 @@ select "Argentina", from: :user_country select "Individual", from: :user_select_fields_participant_type check "I am a member of a non-governmental organization (NGO)" + fill_in :user_text_fields_motto, with: motto fill_in :user_postal_code, with: "00000" fill_in :user_phone_number, with: "0123456789" fill_in :user_location, with: "Cahors" @@ -131,6 +141,10 @@ expect(page).to have_content("successfully") end + expect(page).to have_field(with: "Nikola Tesla") + expect(page).to have_field(with: "I think, therefore I am.") + expect(page).to have_select(selected: "Individual") + user.reload within_user_menu do @@ -139,6 +153,8 @@ expect(page).to have_content("example.org") expect(page).to have_content("Serbian-American") + expect(page).to have_content("Nikola Tesla") + expect(page).to have_content("A Serbian-American inventor, electrical engineer, mechanical engineer, physicist, and futurist.") # The user's password should not change when they did not update it expect(user.reload.encrypted_password).to eq(encrypted_password) @@ -188,6 +204,41 @@ end end end + + context "with text field blank" do + let(:motto) { "" } + + it "does not update the user's data" do + within_flash_messages do + expect(page).to have_content("successfully") + end + + expect(page).to have_field(with: "Nikola Tesla") + expect(page).to have_no_field(with: "I think, therefore I am.") + expect(page).to have_select(selected: "Individual") + end + + context "with text field mandatory" do + let(:enabled_text_fields) do + { + motto: true + } + end + + it "displays the field as mandatory" do + within "label[for='user_text_fields_motto']" do + expect(page).to have_css("span.label-required") + end + within "form.edit_user" do + fill_in :user_text_fields_motto, with: "" + find("*[type=submit]").click + end + within "label[for='user_text_fields_motto']" do + expect(page).to have_content("There is an error in this field.") + end + end + end + end end context "when date_of_birth is not enabled" do @@ -262,6 +313,14 @@ it_behaves_like "does not display extra user field", "boolean_fields", "Boolean fields" end + context "when text_fields is not enabled" do + let(:text_fields) do + ["another_field"] + end + + it_behaves_like "does not display extra user field", "text_fields", "Text fields" + end + describe "when update password" do before do within "form.edit_user" do @@ -276,6 +335,7 @@ select "Argentina", from: :user_country select "Individual", from: :user_select_fields_participant_type check "I am a member of a non-governmental organization (NGO)" + fill_in :user_text_fields_motto, with: "I think, therefore I am." fill_in :user_postal_code, with: "00000" fill_in :user_phone_number, with: "0123456789" fill_in :user_location, with: "Cahors" @@ -339,6 +399,7 @@ select "Argentina", from: :user_country select "Individual", from: :user_select_fields_participant_type check "I am a member of a non-governmental organization (NGO)" + fill_in :user_text_fields_motto, with: "I think, therefore I am." fill_in :user_postal_code, with: "00000" fill_in :user_phone_number, with: "0123456789" fill_in :user_location, with: "Cahors" diff --git a/spec/system/admin_manages_organization_extra_user_fields_spec.rb b/spec/system/admin_manages_organization_extra_user_fields_spec.rb index 5ac8096..87d4cf6 100644 --- a/spec/system/admin_manages_organization_extra_user_fields_spec.rb +++ b/spec/system/admin_manages_organization_extra_user_fields_spec.rb @@ -76,6 +76,21 @@ expect(page).to have_content("Extra user fields correctly updated in organization") end end + + context "when custom text_fields" do + it "displays the custom text fields" do + within "#accordion-setup" do + expect(page).to have_content("Additional custom fields") + expect(page).to have_content("Enable \"My Motto\" field") + expect(page).to have_content("This field is a String field. If checked, user can fill in a personal phrase or motto") + + page.check("Enable \"My Motto\" field") + end + + find("*[type=submit]", text: "Save configuration").click + expect(page).to have_content("Extra user fields correctly updated in organization") + end + end end context "and no translations are provided" do @@ -90,10 +105,16 @@ let(:custom_boolean_fields) do [:dog_person] end + let(:custom_text_fields) do + { + pet_name: false + } + end before do allow(Decidim::ExtraUserFields).to receive(:select_fields).and_return(custom_select_fields) allow(Decidim::ExtraUserFields).to receive(:boolean_fields).and_return(custom_boolean_fields) + allow(Decidim::ExtraUserFields).to receive(:text_fields).and_return(custom_text_fields) visit decidim_extra_user_fields.root_path end @@ -120,5 +141,17 @@ find("*[type=submit]", text: "Save configuration").click expect(page).to have_content("Extra user fields correctly updated in organization") end + + it "displays the custom text fields" do + within "#accordion-setup" do + expect(page).to have_content("Additional custom fields") + expect(page).to have_content("Pet name") + + page.check("Pet name") + end + + find("*[type=submit]", text: "Save configuration").click + expect(page).to have_content("Extra user fields correctly updated in organization") + end end end diff --git a/spec/system/registration_spec.rb b/spec/system/registration_spec.rb index aaa36d1..81e8c3b 100644 --- a/spec/system/registration_spec.rb +++ b/spec/system/registration_spec.rb @@ -17,6 +17,7 @@ def fill_extra_user_fields select "Argentina", from: :registration_user_country select "Individual", from: :registration_user_select_fields_participant_type check "registration_user_boolean_fields_ngo" + fill_in :registration_registration_user_text_fields_motto, with: "I think, therefore I am." fill_in :registration_user_postal_code, with: "00000" fill_in :registration_user_phone_number, with: "0123456789" fill_in :registration_user_location, with: "Cahors" @@ -45,7 +46,8 @@ def fill_extra_user_fields "phone_number" => phone_number, "location" => location, "select_fields" => select_fields, - "boolean_fields" => boolean_fields + "boolean_fields" => boolean_fields, + "text_fields" => text_fields } end @@ -86,6 +88,10 @@ def fill_extra_user_fields ["ngo"] end + let(:text_fields) do + ["motto"] + end + before do switch_to_host(organization.host) visit decidim.new_user_registration_path @@ -102,6 +108,7 @@ def fill_extra_user_fields expect(page).to have_content("How old are you?") expect(page).to have_content("Are you participating as an individual, or officially on behalf of an organization?") expect(page).to have_content("I am a member of a non-governmental organization (NGO)") + expect(page).to have_content("What is your motto?") end end @@ -114,6 +121,18 @@ def fill_extra_user_fields end expect(page).to have_content("message with a confirmation link has been sent") + + extended_data = Decidim::User.unscoped.last.extended_data + expect(extended_data["text_fields"]["motto"]).to eq("I think, therefore I am.") + expect(extended_data["boolean_fields"]).to eq(["ngo"]) + expect(extended_data["select_fields"]["participant_type"]).to eq("individual") + expect(extended_data["date_of_birth"]).to eq("2000-01-01") + expect(extended_data["gender"]).to eq("other") + expect(extended_data["age_range"]).to eq("17_to_30") + expect(extended_data["country"]).to eq("AR") + expect(extended_data["postal_code"]).to eq("00000") + expect(extended_data["phone_number"]).to eq("0123456789") + expect(extended_data["location"]).to eq("Cahors") end context "with phone number pattern blank" do From c031904b921085775287f8c13a26a0a19e5e2e65 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ivan=20Verg=C3=A9s?= Date: Mon, 16 Jun 2025 11:17:46 +0200 Subject: [PATCH 08/10] allow proc (#7) * allow proc * change context * add example --- README.md | 4 +++- .../decidim/extra_user_fields/application_helper.rb | 13 ++++++++----- .../extra_user_fields/_select_fields.html.erb | 3 ++- 3 files changed, 13 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 14d7856..6948624 100644 --- a/README.md +++ b/README.md @@ -143,7 +143,9 @@ Decidim::ExtraUserFields.configure do |config| favorite_pet: { "cat" => "my_app.favorite_pets.cat". "dog" => "my_app.favorite_pets.dog" - } + }, + # It is also possible to specify a proc/lambda that returns a suitable list for the select: + organization_country: ->(form) { ISO3166::Country.translations(form.locale).invert }, } end diff --git a/app/helpers/decidim/extra_user_fields/application_helper.rb b/app/helpers/decidim/extra_user_fields/application_helper.rb index d7b9655..f585990 100644 --- a/app/helpers/decidim/extra_user_fields/application_helper.rb +++ b/app/helpers/decidim/extra_user_fields/application_helper.rb @@ -29,20 +29,23 @@ def custom_select_fields_options return {} unless Decidim::ExtraUserFields.select_fields.is_a?(Hash) Decidim::ExtraUserFields.select_fields.filter_map do |field, options| - next unless options.is_a?(Hash) next if options.blank? next unless current_organization.extra_user_field_configuration(:select_fields).include?(field.to_s) [ field, - options.map do |option, label| - label = I18n.t(label, default: label.split(".").last.to_s.humanize) if label.present? - [label, option] - end + options.is_a?(Hash) ? map_options(options) : options ] end.to_h end + def map_options(options) + options.map do |option, label| + label = I18n.t(label, default: label.split(".").last.to_s.humanize) if label.present? + [label, option] + end + end + def custom_boolean_fields return [] unless Decidim::ExtraUserFields.boolean_fields.is_a?(Array) diff --git a/app/views/decidim/extra_user_fields/_select_fields.html.erb b/app/views/decidim/extra_user_fields/_select_fields.html.erb index e96e681..1fd8651 100644 --- a/app/views/decidim/extra_user_fields/_select_fields.html.erb +++ b/app/views/decidim/extra_user_fields/_select_fields.html.erb @@ -7,7 +7,8 @@ <% end %> <%= select_tag "user[select_fields][#{field}]", - options_for_select(options, f.object.select_fields[field]), + options_for_select(options.respond_to?(:call) ? options.call(self) : options, + f.object.select_fields[field]), id: f.field_id("select_fields_#{field}") %> <% end %> From 026117c63055f62edb6c5de0af8256c4ff0fee8e Mon Sep 17 00:00:00 2001 From: Anna Topalidi <60363870+antopalidi@users.noreply.github.com> Date: Tue, 9 Dec 2025 11:12:21 +0100 Subject: [PATCH 09/10] Upgrade decidim to 0.30 (#8) * upgrade versions * fix deface devise, fix tests * remove files * change chrome version * normalizelocales * fix pattern type --- .github/workflows/build_app.yml | 2 +- .github/workflows/ci_tests.yml | 2 +- .github/workflows/test_app.yml | 4 +- .ruby-version | 2 +- Gemfile | 2 +- Gemfile.lock | 466 ++++++++++-------- Rakefile | 6 +- .../omniauth_commands_overrides.rb | 7 +- .../admin/export_participants_job.rb | 5 +- .../new/extra_user_fields.html.erb.deface | 2 +- .../extra_user_fields/_profile_form.html.erb | 2 +- .../_registration_form.html.erb | 2 +- decidim-extra_user_fields.gemspec | 2 +- .../extra_user_fields/form_builder_methods.rb | 13 + lib/decidim/extra_user_fields/version.rb | 4 +- .../create_omniauth_registration_spec.rb | 9 +- .../admin/export_participants_job_spec.rb | 26 +- spec/lib/overrides_spec.rb | 10 +- spec/system/account_spec.rb | 43 +- 19 files changed, 311 insertions(+), 298 deletions(-) diff --git a/.github/workflows/build_app.yml b/.github/workflows/build_app.yml index f7ca3a7..0fcb708 100644 --- a/.github/workflows/build_app.yml +++ b/.github/workflows/build_app.yml @@ -3,7 +3,7 @@ on: inputs: ruby_version: description: 'Ruby Version' - default: "3.2.6" + default: "3.3.4" type: string required: false node_version: diff --git a/.github/workflows/ci_tests.yml b/.github/workflows/ci_tests.yml index 7745fa8..a673f0b 100644 --- a/.github/workflows/ci_tests.yml +++ b/.github/workflows/ci_tests.yml @@ -15,7 +15,7 @@ on: env: CI: "true" - RUBY_VERSION: 3.2.6 + RUBY_VERSION: 3.3.4 NODE_VERSION: 18.17.1 concurrency: diff --git a/.github/workflows/test_app.yml b/.github/workflows/test_app.yml index 1b9e5cf..520033b 100644 --- a/.github/workflows/test_app.yml +++ b/.github/workflows/test_app.yml @@ -3,7 +3,7 @@ on: inputs: ruby_version: description: 'Ruby Version' - default: "3.2.6" + default: "3.3.4" required: false type: string test_command: @@ -13,7 +13,7 @@ on: chrome_version: description: 'Chrome & Chromedriver version' required: false - default: "126.0.6478.182" + default: "139.0.7258.66" type: string jobs: diff --git a/.ruby-version b/.ruby-version index 34cde56..a0891f5 100644 --- a/.ruby-version +++ b/.ruby-version @@ -1 +1 @@ -3.2.6 +3.3.4 diff --git a/Gemfile b/Gemfile index 0ca8b63..679f907 100644 --- a/Gemfile +++ b/Gemfile @@ -1,6 +1,6 @@ # frozen_string_literal: true -DECIDIM_VERSION = "~> 0.29.2" +DECIDIM_VERSION = "~> 0.30.1" source "https://rubygems.org" diff --git a/Gemfile.lock b/Gemfile.lock index 8c69f55..c0e6dca 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,9 +1,9 @@ PATH remote: . specs: - decidim-extra_user_fields (0.29.0) + decidim-extra_user_fields (0.30.0) country_select (~> 4.0) - decidim-core (>= 0.29) + decidim-core (>= 0.30) deface (~> 1.5) GEM @@ -82,9 +82,9 @@ GEM activesupport (>= 6.1) addressable (2.8.7) public_suffix (>= 2.0.2, < 7.0) - ast (2.4.2) - base64 (0.2.0) - batch-loader (1.5.0) + ast (2.4.3) + base64 (0.3.0) + batch-loader (2.0.5) bcrypt (3.1.20) better_html (2.1.1) actionview (>= 6.0) @@ -93,13 +93,13 @@ GEM erubi (~> 1.4) parser (>= 2.4) smart_properties - bigdecimal (3.1.9) + bigdecimal (3.2.2) bindex (0.8.1) bootsnap (1.18.3) msgpack (~> 1.2) - browser (2.7.1) + browser (6.2.0) builder (3.3.0) - bullet (7.1.6) + bullet (8.0.8) activesupport (>= 3.0.0) uniform_notifier (~> 1.11) byebug (11.1.3) @@ -124,8 +124,10 @@ GEM actionpack (>= 5.0) cells (>= 4.1.6, < 5.0.0) charlock_holmes (0.7.9) + chartkick (5.1.5) childprocess (5.1.0) logger (~> 1.5) + cmdparse (3.0.7) commonmarker (0.23.11) concurrent-ruby (1.3.4) countries (3.1.0) @@ -141,124 +143,129 @@ GEM crass (1.0.6) css_parser (1.21.1) addressable - csv (3.3.3) - dartsass (1.49.8) + csv (3.3.5) date (3.4.1) date_validator (0.12.0) activemodel (>= 3) activesupport (>= 3) - decidim (0.29.2) - decidim-accountability (= 0.29.2) - decidim-admin (= 0.29.2) - decidim-api (= 0.29.2) - decidim-assemblies (= 0.29.2) - decidim-blogs (= 0.29.2) - decidim-budgets (= 0.29.2) - decidim-comments (= 0.29.2) - decidim-core (= 0.29.2) - decidim-debates (= 0.29.2) - decidim-forms (= 0.29.2) - decidim-generators (= 0.29.2) - decidim-meetings (= 0.29.2) - decidim-pages (= 0.29.2) - decidim-participatory_processes (= 0.29.2) - decidim-proposals (= 0.29.2) - decidim-sortitions (= 0.29.2) - decidim-surveys (= 0.29.2) - decidim-system (= 0.29.2) - decidim-verifications (= 0.29.2) - decidim-accountability (0.29.2) - decidim-comments (= 0.29.2) - decidim-core (= 0.29.2) - decidim-admin (0.29.2) + decidim (0.30.1) + decidim-accountability (= 0.30.1) + decidim-admin (= 0.30.1) + decidim-api (= 0.30.1) + decidim-assemblies (= 0.30.1) + decidim-blogs (= 0.30.1) + decidim-budgets (= 0.30.1) + decidim-comments (= 0.30.1) + decidim-core (= 0.30.1) + decidim-debates (= 0.30.1) + decidim-forms (= 0.30.1) + decidim-generators (= 0.30.1) + decidim-meetings (= 0.30.1) + decidim-pages (= 0.30.1) + decidim-participatory_processes (= 0.30.1) + decidim-proposals (= 0.30.1) + decidim-sortitions (= 0.30.1) + decidim-surveys (= 0.30.1) + decidim-system (= 0.30.1) + decidim-verifications (= 0.30.1) + decidim-accountability (0.30.1) + decidim-comments (= 0.30.1) + decidim-core (= 0.30.1) + decidim-admin (0.30.1) active_link_to (~> 1.0) - decidim-core (= 0.29.2) + decidim-core (= 0.30.1) devise (~> 4.7) devise-i18n (~> 1.2) devise_invitable (~> 2.0, >= 2.0.9) - decidim-api (0.29.2) - decidim-core (= 0.29.2) - graphql (~> 2.2.6) - graphql-docs (~> 4.0) + decidim-api (0.30.1) + decidim-core (= 0.30.1) + graphql (~> 2.4.0) + graphql-docs (~> 5.0) rack-cors (~> 1.0) - decidim-assemblies (0.29.2) - decidim-core (= 0.29.2) - decidim-blogs (0.29.2) - decidim-admin (= 0.29.2) - decidim-comments (= 0.29.2) - decidim-core (= 0.29.2) - decidim-budgets (0.29.2) - decidim-comments (= 0.29.2) - decidim-core (= 0.29.2) - decidim-comments (0.29.2) - decidim-core (= 0.29.2) + decidim-assemblies (0.30.1) + decidim-core (= 0.30.1) + decidim-blogs (0.30.1) + decidim-admin (= 0.30.1) + decidim-comments (= 0.30.1) + decidim-core (= 0.30.1) + decidim-budgets (0.30.1) + decidim-comments (= 0.30.1) + decidim-core (= 0.30.1) + decidim-comments (0.30.1) + decidim-core (= 0.30.1) redcarpet (~> 3.5, >= 3.5.1) - decidim-core (0.29.2) + decidim-core (0.30.1) active_link_to (~> 1.0) acts_as_list (~> 1.0) - batch-loader (~> 1.2) - browser (~> 2.7) + batch-loader (~> 2.0) + browser (~> 6.2.0) cells-erb (~> 0.1.0) cells-rails (~> 0.1.3) charlock_holmes (~> 0.7) + chartkick (~> 5.1.2) concurrent-ruby (= 1.3.4) date_validator (~> 0.12.0) devise (~> 4.7) - devise-i18n (~> 1.2, < 1.11.1) + devise-i18n (~> 1.2) diffy (~> 3.3) doorkeeper (~> 5.6, >= 5.6.6) doorkeeper-i18n (~> 4.0) file_validators (~> 3.0) fog-local (~> 0.6) - foundation_rails_helper (~> 4.0) geocoder (~> 1.8) hashdiff (>= 0.4.0, < 2.0.0) + hexapdf (~> 1.1.0) image_processing (~> 1.2) invisible_captcha (~> 0.12) kaminari (~> 1.2, >= 1.2.1) loofah (~> 2.19, >= 2.19.1) mime-types (>= 1.16, < 4.0) mini_magick (~> 4.9) - net-smtp (~> 0.3.1) + net-smtp (~> 0.5.0) nokogiri (~> 1.16, >= 1.16.2) omniauth (~> 2.0) omniauth-facebook (~> 5.0) omniauth-google-oauth2 (~> 1.0) omniauth-rails_csrf_protection (~> 1.0) omniauth-twitter (~> 1.4) - paper_trail (~> 12.0) - pg (~> 1.4.0, < 2) + paper_trail (~> 16.0) + paranoia (~> 3.0.0) + pg (~> 1.5.0, < 2) pg_search (~> 2.2) premailer-rails (~> 1.10) - psych (~> 4.0) rack (~> 2.2, >= 2.2.8.1) rack-attack (~> 6.0) rails (~> 7.0.8) rails-i18n (~> 7.0) - ransack (~> 3.2.1) + ransack (~> 4.2.0) redis (~> 4.1) - request_store (~> 1.5.0) + request_store (~> 1.7.0) rubyXL (~> 3.4) rubyzip (~> 2.0) shakapacker (~> 7.1.0) - valid_email2 (~> 4.0) + valid_email2 (~> 7.0) web-push (~> 3.0) - wisper (~> 2.0) - decidim-debates (0.29.2) - decidim-comments (= 0.29.2) - decidim-core (= 0.29.2) - decidim-dev (0.29.2) - bullet (~> 7.1.6) + wisper (~> 3.0) + decidim-debates (0.30.1) + decidim-comments (= 0.30.1) + decidim-core (= 0.30.1) + decidim-dev (0.30.1) + bullet (~> 8.0.0) byebug (~> 11.0) capybara (~> 3.39) - decidim (= 0.29.2) - erb_lint (~> 0.4.0) + decidim-admin (= 0.30.1) + decidim-api (= 0.30.1) + decidim-comments (= 0.30.1) + decidim-core (= 0.30.1) + decidim-generators (= 0.30.1) + decidim-verifications (= 0.30.1) + erb_lint (~> 0.8.0) factory_bot_rails (~> 6.2) faker (~> 3.2) i18n-tasks (~> 1.0) nokogiri (~> 1.16, >= 1.16.2) parallel_tests (~> 4.2) - puma (~> 6.2, >= 6.3.1) + puma (~> 6.5) rails-controller-testing (~> 1.0) rspec (~> 3.12) rspec-cells (~> 0.3.7) @@ -266,10 +273,11 @@ GEM rspec-rails (~> 6.0) rspec-retry (~> 0.6.2) rspec_junit_formatter (~> 0.6.0) - rubocop (~> 1.65.0) + rubocop (~> 1.69.0) rubocop-capybara (~> 2.21) rubocop-factory_bot (~> 2.26) rubocop-faker (~> 1.1) + rubocop-graphql (~> 1.5) rubocop-performance (~> 1.21) rubocop-rails (~> 2.25) rubocop-rspec (~> 3.0) @@ -283,40 +291,39 @@ GEM w3c_rspec_validators (~> 0.3.0) webmock (~> 3.18) wisper-rspec (~> 1.0) - decidim-forms (0.29.2) - decidim-core (= 0.29.2) - wicked_pdf (~> 2.1) - decidim-generators (0.29.2) - decidim-core (= 0.29.2) - decidim-meetings (0.29.2) - decidim-core (= 0.29.2) - decidim-forms (= 0.29.2) + decidim-forms (0.30.1) + decidim-core (= 0.30.1) + decidim-generators (0.30.1) + decidim-core (= 0.30.1) + decidim-meetings (0.30.1) + decidim-core (= 0.30.1) + decidim-forms (= 0.30.1) icalendar (~> 2.5) - decidim-pages (0.29.2) - decidim-core (= 0.29.2) - decidim-participatory_processes (0.29.2) - decidim-core (= 0.29.2) - decidim-proposals (0.29.2) - decidim-comments (= 0.29.2) - decidim-core (= 0.29.2) + decidim-pages (0.30.1) + decidim-core (= 0.30.1) + decidim-participatory_processes (0.30.1) + decidim-core (= 0.30.1) + decidim-proposals (0.30.1) + decidim-comments (= 0.30.1) + decidim-core (= 0.30.1) doc2text (~> 0.4.7) redcarpet (~> 3.5, >= 3.5.1) - decidim-sortitions (0.29.2) - decidim-admin (= 0.29.2) - decidim-comments (= 0.29.2) - decidim-core (= 0.29.2) - decidim-proposals (= 0.29.2) - decidim-surveys (0.29.2) - decidim-core (= 0.29.2) - decidim-forms (= 0.29.2) - decidim-system (0.29.2) + decidim-sortitions (0.30.1) + decidim-admin (= 0.30.1) + decidim-comments (= 0.30.1) + decidim-core (= 0.30.1) + decidim-proposals (= 0.30.1) + decidim-surveys (0.30.1) + decidim-core (= 0.30.1) + decidim-forms (= 0.30.1) + decidim-system (0.30.1) active_link_to (~> 1.0) - decidim-core (= 0.29.2) + decidim-core (= 0.30.1) devise (~> 4.7) devise-i18n (~> 1.2) devise_invitable (~> 2.0, >= 2.0.9) - decidim-verifications (0.29.2) - decidim-core (= 0.29.2) + decidim-verifications (0.30.1) + decidim-core (= 0.30.1) declarative-builder (0.2.0) trailblazer-option (~> 0.1.0) declarative-option (0.1.0) @@ -332,49 +339,51 @@ GEM railties (>= 4.1.0) responders warden (~> 1.2.3) - devise-i18n (1.11.0) + devise-i18n (1.14.0) devise (>= 4.9.0) - devise_invitable (2.0.10) + rails-i18n + devise_invitable (2.0.11) actionmailer (>= 5.0) devise (>= 4.6) - diff-lcs (1.5.1) - diffy (3.4.3) + diff-lcs (1.6.2) + diffy (3.4.4) doc2text (0.4.8) nokogiri (>= 1.18.2) rubyzip (~> 2.3.0) - docile (1.4.0) - doorkeeper (5.8.1) + docile (1.4.1) + doorkeeper (5.8.2) railties (>= 5) doorkeeper-i18n (4.0.1) - erb_lint (0.4.0) + erb_lint (0.8.0) activesupport better_html (>= 2.0.1) parser (>= 2.7.1.4) rainbow - rubocop + rubocop (>= 1) smart_properties erbse (0.1.4) temple erubi (1.13.1) escape_utils (1.3.0) - excon (1.2.5) + excon (1.2.8) logger extended-markdown-filter (0.7.0) html-pipeline (~> 2.9) - factory_bot (6.4.6) - activesupport (>= 5.0.0) - factory_bot_rails (6.4.3) - factory_bot (~> 6.4) - railties (>= 5.0.0) + factory_bot (6.5.4) + activesupport (>= 6.1.0) + factory_bot_rails (6.5.0) + factory_bot (~> 6.5) + railties (>= 6.1.0) faker (3.3.1) i18n (>= 1.8.11, < 2) - faraday (2.12.2) + faraday (2.13.4) faraday-net_http (>= 2.0, < 3.5) json logger - faraday-net_http (3.4.0) + faraday-net_http (3.4.1) net-http (>= 0.5.0) - ffi (1.17.1) + ffi (1.17.2) + fiber-storage (1.0.1) file_validators (3.0.0) activemodel (>= 3.2) mime-types (>= 1.0) @@ -385,38 +394,48 @@ GEM mime-types fog-local (0.9.0) fog-core (>= 1.27, < 3.0) - formatador (1.1.0) - foundation_rails_helper (4.0.1) - actionpack (>= 4.1, < 7.1) - activemodel (>= 4.1, < 7.1) - activesupport (>= 4.1, < 7.1) - railties (>= 4.1, < 7.1) + formatador (1.2.0) + reline gemoji (3.0.1) geocoder (1.8.5) base64 (>= 0.1.0) csv (>= 3.0.0) + geom2d (0.4.1) globalid (1.2.1) activesupport (>= 6.1) - graphql (2.2.17) + google-protobuf (4.31.1) + bigdecimal + rake (>= 13) + graphql (2.4.17) base64 - graphql-docs (4.0.0) + fiber-storage + logger + graphql-docs (5.2.0) commonmarker (~> 0.23, >= 0.23.6) - dartsass (~> 1.49) escape_utils (~> 1.2) extended-markdown-filter (~> 0.4) gemoji (~> 3.0) graphql (~> 2.0) html-pipeline (~> 2.14, >= 2.14.3) - hashdiff (1.1.2) + logger (~> 1.6) + ostruct (~> 0.6) + sass-embedded (~> 1.58) + hashdiff (1.2.0) hashie (5.0.0) - highline (3.0.1) + hexapdf (1.1.1) + cmdparse (~> 3.0, >= 3.0.3) + geom2d (~> 0.4, >= 0.4.1) + openssl (>= 2.2.1) + strscan (>= 3.1.2) + highline (3.1.2) + reline html-pipeline (2.14.3) activesupport (>= 2) nokogiri (>= 1.4) htmlentities (4.3.4) i18n (1.14.7) concurrent-ruby (~> 1.0) - i18n-tasks (1.0.14) + i18n-tasks (1.0.15) activesupport (>= 4.0.2) ast (>= 2.1.0) erubi @@ -425,10 +444,13 @@ GEM parser (>= 3.2.2.1) rails-i18n rainbow (>= 2.2.2, < 4.0) + ruby-progressbar (~> 1.8, >= 1.8.1) terminal-table (>= 1.5.1) i18n_data (0.11.0) - icalendar (2.10.3) + icalendar (2.11.2) + base64 ice_cube (~> 0.16) + logger ostruct ice_cube (0.17.0) image_processing (1.14.0) @@ -436,8 +458,9 @@ GEM ruby-vips (>= 2.0.17, < 3) invisible_captcha (0.13.0) rails (>= 3.2.0) - json (2.10.2) - jwt (2.10.1) + io-console (0.8.1) + json (2.13.2) + jwt (3.1.2) base64 kaminari (1.2.2) activesupport (>= 4.1.0) @@ -451,7 +474,7 @@ GEM activerecord kaminari-core (= 1.2.2) kaminari-core (1.2.2) - language_server-protocol (3.17.0.4) + language_server-protocol (3.17.0.5) launchy (3.1.0) addressable (~> 2.8) childprocess (~> 5.0) @@ -467,7 +490,7 @@ GEM rb-fsevent (~> 0.10, >= 0.10.3) rb-inotify (~> 0.9, >= 0.9.10) logger (1.7.0) - loofah (2.24.0) + loofah (2.24.1) crass (~> 1.0.2) nokogiri (>= 1.12.0) mail (2.8.1) @@ -476,32 +499,32 @@ GEM net-pop net-smtp marcel (1.0.4) - matrix (0.4.2) + matrix (0.4.3) method_source (1.1.0) - mime-types (3.6.2) + mime-types (3.7.0) logger - mime-types-data (~> 3.2015) - mime-types-data (3.2025.0325) + mime-types-data (~> 3.2025, >= 3.2025.0507) + mime-types-data (3.2025.0812) mini_magick (4.13.2) mini_mime (1.1.5) - mini_portile2 (2.8.8) + mini_portile2 (2.8.9) minitest (5.25.5) msgpack (1.7.2) - multi_xml (0.7.1) + multi_xml (0.7.2) bigdecimal (~> 3.1) net-http (0.6.0) uri - net-imap (0.5.6) + net-imap (0.5.9) date net-protocol net-pop (0.1.2) net-protocol net-protocol (0.2.2) timeout - net-smtp (0.3.4) + net-smtp (0.5.1) net-protocol nio4r (2.7.4) - nokogiri (1.18.7) + nokogiri (1.18.9) mini_portile2 (~> 2.8.2) racc (~> 1.4) oauth (1.1.0) @@ -510,13 +533,14 @@ GEM version_gem (~> 1.1) oauth-tty (1.0.5) version_gem (~> 1.1, >= 1.1.1) - oauth2 (2.0.9) - faraday (>= 0.17.3, < 3.0) - jwt (>= 1.0, < 3.0) + oauth2 (2.0.12) + faraday (>= 0.17.3, < 4.0) + jwt (>= 1.0, < 4.0) + logger (~> 1.2) multi_xml (~> 0.5) rack (>= 1.2, < 4) - snaky_hash (~> 2.0) - version_gem (~> 1.1) + snaky_hash (~> 2.0, >= 2.0.3) + version_gem (>= 1.1.8, < 3) omniauth (2.1.3) hashie (>= 3.4.6) rack (>= 2.2.3) @@ -543,17 +567,19 @@ GEM rack openssl (3.3.0) orm_adapter (0.5.0) - ostruct (0.6.1) - paper_trail (12.3.0) - activerecord (>= 5.2) - request_store (~> 1.1) - parallel (1.25.1) - parallel_tests (4.7.1) + ostruct (0.6.3) + paper_trail (16.0.0) + activerecord (>= 6.1) + request_store (~> 1.4) + parallel (1.27.0) + parallel_tests (4.10.1) parallel - parser (3.3.3.0) + paranoia (3.0.1) + activerecord (>= 6, < 8.1) + parser (3.3.9.0) ast (~> 2.4.1) racc - pg (1.4.6) + pg (1.5.9) pg_search (2.3.7) activerecord (>= 6.1) activesupport (>= 6.1) @@ -566,13 +592,12 @@ GEM actionmailer (>= 3) net-smtp premailer (~> 1.7, >= 1.7.9) - psych (4.0.6) - stringio - public_suffix (6.0.1) - puma (6.4.2) + prism (1.4.0) + public_suffix (6.0.2) + puma (6.6.1) nio4r (~> 2.0) racc (1.8.1) - rack (2.2.13) + rack (2.2.17) rack-attack (6.7.0) rack (>= 1.0, < 4) rack-cors (1.1.1) @@ -602,7 +627,7 @@ GEM actionpack (>= 5.0.1.rc1) actionview (>= 5.0.1.rc1) activesupport (>= 5.0.1.rc1) - rails-dom-testing (2.2.0) + rails-dom-testing (2.3.0) activesupport (>= 5.0.0) minitest nokogiri (>= 1.6) @@ -620,8 +645,8 @@ GEM thor (~> 1.0) zeitwerk (~> 2.5) rainbow (3.1.1) - rake (13.2.1) - ransack (3.2.1) + rake (13.3.0) + ransack (4.2.1) activerecord (>= 6.1.5) activesupport (>= 6.1.5) i18n @@ -630,33 +655,35 @@ GEM ffi (~> 1.0) redcarpet (3.6.1) redis (4.8.1) - regexp_parser (2.9.2) - request_store (1.5.1) + regexp_parser (2.11.2) + reline (0.6.2) + io-console (~> 0.5) + request_store (1.7.0) rack (>= 1.4) responders (3.1.1) actionpack (>= 5.2) railties (>= 5.2) rexml (3.3.1) strscan - rspec (3.13.0) + rspec (3.13.1) rspec-core (~> 3.13.0) rspec-expectations (~> 3.13.0) rspec-mocks (~> 3.13.0) - rspec-cells (0.3.9) + rspec-cells (0.3.10) cells (>= 4.0.0, < 6.0.0) - rspec-rails (>= 3.0.0, < 6.2.0) - rspec-core (3.13.0) + rspec-rails (>= 3.0.0) + rspec-core (3.13.5) rspec-support (~> 3.13.0) - rspec-expectations (3.13.1) + rspec-expectations (3.13.5) diff-lcs (>= 1.2.0, < 2.0) rspec-support (~> 3.13.0) rspec-html-matchers (0.10.0) nokogiri (~> 1) rspec (>= 3.0.0.a) - rspec-mocks (3.13.1) + rspec-mocks (3.13.5) diff-lcs (>= 1.2.0, < 2.0) rspec-support (~> 3.13.0) - rspec-rails (6.1.3) + rspec-rails (6.1.5) actionpack (>= 6.1) activesupport (>= 6.1) railties (>= 6.1) @@ -666,36 +693,38 @@ GEM rspec-support (~> 3.13) rspec-retry (0.6.2) rspec-core (> 3.3) - rspec-support (3.13.1) + rspec-support (3.13.4) rspec_junit_formatter (0.6.0) rspec-core (>= 2, < 4, != 2.12.0) - rubocop (1.65.1) + rubocop (1.69.2) json (~> 2.3) language_server-protocol (>= 3.17.0) parallel (~> 1.10) parser (>= 3.3.0.2) rainbow (>= 2.2.2, < 4.0) - regexp_parser (>= 2.4, < 3.0) - rexml (>= 3.2.5, < 4.0) - rubocop-ast (>= 1.31.1, < 2.0) + regexp_parser (>= 2.9.3, < 3.0) + rubocop-ast (>= 1.36.2, < 2.0) ruby-progressbar (~> 1.7) - unicode-display_width (>= 2.4.0, < 3.0) - rubocop-ast (1.31.3) - parser (>= 3.3.1.0) + unicode-display_width (>= 2.4.0, < 4.0) + rubocop-ast (1.46.0) + parser (>= 3.3.7.2) + prism (~> 1.4) rubocop-capybara (2.21.0) rubocop (~> 1.41) rubocop-factory_bot (2.26.1) rubocop (~> 1.61) - rubocop-faker (1.1.0) + rubocop-faker (1.2.0) faker (>= 2.12.0) - rubocop (>= 0.82.0) + rubocop (>= 1.13.0) + rubocop-graphql (1.5.4) + rubocop (>= 1.50, < 2) rubocop-performance (1.23.1) rubocop (>= 1.48.1, < 2.0) rubocop-ast (>= 1.31.1, < 2.0) - rubocop-rails (2.25.1) + rubocop-rails (2.29.1) activesupport (>= 4.2.0) rack (>= 1.1) - rubocop (>= 1.33.0, < 2.0) + rubocop (>= 1.52.0, < 2.0) rubocop-ast (>= 1.31.1, < 2.0) rubocop-rspec (3.4.0) rubocop (~> 1.61) @@ -705,18 +734,21 @@ GEM rubocop-rubycw (0.1.6) rubocop (~> 1.0) ruby-progressbar (1.13.0) - ruby-vips (2.2.3) + ruby-vips (2.2.4) ffi (~> 1.12) logger rubyXL (3.4.33) nokogiri (>= 1.10.8) rubyzip (>= 1.3.0) rubyzip (2.3.2) - selenium-webdriver (4.22.0) + sass-embedded (1.90.0) + google-protobuf (~> 4.31) + rake (>= 13) + selenium-webdriver (4.35.0) base64 (~> 0.2) logger (~> 1.4) rexml (~> 3.2, >= 3.2.5) - rubyzip (>= 1.2.2, < 3.0) + rubyzip (>= 1.2.2, < 4.0) websocket (~> 1.0) semantic_range (3.1.0) shakapacker (7.1.0) @@ -731,39 +763,40 @@ GEM simplecov-cobertura (2.1.0) rexml simplecov (~> 0.19) - simplecov-html (0.12.3) + simplecov-html (0.13.2) simplecov_json_formatter (0.1.4) sixarm_ruby_unaccent (1.2.2) smart_properties (1.17.0) - snaky_hash (2.0.1) - hashie - version_gem (~> 1.1, >= 1.1.1) + snaky_hash (2.0.3) + hashie (>= 0.1.0, < 6) + version_gem (>= 1.1.8, < 3) sort_alphabetical (1.1.0) unicode_utils (>= 1.2.2) - spring (4.3.0) + spring (4.4.0) spring-watcher-listen (2.1.0) listen (>= 2.7, < 4.0) spring (>= 4) - stringio (3.1.6) - strscan (3.1.0) - temple (0.10.3) - terminal-table (3.0.2) - unicode-display_width (>= 1.1.1, < 3) - thor (1.3.2) - tilt (2.6.0) + strscan (3.1.5) + temple (0.10.4) + terminal-table (4.0.0) + unicode-display_width (>= 1.1.1, < 4) + thor (1.4.0) + tilt (2.6.1) timeout (0.4.3) trailblazer-option (0.1.2) tzinfo (2.0.6) concurrent-ruby (~> 1.0) uber (0.1.0) - unicode-display_width (2.5.0) + unicode-display_width (3.1.5) + unicode-emoji (~> 4.0, >= 4.0.4) + unicode-emoji (4.0.4) unicode_utils (1.4.0) - uniform_notifier (1.16.0) + uniform_notifier (1.17.0) uri (1.0.3) - valid_email2 (4.0.6) - activemodel (>= 3.2) + valid_email2 (7.0.13) + activemodel (>= 6.0) mail (~> 2.5) - version_gem (1.1.6) + version_gem (1.1.8) w3c_rspec_validators (0.3.0) rails rspec @@ -779,26 +812,23 @@ GEM activemodel (>= 6.0.0) bindex (>= 0.4.0) railties (>= 6.0.0) - web-push (3.0.1) - jwt (~> 2.0) + web-push (3.0.2) + jwt (~> 3.0) openssl (~> 3.0) - webmock (3.23.1) + webmock (3.25.1) addressable (>= 2.8.0) crack (>= 0.3.2) hashdiff (>= 0.4.0, < 2.0.0) - websocket (1.2.10) - websocket-driver (0.7.7) + websocket (1.2.11) + websocket-driver (0.8.0) base64 websocket-extensions (>= 0.1.0) websocket-extensions (0.1.5) - wicked_pdf (2.8.2) - activesupport - ostruct - wisper (2.0.1) + wisper (3.0.0) wisper-rspec (1.1.0) xpath (3.2.0) nokogiri (~> 1.8) - zeitwerk (2.7.2) + zeitwerk (2.7.3) PLATFORMS ruby @@ -806,8 +836,8 @@ PLATFORMS DEPENDENCIES bootsnap (~> 1.7) byebug (~> 11.0) - decidim (~> 0.29.2) - decidim-dev (~> 0.29.2) + decidim (~> 0.30.1) + decidim-dev (~> 0.30.1) decidim-extra_user_fields! faker (~> 3.3.1) letter_opener_web (~> 2.0) @@ -817,7 +847,7 @@ DEPENDENCIES web-console (~> 4.2) RUBY VERSION - ruby 3.2.6p234 + ruby 3.3.4p94 BUNDLED WITH - 2.6.5 + 2.5.17 diff --git a/Rakefile b/Rakefile index 45f3f26..02b01e2 100644 --- a/Rakefile +++ b/Rakefile @@ -5,14 +5,14 @@ require "decidim/dev/common_rake" def install_module(path) Dir.chdir(path) do - system("bundle exec rake decidim_extra_user_fields:install:migrations") - system("bundle exec rake db:migrate") + system("bundle exec rails decidim_extra_user_fields:install:migrations") + system("bundle exec rails db:migrate") end end def seed_db(path) Dir.chdir(path) do - system("bundle exec rake db:seed") + system("bundle exec rails db:seed") end end diff --git a/app/commands/concerns/decidim/extra_user_fields/omniauth_commands_overrides.rb b/app/commands/concerns/decidim/extra_user_fields/omniauth_commands_overrides.rb index 5755012..b4d670c 100644 --- a/app/commands/concerns/decidim/extra_user_fields/omniauth_commands_overrides.rb +++ b/app/commands/concerns/decidim/extra_user_fields/omniauth_commands_overrides.rb @@ -48,6 +48,8 @@ def create_or_find_user # in with omniauth with an already verified account, the account needs # to be marked confirmed. @user.skip_confirmation! if !@user.confirmed? && @user.email == verified_email + @user.tos_agreement = "1" + @user.save! else generated_password = SecureRandom.hex @@ -63,10 +65,13 @@ def create_or_find_user file = url.open @user.avatar.attach(io: file, filename:) end + @user.tos_agreement = form.tos_agreement + @user.accepted_tos_version = Time.current + raise NeedTosAcceptance if @user.tos_agreement.blank? + @user.skip_confirmation! if verified_email end - @user.tos_agreement = "1" @user.extended_data = extended_data @user.save! end diff --git a/app/jobs/decidim/extra_user_fields/admin/export_participants_job.rb b/app/jobs/decidim/extra_user_fields/admin/export_participants_job.rb index a28a9d2..c600a61 100644 --- a/app/jobs/decidim/extra_user_fields/admin/export_participants_job.rb +++ b/app/jobs/decidim/extra_user_fields/admin/export_participants_job.rb @@ -4,13 +4,16 @@ module Decidim module ExtraUserFields module Admin class ExportParticipantsJob < ApplicationJob + include Decidim::PrivateDownloadHelper + queue_as :exports def perform(organization, user, format) collection = organization.users.not_deleted export_data = Decidim::Exporters.find_exporter(format).new(collection, Decidim::ExtraUserFields::UserExportSerializer).export - ExportMailer.export(user, "participants", export_data).deliver_now + private_export = attach_archive(export_data, "participants", user) + ExportMailer.export(user, private_export).deliver_later end end end diff --git a/app/overrides/decidim/devise/registrations/new/extra_user_fields.html.erb.deface b/app/overrides/decidim/devise/registrations/new/extra_user_fields.html.erb.deface index 4e24bb8..0632b39 100644 --- a/app/overrides/decidim/devise/registrations/new/extra_user_fields.html.erb.deface +++ b/app/overrides/decidim/devise/registrations/new/extra_user_fields.html.erb.deface @@ -1,3 +1,3 @@ - + <%= render partial: "/decidim/extra_user_fields/registration_form", locals: { f: f } %> diff --git a/app/views/decidim/extra_user_fields/_profile_form.html.erb b/app/views/decidim/extra_user_fields/_profile_form.html.erb index 586b59c..efe969f 100644 --- a/app/views/decidim/extra_user_fields/_profile_form.html.erb +++ b/app/views/decidim/extra_user_fields/_profile_form.html.erb @@ -22,7 +22,7 @@ <% end %> <% if current_organization.activated_extra_field?(:phone_number) %> - <%= f.telephone_field :phone_number, placeholder: translated_attribute(f.object.phone_number_extra_user_field_placeholder), pattern: f.object.phone_number_extra_user_field_pattern %> + <%= f.phone_field :phone_number, placeholder: translated_attribute(f.object.phone_number_extra_user_field_placeholder), pattern: f.object.phone_number_extra_user_field_pattern %> <% end %> <% if current_organization.activated_extra_field?(:location) %> diff --git a/app/views/decidim/extra_user_fields/_registration_form.html.erb b/app/views/decidim/extra_user_fields/_registration_form.html.erb index 11ae57a..c482401 100644 --- a/app/views/decidim/extra_user_fields/_registration_form.html.erb +++ b/app/views/decidim/extra_user_fields/_registration_form.html.erb @@ -25,7 +25,7 @@ <% end %> <% if current_organization.activated_extra_field?(:phone_number) %> - <%= f.telephone_field :phone_number, placeholder: translated_attribute(f.object.phone_number_extra_user_field_placeholder), pattern: f.object.phone_number_extra_user_field_pattern %> + <%= f.phone_field :phone_number, placeholder: translated_attribute(f.object.phone_number_extra_user_field_placeholder), pattern: f.object.phone_number_extra_user_field_pattern %> <% end %> <% if current_organization.activated_extra_field?(:location) %> diff --git a/decidim-extra_user_fields.gemspec b/decidim-extra_user_fields.gemspec index a5935e2..395634e 100644 --- a/decidim-extra_user_fields.gemspec +++ b/decidim-extra_user_fields.gemspec @@ -10,7 +10,7 @@ Gem::Specification.new do |s| s.email = ["fernando@populate.tools"] s.license = "AGPL-3.0" s.homepage = "https://github.com/PopulateTools/decidim-module-extra_user_fields" - s.required_ruby_version = ">= 3.2.0" + s.required_ruby_version = ">= 3.3.0" s.name = "decidim-extra_user_fields" s.summary = "Decidim module to add extra fields to users." diff --git a/lib/decidim/extra_user_fields/form_builder_methods.rb b/lib/decidim/extra_user_fields/form_builder_methods.rb index 378d34a..df3c7b6 100644 --- a/lib/decidim/extra_user_fields/form_builder_methods.rb +++ b/lib/decidim/extra_user_fields/form_builder_methods.rb @@ -12,6 +12,19 @@ def custom_country_select(name, options = {}) html.html_safe end + def phone_field(attribute, options = {}) + field(attribute, options) do |opts| + if opts[:placeholder].blank? && object.respond_to?(:"#{attribute}_extra_user_field_placeholder") + opts[:placeholder] = translated_attribute(object.send(:"#{attribute}_extra_user_field_placeholder")) + end + + opts[:pattern] ||= object.send(:"#{attribute}_extra_user_field_pattern") if object.respond_to?(:"#{attribute}_extra_user_field_pattern") + opts[:type] = "tel" + + @template.text_field(@object_name, attribute, objectify_options(opts)) + end + end + private # Remove non-standard attrs added by country_select that fail HTML/accessibility validation diff --git a/lib/decidim/extra_user_fields/version.rb b/lib/decidim/extra_user_fields/version.rb index 5349aae..2c5e7ae 100644 --- a/lib/decidim/extra_user_fields/version.rb +++ b/lib/decidim/extra_user_fields/version.rb @@ -4,11 +4,11 @@ module Decidim # This holds the decidim-extra_user_fields version. module ExtraUserFields def self.version - "0.29.0" + "0.30.0" end def self.decidim_version - [">= 0.29"].freeze + [">= 0.30"].freeze end end end diff --git a/spec/commands/decidim/create_omniauth_registration_spec.rb b/spec/commands/decidim/create_omniauth_registration_spec.rb index dd9366c..e47ea21 100644 --- a/spec/commands/decidim/create_omniauth_registration_spec.rb +++ b/spec/commands/decidim/create_omniauth_registration_spec.rb @@ -12,6 +12,7 @@ module Comments let(:uid) { "12345" } let(:oauth_signature) { OmniauthRegistrationForm.create_signature(provider, uid) } let(:verified_email) { email } + let(:tos_agreement) { true } let(:country) { "Argentina" } let(:date_of_birth) { "01/01/2000" } let(:gender) { "other" } @@ -62,6 +63,7 @@ module Comments "nickname" => "facebook_user", "oauth_signature" => oauth_signature, "avatar_url" => "http://www.example.com/foo.jpg", + "tos_agreement" => tos_agreement, "country" => country, "postal_code" => postal_code, "date_of_birth" => date_of_birth, @@ -162,7 +164,7 @@ module Comments user = create(:user, email:, organization:) identity = Decidim::Identity.new(id: 1234) allow(command).to receive(:create_identity).and_return(identity) - + puts "user id in test: #{user.id}, tos_agreement: #{user.tos_agreement}" expect(ActiveSupport::Notifications) .to receive(:publish) .with( @@ -175,7 +177,10 @@ module Comments name: "Facebook User", nickname: "facebook_user", avatar_url: "http://www.example.com/foo.jpg", - raw_data: {} + raw_data: {}, + tos_agreement: true, + accepted_tos_version: user.accepted_tos_version, + newsletter_notifications_at: user.newsletter_notifications_at ) command.call end diff --git a/spec/jobs/decidim/extra_user_fields/admin/export_participants_job_spec.rb b/spec/jobs/decidim/extra_user_fields/admin/export_participants_job_spec.rb index 360facb..a92db59 100644 --- a/spec/jobs/decidim/extra_user_fields/admin/export_participants_job_spec.rb +++ b/spec/jobs/decidim/extra_user_fields/admin/export_participants_job_spec.rb @@ -11,24 +11,20 @@ module Admin let(:format) { "CSV" } it "sends an email with a file attached" do - ExportParticipantsJob.perform_now(organization, user, format) + perform_enqueued_jobs { ExportParticipantsJob.perform_now(organization, user, format) } email = last_email expect(email.subject).to include("participants") - attachment = email.attachments.first - - expect(attachment.read.length).to be_positive - expect(attachment.mime_type).to eq("application/zip") - expect(attachment.filename).to match(/^participants-[0-9]+-[0-9]+-[0-9]+-[0-9]+\.zip$/) + expect(last_email_body).to include("Your download is ready.") end context "when format is CSV" do it "uses the csv exporter" do - export_data = double + export_data = double(read: "", filename: "participants") expect(Decidim::Exporters::CSV).to(receive(:new).with(anything, Decidim::ExtraUserFields::UserExportSerializer)).and_return(double(export: export_data)) expect(ExportMailer) - .to(receive(:export).with(user, "participants", export_data)) - .and_return(double(deliver_now: true)) + .to(receive(:export).with(user, kind_of(Decidim::PrivateExport))) + .and_return(double(deliver_later: true)) ExportParticipantsJob.perform_now(organization, user, format) end end @@ -37,13 +33,13 @@ module Admin let(:format) { "JSON" } it "uses the json exporter" do - export_data = double + export_data = double(read: "", filename: "participants") expect(Decidim::Exporters::JSON) .to(receive(:new).with(anything, Decidim::ExtraUserFields::UserExportSerializer)) .and_return(double(export: export_data)) expect(ExportMailer) - .to(receive(:export).with(user, "participants", export_data)) - .and_return(double(deliver_now: true)) + .to(receive(:export).with(user, kind_of(Decidim::PrivateExport))) + .and_return(double(deliver_later: true)) ExportParticipantsJob.perform_now(organization, user, format) end end @@ -52,13 +48,13 @@ module Admin let(:format) { "Excel" } it "uses the excel exporter" do - export_data = double + export_data = double(read: "", filename: "participants") expect(Decidim::Exporters::Excel) .to(receive(:new).with(anything, Decidim::ExtraUserFields::UserExportSerializer)) .and_return(double(export: export_data)) expect(ExportMailer) - .to(receive(:export).with(user, "participants", export_data)) - .and_return(double(deliver_now: true)) + .to(receive(:export).with(user, kind_of(Decidim::PrivateExport))) + .and_return(double(deliver_later: true)) ExportParticipantsJob.perform_now(organization, user, format) end end diff --git a/spec/lib/overrides_spec.rb b/spec/lib/overrides_spec.rb index 1f5cbe4..43ec2fd 100644 --- a/spec/lib/overrides_spec.rb +++ b/spec/lib/overrides_spec.rb @@ -10,12 +10,12 @@ package: "decidim-core", files: { "/app/commands/decidim/create_registration.rb" => "c2fafd313dbe16624e3ef07584e946cd", - "/app/commands/decidim/create_omniauth_registration.rb" => "5bca48c990c3b82d47119902c0a56ca1", - "/app/commands/decidim/update_account.rb" => "d24090fdd9358c38e6e15c4607a78e18", - "/app/models/decidim/organization.rb" => "a72b9d9ef10aa06dbe5aef27c68d5c7a", + "/app/commands/decidim/create_omniauth_registration.rb" => "95f36dfd91fe8f32ca7fead4b250f095", + "/app/commands/decidim/update_account.rb" => "f6c1fbdfd2e2c38bd9b6a43b335df975", + "/app/models/decidim/organization.rb" => "2aeb36c0edbacbd6761d230a86226e95", "/app/views/decidim/account/show.html.erb" => "f13218e2358a2d611996c2a197c0de25", - "/app/views/decidim/devise/registrations/new.html.erb" => "b30423406afd43bb9af2c98d59d43632", - "/app/views/decidim/devise/omniauth_registrations/new.html.erb" => "49f44efcd7ae6f87c04b309733ff28f6" + "/app/views/decidim/devise/registrations/new.html.erb" => "56884184f7f1582828a77fbeff2bb546", + "/app/views/decidim/devise/omniauth_registrations/new.html.erb" => "968957ce3cfdb63b87a4cc984a310d1f" } }, { diff --git a/spec/system/account_spec.rb b/spec/system/account_spec.rb index 54da721..ae0813f 100644 --- a/spec/system/account_spec.rb +++ b/spec/system/account_spec.rb @@ -530,44 +530,6 @@ end end - context "when on the interests page" do - before do - visit decidim.user_interests_path - end - - it "does not find any scopes" do - expect(page).to have_content("My interests") - expect(page).to have_content("This organization does not have any scope yet") - end - - context "when scopes are defined" do - let!(:scopes) { create_list(:scope, 3, organization:) } - let!(:subscopes) { create_list(:subscope, 3, parent: scopes.first) } - - before do - visit decidim.user_interests_path - end - - it "display translated scope name" do - expect(page).to have_content("My interests") - within "label[for='user_scopes_#{scopes.first.id}_checked']" do - expect(page).to have_content(translated(scopes.first.name)) - end - end - - it "allows to choose interests" do - label_field = "label[for='user_scopes_#{scopes.first.id}_checked']" - expect(page).to have_content("My interests") - find(label_field).click - click_on "Update my interests" - - within_flash_messages do - expect(page).to have_content("Your interests have been successfully updated.") - end - end - end - end - context "when on the delete my account page" do before do visit decidim.delete_account_path @@ -578,9 +540,8 @@ end it "the user can delete their account" do - fill_in :delete_user_delete_account_delete_reason, with: "I just want to delete my account" - - within ".form__wrapper-block" do + within ".delete-account" do + fill_in :delete_user_delete_account_delete_reason, with: "I just want to delete my account" click_on "Delete my account" end From e932dcd3893bf9efbf63f23bfd64b40db2e11662 Mon Sep 17 00:00:00 2001 From: Anna Topalidi <60363870+antopalidi@users.noreply.github.com> Date: Tue, 16 Dec 2025 11:31:20 +0100 Subject: [PATCH 10/10] Upgrade to 0.31 (#9) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Upgrade to 0.31 * fix linter * update Gemfile * fix test * add comment * update workflow * update workflow * comment test * fix dropdown * fix dropdown * fix date_of_birth * Update README.md Co-authored-by: Ivan Vergés * change trigger_omniauth_event line * fix * fix omniauth_commands_overrides --------- Co-authored-by: Ivan Vergés --- .github/workflows/build_app.yml | 2 +- .github/workflows/ci_tests.yml | 2 +- .github/workflows/test_app.yml | 2 +- Gemfile | 3 +- Gemfile.lock | 632 ++++++++++-------- README.md | 10 +- .../omniauth_commands_overrides.rb | 12 +- .../extra_user_fields/_profile_form.html.erb | 2 +- .../_registration_form.html.erb | 2 +- .../admin/export_users/_dropdown.html.erb | 4 +- .../admin/extra_user_fields/_form.html.erb | 6 +- .../fields/_phone_number.html.erb | 2 +- config/assets.rb | 6 +- decidim-extra_user_fields.gemspec | 2 +- lib/decidim/extra_user_fields/version.rb | 4 +- spec/factories.rb | 1 - spec/forms/decidim/account_form_spec.rb | 16 - spec/forms/decidim/registration_form_spec.rb | 12 - spec/lib/overrides_spec.rb | 14 +- spec/models/decidim/organization_spec.rb | 24 +- spec/system/account_spec.rb | 46 +- 21 files changed, 428 insertions(+), 376 deletions(-) diff --git a/.github/workflows/build_app.yml b/.github/workflows/build_app.yml index 0fcb708..51b7095 100644 --- a/.github/workflows/build_app.yml +++ b/.github/workflows/build_app.yml @@ -8,7 +8,7 @@ on: required: false node_version: description: 'Node version' - default: '18.17.1' + default: '22.14.0' required: false type: string jobs: diff --git a/.github/workflows/ci_tests.yml b/.github/workflows/ci_tests.yml index a673f0b..1fcd3c7 100644 --- a/.github/workflows/ci_tests.yml +++ b/.github/workflows/ci_tests.yml @@ -16,7 +16,7 @@ on: env: CI: "true" RUBY_VERSION: 3.3.4 - NODE_VERSION: 18.17.1 + NODE_VERSION: 22.14.0 concurrency: group: ${{ github.workflow }}-${{ github.head_ref || github.ref }} diff --git a/.github/workflows/test_app.yml b/.github/workflows/test_app.yml index 520033b..36c6924 100644 --- a/.github/workflows/test_app.yml +++ b/.github/workflows/test_app.yml @@ -30,7 +30,7 @@ jobs: services: validator: image: ghcr.io/validator/validator:latest - ports: ["8888:8888"] + ports: [ "8888:8888" ] postgres: image: postgres:14 ports: ["5432:5432"] diff --git a/Gemfile b/Gemfile index 679f907..9043fcb 100644 --- a/Gemfile +++ b/Gemfile @@ -1,6 +1,6 @@ # frozen_string_literal: true -DECIDIM_VERSION = "~> 0.30.1" +DECIDIM_VERSION = "~> 0.31.0" source "https://rubygems.org" @@ -8,6 +8,7 @@ ruby RUBY_VERSION gem "decidim", DECIDIM_VERSION gem "decidim-extra_user_fields", path: "." +gem "decidim-initiatives", DECIDIM_VERSION gem "bootsnap", "~> 1.7" gem "puma", ">= 6.3.1" diff --git a/Gemfile.lock b/Gemfile.lock index c0e6dca..5b87180 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,99 +1,108 @@ PATH remote: . specs: - decidim-extra_user_fields (0.30.0) - country_select (~> 4.0) - decidim-core (>= 0.30) + decidim-extra_user_fields (0.31.0) + country_select (~> 10.0) + decidim-core (>= 0.31) deface (~> 1.5) GEM remote: https://rubygems.org/ specs: - actioncable (7.0.8.7) - actionpack (= 7.0.8.7) - activesupport (= 7.0.8.7) + actioncable (7.2.3) + actionpack (= 7.2.3) + activesupport (= 7.2.3) nio4r (~> 2.0) websocket-driver (>= 0.6.1) - actionmailbox (7.0.8.7) - actionpack (= 7.0.8.7) - activejob (= 7.0.8.7) - activerecord (= 7.0.8.7) - activestorage (= 7.0.8.7) - activesupport (= 7.0.8.7) - mail (>= 2.7.1) - net-imap - net-pop - net-smtp - actionmailer (7.0.8.7) - actionpack (= 7.0.8.7) - actionview (= 7.0.8.7) - activejob (= 7.0.8.7) - activesupport (= 7.0.8.7) - mail (~> 2.5, >= 2.5.4) - net-imap - net-pop - net-smtp - rails-dom-testing (~> 2.0) - actionpack (7.0.8.7) - actionview (= 7.0.8.7) - activesupport (= 7.0.8.7) - rack (~> 2.0, >= 2.2.4) + zeitwerk (~> 2.6) + actionmailbox (7.2.3) + actionpack (= 7.2.3) + activejob (= 7.2.3) + activerecord (= 7.2.3) + activestorage (= 7.2.3) + activesupport (= 7.2.3) + mail (>= 2.8.0) + actionmailer (7.2.3) + actionpack (= 7.2.3) + actionview (= 7.2.3) + activejob (= 7.2.3) + activesupport (= 7.2.3) + mail (>= 2.8.0) + rails-dom-testing (~> 2.2) + actionpack (7.2.3) + actionview (= 7.2.3) + activesupport (= 7.2.3) + cgi + nokogiri (>= 1.8.5) + racc + rack (>= 2.2.4, < 3.3) + rack-session (>= 1.0.1) rack-test (>= 0.6.3) - rails-dom-testing (~> 2.0) - rails-html-sanitizer (~> 1.0, >= 1.2.0) - actiontext (7.0.8.7) - actionpack (= 7.0.8.7) - activerecord (= 7.0.8.7) - activestorage (= 7.0.8.7) - activesupport (= 7.0.8.7) + rails-dom-testing (~> 2.2) + rails-html-sanitizer (~> 1.6) + useragent (~> 0.16) + actiontext (7.2.3) + actionpack (= 7.2.3) + activerecord (= 7.2.3) + activestorage (= 7.2.3) + activesupport (= 7.2.3) globalid (>= 0.6.0) nokogiri (>= 1.8.5) - actionview (7.0.8.7) - activesupport (= 7.0.8.7) + actionview (7.2.3) + activesupport (= 7.2.3) builder (~> 3.1) - erubi (~> 1.4) - rails-dom-testing (~> 2.0) - rails-html-sanitizer (~> 1.1, >= 1.2.0) + cgi + erubi (~> 1.11) + rails-dom-testing (~> 2.2) + rails-html-sanitizer (~> 1.6) active_link_to (1.0.5) actionpack addressable - activejob (7.0.8.7) - activesupport (= 7.0.8.7) + activejob (7.2.3) + activesupport (= 7.2.3) globalid (>= 0.3.6) - activemodel (7.0.8.7) - activesupport (= 7.0.8.7) - activerecord (7.0.8.7) - activemodel (= 7.0.8.7) - activesupport (= 7.0.8.7) - activestorage (7.0.8.7) - actionpack (= 7.0.8.7) - activejob (= 7.0.8.7) - activerecord (= 7.0.8.7) - activesupport (= 7.0.8.7) + activemodel (7.2.3) + activesupport (= 7.2.3) + activerecord (7.2.3) + activemodel (= 7.2.3) + activesupport (= 7.2.3) + timeout (>= 0.4.0) + activestorage (7.2.3) + actionpack (= 7.2.3) + activejob (= 7.2.3) + activerecord (= 7.2.3) + activesupport (= 7.2.3) marcel (~> 1.0) - mini_mime (>= 1.1.0) - activesupport (7.0.8.7) - concurrent-ruby (~> 1.0, >= 1.0.2) + activesupport (7.2.3) + base64 + benchmark (>= 0.3) + bigdecimal + concurrent-ruby (~> 1.0, >= 1.3.1) + connection_pool (>= 2.2.5) + drb i18n (>= 1.6, < 2) + logger (>= 1.4.2) minitest (>= 5.1) - tzinfo (~> 2.0) - acts_as_list (1.2.4) + securerandom (>= 0.3) + tzinfo (~> 2.0, >= 2.0.5) + acts_as_list (1.2.6) activerecord (>= 6.1) activesupport (>= 6.1) - addressable (2.8.7) - public_suffix (>= 2.0.2, < 7.0) + addressable (2.8.8) + public_suffix (>= 2.0.2, < 8.0) ast (2.4.3) base64 (0.3.0) - batch-loader (2.0.5) + batch-loader (2.0.6) bcrypt (3.1.20) - better_html (2.1.1) - actionview (>= 6.0) - activesupport (>= 6.0) + benchmark (0.5.0) + better_html (2.2.0) + actionview (>= 7.0) + activesupport (>= 7.0) ast (~> 2.0) erubi (~> 1.4) parser (>= 2.4) smart_properties - bigdecimal (3.2.2) + bigdecimal (3.3.1) bindex (0.8.1) bootsnap (1.18.3) msgpack (~> 1.2) @@ -123,78 +132,82 @@ GEM cells-rails (0.1.6) actionpack (>= 5.0) cells (>= 4.1.6, < 5.0.0) + cgi (0.5.1) charlock_holmes (0.7.9) chartkick (5.1.5) childprocess (5.1.0) logger (~> 1.5) + chunky_png (1.4.0) cmdparse (3.0.7) - commonmarker (0.23.11) - concurrent-ruby (1.3.4) - countries (3.1.0) - i18n_data (~> 0.11.0) - sixarm_ruby_unaccent (~> 1.1) - unicode_utils (~> 1.4) - country_select (4.0.0) - countries (~> 3.0) - sort_alphabetical (~> 1.0) - crack (1.0.0) + commonmarker (0.23.12) + concurrent-ruby (1.3.5) + connection_pool (3.0.2) + countries (7.1.1) + unaccent (~> 0.3) + country_select (10.0.1) + countries (> 5.0, < 8.0) + crack (1.0.1) bigdecimal rexml crass (1.0.6) css_parser (1.21.1) addressable csv (3.3.5) - date (3.4.1) + data_migrate (11.3.1) + activerecord (>= 6.1) + railties (>= 6.1) + date (3.5.1) date_validator (0.12.0) activemodel (>= 3) activesupport (>= 3) - decidim (0.30.1) - decidim-accountability (= 0.30.1) - decidim-admin (= 0.30.1) - decidim-api (= 0.30.1) - decidim-assemblies (= 0.30.1) - decidim-blogs (= 0.30.1) - decidim-budgets (= 0.30.1) - decidim-comments (= 0.30.1) - decidim-core (= 0.30.1) - decidim-debates (= 0.30.1) - decidim-forms (= 0.30.1) - decidim-generators (= 0.30.1) - decidim-meetings (= 0.30.1) - decidim-pages (= 0.30.1) - decidim-participatory_processes (= 0.30.1) - decidim-proposals (= 0.30.1) - decidim-sortitions (= 0.30.1) - decidim-surveys (= 0.30.1) - decidim-system (= 0.30.1) - decidim-verifications (= 0.30.1) - decidim-accountability (0.30.1) - decidim-comments (= 0.30.1) - decidim-core (= 0.30.1) - decidim-admin (0.30.1) + decidim (0.31.0) + decidim-accountability (= 0.31.0) + decidim-admin (= 0.31.0) + decidim-api (= 0.31.0) + decidim-assemblies (= 0.31.0) + decidim-blogs (= 0.31.0) + decidim-budgets (= 0.31.0) + decidim-comments (= 0.31.0) + decidim-core (= 0.31.0) + decidim-debates (= 0.31.0) + decidim-forms (= 0.31.0) + decidim-generators (= 0.31.0) + decidim-meetings (= 0.31.0) + decidim-pages (= 0.31.0) + decidim-participatory_processes (= 0.31.0) + decidim-proposals (= 0.31.0) + decidim-sortitions (= 0.31.0) + decidim-surveys (= 0.31.0) + decidim-system (= 0.31.0) + decidim-verifications (= 0.31.0) + decidim-accountability (0.31.0) + decidim-comments (= 0.31.0) + decidim-core (= 0.31.0) + decidim-admin (0.31.0) active_link_to (~> 1.0) - decidim-core (= 0.30.1) + decidim-core (= 0.31.0) devise (~> 4.7) devise-i18n (~> 1.2) devise_invitable (~> 2.0, >= 2.0.9) - decidim-api (0.30.1) - decidim-core (= 0.30.1) - graphql (~> 2.4.0) + decidim-api (0.31.0) + decidim-core (= 0.31.0) + devise-jwt (~> 0.12.1) + graphql (~> 2.4.0, >= 2.4.17) graphql-docs (~> 5.0) rack-cors (~> 1.0) - decidim-assemblies (0.30.1) - decidim-core (= 0.30.1) - decidim-blogs (0.30.1) - decidim-admin (= 0.30.1) - decidim-comments (= 0.30.1) - decidim-core (= 0.30.1) - decidim-budgets (0.30.1) - decidim-comments (= 0.30.1) - decidim-core (= 0.30.1) - decidim-comments (0.30.1) - decidim-core (= 0.30.1) + decidim-assemblies (0.31.0) + decidim-core (= 0.31.0) + decidim-blogs (0.31.0) + decidim-admin (= 0.31.0) + decidim-comments (= 0.31.0) + decidim-core (= 0.31.0) + decidim-budgets (0.31.0) + decidim-comments (= 0.31.0) + decidim-core (= 0.31.0) + decidim-comments (0.31.0) + decidim-core (= 0.31.0) redcarpet (~> 3.5, >= 3.5.1) - decidim-core (0.30.1) + decidim-core (0.31.0) active_link_to (~> 1.0) acts_as_list (~> 1.0) batch-loader (~> 2.0) @@ -203,7 +216,8 @@ GEM cells-rails (~> 0.1.3) charlock_holmes (~> 0.7) chartkick (~> 5.1.2) - concurrent-ruby (= 1.3.4) + concurrent-ruby (~> 1.3.0) + data_migrate (~> 11.3) date_validator (~> 0.12.0) devise (~> 4.7) devise-i18n (~> 1.2) @@ -235,30 +249,31 @@ GEM premailer-rails (~> 1.10) rack (~> 2.2, >= 2.2.8.1) rack-attack (~> 6.0) - rails (~> 7.0.8) + rails (~> 7.2.0, >= 7.2.2.2) rails-i18n (~> 7.0) ransack (~> 4.2.0) redis (~> 4.1) request_store (~> 1.7.0) + rqrcode (~> 2.2.0) rubyXL (~> 3.4) rubyzip (~> 2.0) - shakapacker (~> 7.1.0) + shakapacker (~> 8.3.0) valid_email2 (~> 7.0) web-push (~> 3.0) wisper (~> 3.0) - decidim-debates (0.30.1) - decidim-comments (= 0.30.1) - decidim-core (= 0.30.1) - decidim-dev (0.30.1) + decidim-debates (0.31.0) + decidim-comments (= 0.31.0) + decidim-core (= 0.31.0) + decidim-dev (0.31.0) bullet (~> 8.0.0) byebug (~> 11.0) capybara (~> 3.39) - decidim-admin (= 0.30.1) - decidim-api (= 0.30.1) - decidim-comments (= 0.30.1) - decidim-core (= 0.30.1) - decidim-generators (= 0.30.1) - decidim-verifications (= 0.30.1) + decidim-admin (= 0.31.0) + decidim-api (= 0.31.0) + decidim-comments (= 0.31.0) + decidim-core (= 0.31.0) + decidim-generators (= 0.31.0) + decidim-verifications (= 0.31.0) erb_lint (~> 0.8.0) factory_bot_rails (~> 6.2) faker (~> 3.2) @@ -273,16 +288,16 @@ GEM rspec-rails (~> 6.0) rspec-retry (~> 0.6.2) rspec_junit_formatter (~> 0.6.0) - rubocop (~> 1.69.0) - rubocop-capybara (~> 2.21) - rubocop-factory_bot (~> 2.26) - rubocop-faker (~> 1.1) - rubocop-graphql (~> 1.5) - rubocop-performance (~> 1.21) - rubocop-rails (~> 2.25) - rubocop-rspec (~> 3.0) - rubocop-rspec_rails (~> 2.30) - rubocop-rubycw (~> 0.1) + rubocop (~> 1.78.0) + rubocop-capybara (~> 2.22.0, >= 2.22.1) + rubocop-factory_bot (~> 2.27.0) + rubocop-faker (~> 1.3, >= 1.3.0) + rubocop-graphql (~> 1.5, >= 1.5.6) + rubocop-performance (~> 1.25, >= 1.25.0) + rubocop-rails (~> 2.32.0, >= 2.32.0) + rubocop-rspec (~> 3.0, >= 3.6.0) + rubocop-rspec_rails (~> 2.31.0) + rubocop-rubycw (~> 0.2.0) selenium-webdriver (~> 4.9) simplecov (~> 0.22.0) simplecov-cobertura (~> 2.1.0) @@ -291,39 +306,44 @@ GEM w3c_rspec_validators (~> 0.3.0) webmock (~> 3.18) wisper-rspec (~> 1.0) - decidim-forms (0.30.1) - decidim-core (= 0.30.1) - decidim-generators (0.30.1) - decidim-core (= 0.30.1) - decidim-meetings (0.30.1) - decidim-core (= 0.30.1) - decidim-forms (= 0.30.1) + decidim-forms (0.31.0) + decidim-core (= 0.31.0) + decidim-generators (0.31.0) + decidim-core (= 0.31.0) + decidim-initiatives (0.31.0) + decidim-admin (= 0.31.0) + decidim-comments (= 0.31.0) + decidim-core (= 0.31.0) + decidim-verifications (= 0.31.0) + decidim-meetings (0.31.0) + decidim-core (= 0.31.0) + decidim-forms (= 0.31.0) icalendar (~> 2.5) - decidim-pages (0.30.1) - decidim-core (= 0.30.1) - decidim-participatory_processes (0.30.1) - decidim-core (= 0.30.1) - decidim-proposals (0.30.1) - decidim-comments (= 0.30.1) - decidim-core (= 0.30.1) - doc2text (~> 0.4.7) + decidim-pages (0.31.0) + decidim-core (= 0.31.0) + decidim-participatory_processes (0.31.0) + decidim-core (= 0.31.0) + decidim-proposals (0.31.0) + decidim-comments (= 0.31.0) + decidim-core (= 0.31.0) + doc2text (~> 0.4.0, >= 0.4.8) redcarpet (~> 3.5, >= 3.5.1) - decidim-sortitions (0.30.1) - decidim-admin (= 0.30.1) - decidim-comments (= 0.30.1) - decidim-core (= 0.30.1) - decidim-proposals (= 0.30.1) - decidim-surveys (0.30.1) - decidim-core (= 0.30.1) - decidim-forms (= 0.30.1) - decidim-system (0.30.1) + decidim-sortitions (0.31.0) + decidim-admin (= 0.31.0) + decidim-comments (= 0.31.0) + decidim-core (= 0.31.0) + decidim-proposals (= 0.31.0) + decidim-surveys (0.31.0) + decidim-core (= 0.31.0) + decidim-forms (= 0.31.0) + decidim-system (0.31.0) active_link_to (~> 1.0) - decidim-core (= 0.30.1) + decidim-core (= 0.31.0) devise (~> 4.7) devise-i18n (~> 1.2) devise_invitable (~> 2.0, >= 2.0.9) - decidim-verifications (0.30.1) - decidim-core (= 0.30.1) + decidim-verifications (0.31.0) + decidim-core (= 0.31.0) declarative-builder (0.2.0) trailblazer-option (~> 0.1.0) declarative-option (0.1.0) @@ -339,9 +359,12 @@ GEM railties (>= 4.1.0) responders warden (~> 1.2.3) - devise-i18n (1.14.0) + devise-i18n (1.15.0) devise (>= 4.9.0) rails-i18n + devise-jwt (0.12.1) + devise (~> 4.0) + warden-jwt_auth (~> 0.10) devise_invitable (2.0.11) actionmailer (>= 5.0) devise (>= 4.6) @@ -354,6 +377,18 @@ GEM doorkeeper (5.8.2) railties (>= 5) doorkeeper-i18n (4.0.1) + drb (2.2.3) + dry-auto_inject (1.1.0) + dry-core (~> 1.1) + zeitwerk (~> 2.6) + dry-configurable (1.3.0) + dry-core (~> 1.1) + zeitwerk (~> 2.6) + dry-core (1.1.0) + concurrent-ruby (~> 1.0) + logger + zeitwerk (~> 2.6) + erb (6.0.0) erb_lint (0.8.0) activesupport better_html (>= 2.0.1) @@ -365,23 +400,23 @@ GEM temple erubi (1.13.1) escape_utils (1.3.0) - excon (1.2.8) + excon (1.3.2) logger extended-markdown-filter (0.7.0) html-pipeline (~> 2.9) - factory_bot (6.5.4) + factory_bot (6.5.6) activesupport (>= 6.1.0) - factory_bot_rails (6.5.0) + factory_bot_rails (6.5.1) factory_bot (~> 6.5) railties (>= 6.1.0) faker (3.3.1) i18n (>= 1.8.11, < 2) - faraday (2.13.4) + faraday (2.14.0) faraday-net_http (>= 2.0, < 3.5) json logger - faraday-net_http (3.4.1) - net-http (>= 0.5.0) + faraday-net_http (3.4.2) + net-http (~> 0.5) ffi (1.17.2) fiber-storage (1.0.1) file_validators (3.0.0) @@ -394,16 +429,16 @@ GEM mime-types fog-local (0.9.0) fog-core (>= 1.27, < 3.0) - formatador (1.2.0) + formatador (1.2.3) reline gemoji (3.0.1) - geocoder (1.8.5) + geocoder (1.8.6) base64 (>= 0.1.0) csv (>= 3.0.0) geom2d (0.4.1) - globalid (1.2.1) + globalid (1.3.0) activesupport (>= 6.1) - google-protobuf (4.31.1) + google-protobuf (4.33.2) bigdecimal rake (>= 13) graphql (2.4.17) @@ -420,7 +455,7 @@ GEM logger (~> 1.6) ostruct (~> 0.6) sass-embedded (~> 1.58) - hashdiff (1.2.0) + hashdiff (1.2.1) hashie (5.0.0) hexapdf (1.1.1) cmdparse (~> 3.0, >= 3.0.3) @@ -432,22 +467,22 @@ GEM html-pipeline (2.14.3) activesupport (>= 2) nokogiri (>= 1.4) - htmlentities (4.3.4) + htmlentities (4.4.2) i18n (1.14.7) concurrent-ruby (~> 1.0) - i18n-tasks (1.0.15) + i18n-tasks (1.1.2) activesupport (>= 4.0.2) ast (>= 2.1.0) erubi - highline (>= 2.0.0) + highline (>= 3.0.0) i18n parser (>= 3.2.2.1) + prism rails-i18n rainbow (>= 2.2.2, < 4.0) ruby-progressbar (~> 1.8, >= 1.8.1) terminal-table (>= 1.5.1) - i18n_data (0.11.0) - icalendar (2.11.2) + icalendar (2.12.1) base64 ice_cube (~> 0.16) logger @@ -459,7 +494,11 @@ GEM invisible_captcha (0.13.0) rails (>= 3.2.0) io-console (0.8.1) - json (2.13.2) + irb (1.15.3) + pp (>= 0.6.0) + rdoc (>= 4.0.0) + reline (>= 0.4.2) + json (2.17.1) jwt (3.1.2) base64 kaminari (1.2.2) @@ -486,6 +525,7 @@ GEM letter_opener (~> 1.7) railties (>= 5.2) rexml + lint_roller (1.1.0) listen (3.9.0) rb-fsevent (~> 0.10, >= 0.10.3) rb-inotify (~> 0.9, >= 0.9.10) @@ -493,28 +533,28 @@ GEM loofah (2.24.1) crass (~> 1.0.2) nokogiri (>= 1.12.0) - mail (2.8.1) + mail (2.9.0) + logger mini_mime (>= 0.1.1) net-imap net-pop net-smtp - marcel (1.0.4) + marcel (1.1.0) matrix (0.4.3) - method_source (1.1.0) mime-types (3.7.0) logger mime-types-data (~> 3.2025, >= 3.2025.0507) - mime-types-data (3.2025.0812) + mime-types-data (3.2025.0924) mini_magick (4.13.2) mini_mime (1.1.5) mini_portile2 (2.8.9) - minitest (5.25.5) + minitest (5.26.2) msgpack (1.7.2) multi_xml (0.7.2) bigdecimal (~> 3.1) - net-http (0.6.0) - uri - net-imap (0.5.9) + net-http (0.8.0) + uri (>= 0.11.1) + net-imap (0.5.12) date net-protocol net-pop (0.1.2) @@ -523,26 +563,28 @@ GEM timeout net-smtp (0.5.1) net-protocol - nio4r (2.7.4) - nokogiri (1.18.9) + nio4r (2.7.5) + nokogiri (1.18.10) mini_portile2 (~> 2.8.2) racc (~> 1.4) - oauth (1.1.0) - oauth-tty (~> 1.0, >= 1.0.1) + oauth (1.1.3) + base64 (~> 0.1) + oauth-tty (~> 1.0, >= 1.0.6) snaky_hash (~> 2.0) - version_gem (~> 1.1) - oauth-tty (1.0.5) - version_gem (~> 1.1, >= 1.1.1) - oauth2 (2.0.12) + version_gem (~> 1.1, >= 1.1.9) + oauth-tty (1.0.6) + version_gem (~> 1.1, >= 1.1.9) + oauth2 (2.0.18) faraday (>= 0.17.3, < 4.0) jwt (>= 1.0, < 4.0) logger (~> 1.2) multi_xml (~> 0.5) rack (>= 1.2, < 4) snaky_hash (~> 2.0, >= 2.0.3) - version_gem (>= 1.1.8, < 3) - omniauth (2.1.3) + version_gem (~> 1.1, >= 1.1.9) + omniauth (2.1.4) hashie (>= 3.4.6) + logger rack (>= 2.2.3) rack-protection omniauth-facebook (5.0.0) @@ -565,9 +607,10 @@ GEM omniauth-twitter (1.4.0) omniauth-oauth (~> 1.1) rack - openssl (3.3.0) + openssl (3.3.2) orm_adapter (0.5.0) ostruct (0.6.3) + package_json (0.2.0) paper_trail (16.0.0) activerecord (>= 6.1) request_store (~> 1.4) @@ -584,6 +627,8 @@ GEM activerecord (>= 6.1) activesupport (>= 6.1) polyglot (0.3.5) + pp (0.6.3) + prettyprint premailer (1.27.0) addressable css_parser (>= 1.19.0) @@ -592,13 +637,17 @@ GEM actionmailer (>= 3) net-smtp premailer (~> 1.7, >= 1.7.9) + prettyprint (0.2.0) prism (1.4.0) - public_suffix (6.0.2) + psych (5.3.0) + date + stringio + public_suffix (7.0.0) puma (6.6.1) nio4r (~> 2.0) racc (1.8.1) - rack (2.2.17) - rack-attack (6.7.0) + rack (2.2.21) + rack-attack (6.8.0) rack (>= 1.0, < 4) rack-cors (1.1.1) rack (>= 2.0.0) @@ -607,22 +656,27 @@ GEM rack (~> 2.2, >= 2.2.4) rack-proxy (0.7.7) rack + rack-session (1.0.2) + rack (< 3) rack-test (2.2.0) rack (>= 1.3) - rails (7.0.8.7) - actioncable (= 7.0.8.7) - actionmailbox (= 7.0.8.7) - actionmailer (= 7.0.8.7) - actionpack (= 7.0.8.7) - actiontext (= 7.0.8.7) - actionview (= 7.0.8.7) - activejob (= 7.0.8.7) - activemodel (= 7.0.8.7) - activerecord (= 7.0.8.7) - activestorage (= 7.0.8.7) - activesupport (= 7.0.8.7) + rackup (1.0.1) + rack (< 3) + webrick + rails (7.2.3) + actioncable (= 7.2.3) + actionmailbox (= 7.2.3) + actionmailer (= 7.2.3) + actionpack (= 7.2.3) + actiontext (= 7.2.3) + actionview (= 7.2.3) + activejob (= 7.2.3) + activemodel (= 7.2.3) + activerecord (= 7.2.3) + activestorage (= 7.2.3) + activesupport (= 7.2.3) bundler (>= 1.15.0) - railties (= 7.0.8.7) + railties (= 7.2.3) rails-controller-testing (1.0.5) actionpack (>= 5.0.1.rc1) actionview (>= 5.0.1.rc1) @@ -637,15 +691,18 @@ GEM rails-i18n (7.0.10) i18n (>= 0.7, < 2) railties (>= 6.0.0, < 8) - railties (7.0.8.7) - actionpack (= 7.0.8.7) - activesupport (= 7.0.8.7) - method_source + railties (7.2.3) + actionpack (= 7.2.3) + activesupport (= 7.2.3) + cgi + irb (~> 1.13) + rackup (>= 1.0.0) rake (>= 12.2) - thor (~> 1.0) - zeitwerk (~> 2.5) + thor (~> 1.0, >= 1.2.2) + tsort (>= 0.2) + zeitwerk (~> 2.6) rainbow (3.1.1) - rake (13.3.0) + rake (13.3.1) ransack (4.2.1) activerecord (>= 6.1.5) activesupport (>= 6.1.5) @@ -653,26 +710,34 @@ GEM rb-fsevent (0.11.2) rb-inotify (0.11.1) ffi (~> 1.0) + rdoc (6.17.0) + erb + psych (>= 4.0.0) + tsort redcarpet (3.6.1) redis (4.8.1) regexp_parser (2.11.2) - reline (0.6.2) + reline (0.6.3) io-console (~> 0.5) request_store (1.7.0) rack (>= 1.4) - responders (3.1.1) - actionpack (>= 5.2) - railties (>= 5.2) + responders (3.2.0) + actionpack (>= 7.0) + railties (>= 7.0) rexml (3.3.1) strscan - rspec (3.13.1) + rqrcode (2.2.0) + chunky_png (~> 1.0) + rqrcode_core (~> 1.0) + rqrcode_core (1.2.0) + rspec (3.13.2) rspec-core (~> 3.13.0) rspec-expectations (~> 3.13.0) rspec-mocks (~> 3.13.0) rspec-cells (0.3.10) cells (>= 4.0.0, < 6.0.0) rspec-rails (>= 3.0.0) - rspec-core (3.13.5) + rspec-core (3.13.6) rspec-support (~> 3.13.0) rspec-expectations (3.13.5) diff-lcs (>= 1.2.0, < 2.0) @@ -680,7 +745,7 @@ GEM rspec-html-matchers (0.10.0) nokogiri (~> 1) rspec (>= 3.0.0.a) - rspec-mocks (3.13.5) + rspec-mocks (3.13.7) diff-lcs (>= 1.2.0, < 2.0) rspec-support (~> 3.13.0) rspec-rails (6.1.5) @@ -693,66 +758,78 @@ GEM rspec-support (~> 3.13) rspec-retry (0.6.2) rspec-core (> 3.3) - rspec-support (3.13.4) + rspec-support (3.13.6) rspec_junit_formatter (0.6.0) rspec-core (>= 2, < 4, != 2.12.0) - rubocop (1.69.2) + rubocop (1.78.0) json (~> 2.3) - language_server-protocol (>= 3.17.0) + language_server-protocol (~> 3.17.0.2) + lint_roller (~> 1.1.0) parallel (~> 1.10) parser (>= 3.3.0.2) rainbow (>= 2.2.2, < 4.0) regexp_parser (>= 2.9.3, < 3.0) - rubocop-ast (>= 1.36.2, < 2.0) + rubocop-ast (>= 1.45.1, < 2.0) ruby-progressbar (~> 1.7) unicode-display_width (>= 2.4.0, < 4.0) rubocop-ast (1.46.0) parser (>= 3.3.7.2) prism (~> 1.4) - rubocop-capybara (2.21.0) - rubocop (~> 1.41) - rubocop-factory_bot (2.26.1) - rubocop (~> 1.61) - rubocop-faker (1.2.0) + rubocop-capybara (2.22.1) + lint_roller (~> 1.1) + rubocop (~> 1.72, >= 1.72.1) + rubocop-factory_bot (2.27.1) + lint_roller (~> 1.1) + rubocop (~> 1.72, >= 1.72.1) + rubocop-faker (1.3.0) faker (>= 2.12.0) - rubocop (>= 1.13.0) - rubocop-graphql (1.5.4) - rubocop (>= 1.50, < 2) - rubocop-performance (1.23.1) - rubocop (>= 1.48.1, < 2.0) - rubocop-ast (>= 1.31.1, < 2.0) - rubocop-rails (2.29.1) + lint_roller (~> 1.1) + rubocop (>= 1.72.1) + rubocop-graphql (1.5.6) + lint_roller (~> 1.1) + rubocop (>= 1.72.1, < 2) + rubocop-performance (1.26.0) + lint_roller (~> 1.1) + rubocop (>= 1.75.0, < 2.0) + rubocop-ast (>= 1.44.0, < 2.0) + rubocop-rails (2.32.0) activesupport (>= 4.2.0) + lint_roller (~> 1.1) rack (>= 1.1) - rubocop (>= 1.52.0, < 2.0) - rubocop-ast (>= 1.31.1, < 2.0) - rubocop-rspec (3.4.0) - rubocop (~> 1.61) - rubocop-rspec_rails (2.30.0) - rubocop (~> 1.61) - rubocop-rspec (~> 3, >= 3.0.1) - rubocop-rubycw (0.1.6) - rubocop (~> 1.0) + rubocop (>= 1.75.0, < 2.0) + rubocop-ast (>= 1.44.0, < 2.0) + rubocop-rspec (3.7.0) + lint_roller (~> 1.1) + rubocop (~> 1.72, >= 1.72.1) + rubocop-rspec_rails (2.31.0) + lint_roller (~> 1.1) + rubocop (~> 1.72, >= 1.72.1) + rubocop-rspec (~> 3.5) + rubocop-rubycw (0.2.2) + lint_roller (~> 1.1) + rubocop (~> 1.72, >= 1.72.1) ruby-progressbar (1.13.0) - ruby-vips (2.2.4) + ruby-vips (2.2.5) ffi (~> 1.12) logger rubyXL (3.4.33) nokogiri (>= 1.10.8) rubyzip (>= 1.3.0) rubyzip (2.3.2) - sass-embedded (1.90.0) + sass-embedded (1.95.1) google-protobuf (~> 4.31) rake (>= 13) - selenium-webdriver (4.35.0) + securerandom (0.4.1) + selenium-webdriver (4.39.0) base64 (~> 0.2) logger (~> 1.4) rexml (~> 3.2, >= 3.2.5) rubyzip (>= 1.2.2, < 4.0) websocket (~> 1.0) semantic_range (3.1.0) - shakapacker (7.1.0) + shakapacker (8.3.0) activesupport (>= 5.2) + package_json rack-proxy (>= 0.6.1) railties (>= 5.2) semantic_range (>= 2.3.0) @@ -765,38 +842,38 @@ GEM simplecov (~> 0.19) simplecov-html (0.13.2) simplecov_json_formatter (0.1.4) - sixarm_ruby_unaccent (1.2.2) smart_properties (1.17.0) snaky_hash (2.0.3) hashie (>= 0.1.0, < 6) version_gem (>= 1.1.8, < 3) - sort_alphabetical (1.1.0) - unicode_utils (>= 1.2.2) spring (4.4.0) spring-watcher-listen (2.1.0) listen (>= 2.7, < 4.0) spring (>= 4) + stringio (3.1.9) strscan (3.1.5) temple (0.10.4) terminal-table (4.0.0) unicode-display_width (>= 1.1.1, < 4) thor (1.4.0) tilt (2.6.1) - timeout (0.4.3) + timeout (0.5.0) trailblazer-option (0.1.2) + tsort (0.2.0) tzinfo (2.0.6) concurrent-ruby (~> 1.0) uber (0.1.0) + unaccent (0.4.0) unicode-display_width (3.1.5) unicode-emoji (~> 4.0, >= 4.0.4) unicode-emoji (4.0.4) - unicode_utils (1.4.0) - uniform_notifier (1.17.0) - uri (1.0.3) + uniform_notifier (1.18.0) + uri (1.1.1) + useragent (0.16.11) valid_email2 (7.0.13) activemodel (>= 6.0) mail (~> 2.5) - version_gem (1.1.8) + version_gem (1.1.9) w3c_rspec_validators (0.3.0) rails rspec @@ -807,6 +884,11 @@ GEM rexml (~> 3.2) warden (1.2.9) rack (>= 2.0.9) + warden-jwt_auth (0.12.0) + dry-auto_inject (>= 0.8, < 2) + dry-configurable (>= 0.13, < 2) + jwt (>= 2.1, < 4) + warden (~> 1.2) web-console (4.2.1) actionview (>= 6.0.0) activemodel (>= 6.0.0) @@ -815,10 +897,11 @@ GEM web-push (3.0.2) jwt (~> 3.0) openssl (~> 3.0) - webmock (3.25.1) + webmock (3.26.1) addressable (>= 2.8.0) crack (>= 0.3.2) hashdiff (>= 0.4.0, < 2.0.0) + webrick (1.9.2) websocket (1.2.11) websocket-driver (0.8.0) base64 @@ -836,9 +919,10 @@ PLATFORMS DEPENDENCIES bootsnap (~> 1.7) byebug (~> 11.0) - decidim (~> 0.30.1) - decidim-dev (~> 0.30.1) + decidim (~> 0.31.0) + decidim-dev (~> 0.31.0) decidim-extra_user_fields! + decidim-initiatives (~> 0.31.0) faker (~> 3.3.1) letter_opener_web (~> 2.0) listen (~> 3.1) diff --git a/README.md b/README.md index 6948624..945544d 100644 --- a/README.md +++ b/README.md @@ -47,11 +47,9 @@ You can also the version of the gem that matches your Decidim version: ```ruby -gem "decidim-extra_user_fields", github: "PopulateTools/decidim-module-extra_user_fields", branch: "release/0.28-stable" -gem "decidim-extra_user_fields", github: "PopulateTools/decidim-module-extra_user_fields", branch: "release/0.27-stable" -gem "decidim-extra_user_fields", github: "PopulateTools/decidim-module-extra_user_fields", branch: "release/0.26-stable" -gem "decidim-extra_user_fields", github: "PopulateTools/decidim-module-extra_user_fields", branch: "release/0.25-stable" -gem "decidim-extra_user_fields", github: "PopulateTools/decidim-module-extra_user_fields", branch: "release/0.24-stable" +gem "decidim-extra_user_fields", github: "openpoke/decidim-module-extra_user_fields", branch: "release/0.31-stable" +gem "decidim-extra_user_fields", github: "openpoke/decidim-module-extra_user_fields", branch: "release/0.30-stable" +gem "decidim-extra_user_fields", github: "PopulateTools/decidim-module-extra_user_fields", branch: "release/0.29-stable" ``` ## Usage @@ -141,7 +139,7 @@ Decidim::ExtraUserFields.configure do |config| "organization" => "decidim.extra_user_fields.participant_types.organization" }, favorite_pet: { - "cat" => "my_app.favorite_pets.cat". + "cat" => "my_app.favorite_pets.cat", "dog" => "my_app.favorite_pets.dog" }, # It is also possible to specify a proc/lambda that returns a suitable list for the select: diff --git a/app/commands/concerns/decidim/extra_user_fields/omniauth_commands_overrides.rb b/app/commands/concerns/decidim/extra_user_fields/omniauth_commands_overrides.rb index b4d670c..77f88d1 100644 --- a/app/commands/concerns/decidim/extra_user_fields/omniauth_commands_overrides.rb +++ b/app/commands/concerns/decidim/extra_user_fields/omniauth_commands_overrides.rb @@ -14,12 +14,14 @@ def call verify_oauth_signature! begin - if existing_identity - user = existing_identity.user - verify_user_confirmed(user) + if (@identity = existing_identity) + @user = existing_identity.user + verify_user_confirmed(@user) + trigger_omniauth_event("decidim.user.omniauth_login") - return broadcast(:ok, user) + return broadcast(:ok, @user) end + return broadcast(:invalid) if form.invalid? transaction do @@ -27,7 +29,7 @@ def call send_email_to_statutory_representative @identity = create_identity end - trigger_omniauth_registration + trigger_omniauth_event broadcast(:ok, @user) rescue ActiveRecord::RecordInvalid => e diff --git a/app/views/decidim/extra_user_fields/_profile_form.html.erb b/app/views/decidim/extra_user_fields/_profile_form.html.erb index efe969f..3e401b0 100644 --- a/app/views/decidim/extra_user_fields/_profile_form.html.erb +++ b/app/views/decidim/extra_user_fields/_profile_form.html.erb @@ -1,6 +1,6 @@ <% if current_organization.extra_user_fields_enabled? %> <% if current_organization.activated_extra_field?(:date_of_birth) %> -
<%= f.date_field :date_of_birth %>
+
<%= f.date_field :date_of_birth, data: { controller: "date-picker" } %>
<% end %> <% if current_organization.activated_extra_field?(:gender) %> diff --git a/app/views/decidim/extra_user_fields/_registration_form.html.erb b/app/views/decidim/extra_user_fields/_registration_form.html.erb index c482401..b3c1985 100644 --- a/app/views/decidim/extra_user_fields/_registration_form.html.erb +++ b/app/views/decidim/extra_user_fields/_registration_form.html.erb @@ -3,7 +3,7 @@

<%= t(".signup.legend") %>

<% if current_organization.activated_extra_field?(:date_of_birth) %> -
<%= f.date_field :date_of_birth %>
+
<%= f.date_field :date_of_birth, data: { controller: "date-picker" } %>
<% end %> <% if current_organization.activated_extra_field?(:gender) %> diff --git a/app/views/decidim/extra_user_fields/admin/export_users/_dropdown.html.erb b/app/views/decidim/extra_user_fields/admin/export_users/_dropdown.html.erb index 032a1fb..f944b76 100644 --- a/app/views/decidim/extra_user_fields/admin/export_users/_dropdown.html.erb +++ b/app/views/decidim/extra_user_fields/admin/export_users/_dropdown.html.erb @@ -1,7 +1,7 @@ - + <%= t "actions.export", scope: "decidim.admin" %> <%= icon "arrow-down-s-line", class: "dropdown-filter-icon" %> -