Skip to content

Commit

Permalink
Add centers, extra user fields and term customizer modules (#6)
Browse files Browse the repository at this point in the history
* Add centers, extra user fields and term customizer modules

* Lint

* Registration spec

* Account spec

* Lock ChromeDriver to 119.0.6045.105
  • Loading branch information
fblupi authored Dec 14, 2023
1 parent 0efa0bd commit b7024dc
Show file tree
Hide file tree
Showing 22 changed files with 818 additions and 10 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ on:
pull_request:

env:
RUBY_VERSION: 3.0.2
RUBY_VERSION: 3.0.6
NODE_VERSION: 16.9.1

jobs:
Expand Down
6 changes: 5 additions & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ on:
pull_request:

env:
RUBY_VERSION: 3.0.2
RUBY_VERSION: 3.0.6
NODE_VERSION: 16.9.1

jobs:
Expand Down Expand Up @@ -35,6 +35,10 @@ jobs:
ruby-version: ${{ env.RUBY_VERSION }}
bundler-cache: true

- uses: nanasess/setup-chromedriver@v2
with:
chromedriver-version: 119.0.6045.105

- name: Bundle Install
run: bundle install

Expand Down
2 changes: 1 addition & 1 deletion .ruby-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
3.0.2
3.0.6
5 changes: 5 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ gem "decidim", DECIDIM_VERSION
# gem "decidim-initiatives", DECIDIM_VERSION
# gem "decidim-templates", DECIDIM_VERSION

gem "decidim-centers", "~> 0.1.0"
gem "decidim-extra_user_fields", git: "https://github.com/Platoniq/decidim-module-extra_user_fields"
gem "decidim-term_customizer", git: "https://github.com/mainio/decidim-module-term_customizer"

gem "bootsnap", "~> 1.3"

gem "puma", ">= 5.0.0"
Expand Down Expand Up @@ -56,4 +60,5 @@ end

group :test do
gem "codecov", require: false
gem "database_cleaner"
end
53 changes: 52 additions & 1 deletion Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,3 +1,20 @@
GIT
remote: https://github.com/Platoniq/decidim-module-extra_user_fields
revision: e6122fd80135a7f84eb416ff2cf589e2951bb633
specs:
decidim-extra_user_fields (0.27.2)
country_select (~> 4.0)
decidim-core (>= 0.27.0, < 0.28)
deface (~> 1.5)

GIT
remote: https://github.com/mainio/decidim-module-term_customizer
revision: abbf0c69e1bcaafebc5aa4f8da22fdb64ce62149
specs:
decidim-term_customizer (0.27.0)
decidim-admin (~> 0.27.0)
decidim-core (~> 0.27.0)

GEM
remote: https://rubygems.org/
specs:
Expand Down Expand Up @@ -167,11 +184,24 @@ GEM
commonmarker (0.23.9)
concurrent-ruby (1.1.10)
connection_pool (2.4.1)
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 (0.4.5)
rexml
crass (1.0.6)
css_parser (1.14.0)
addressable
database_cleaner (2.0.2)
database_cleaner-active_record (>= 2, < 3)
database_cleaner-active_record (2.1.0)
activerecord (>= 5.a)
database_cleaner-core (~> 2.0.0)
database_cleaner-core (2.0.1)
date_validator (0.12.0)
activemodel (>= 3)
activesupport (>= 3)
Expand Down Expand Up @@ -221,6 +251,9 @@ GEM
decidim-budgets (0.27.4)
decidim-comments (= 0.27.4)
decidim-core (= 0.27.4)
decidim-centers (0.1.1)
decidim-core (>= 0.27.0, < 0.28)
deface (~> 1.9)
decidim-comments (0.27.4)
decidim-core (= 0.27.4)
redcarpet (~> 3.5, >= 3.5.1)
Expand Down Expand Up @@ -348,6 +381,12 @@ GEM
declarative-builder (0.1.0)
declarative-option (< 0.2.0)
declarative-option (0.1.0)
deface (1.9.0)
actionview (>= 5.2)
nokogiri (>= 1.6)
polyglot
railties (>= 5.2)
rainbow (>= 2.1.0)
descendants_tracker (0.0.4)
thread_safe (~> 0.3, >= 0.3.1)
devise (4.9.2)
Expand Down Expand Up @@ -470,6 +509,7 @@ GEM
rails-i18n
rainbow (>= 2.2.2, < 4.0)
terminal-table (>= 1.5.1)
i18n_data (0.11.0)
icalendar (2.8.0)
ice_cube (~> 0.16)
ice_cube (0.16.4)
Expand Down Expand Up @@ -600,6 +640,7 @@ GEM
pg_search (2.3.6)
activerecord (>= 5.2)
activesupport (>= 5.2)
polyglot (0.3.5)
premailer (1.21.0)
addressable
css_parser (>= 1.12.0)
Expand Down Expand Up @@ -757,12 +798,15 @@ GEM
simplecov (~> 0.19)
simplecov-html (0.12.3)
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)
social-share-button (1.2.4)
coffee-rails
sort_alphabetical (1.1.0)
unicode_utils (>= 1.2.2)
spring (2.1.1)
spring-watcher-listen (2.0.1)
listen (>= 2.7, < 4.0)
Expand Down Expand Up @@ -792,6 +836,7 @@ GEM
concurrent-ruby (~> 1.0)
uber (0.1.0)
unicode-display_width (2.4.2)
unicode_utils (1.4.0)
valid_email2 (2.3.1)
activemodel (>= 3.2)
mail (~> 2.5)
Expand Down Expand Up @@ -843,6 +888,8 @@ GEM

PLATFORMS
arm64-darwin-21
arm64-darwin-22
arm64-darwin-23
x86_64-linux

DEPENDENCIES
Expand All @@ -857,8 +904,12 @@ DEPENDENCIES
capistrano-rbenv
capistrano-sidekiq
codecov
database_cleaner
decidim (= 0.27.4)
decidim-centers (~> 0.1.0)
decidim-dev (= 0.27.4)
decidim-extra_user_fields!
decidim-term_customizer!
faker (~> 2.14)
figaro (~> 1.2)
letter_opener_web (~> 2.0)
Expand All @@ -876,7 +927,7 @@ DEPENDENCIES
wicked_pdf (~> 2.1)

RUBY VERSION
ruby 3.0.2p107
ruby 3.0.6p216

BUNDLED WITH
2.3.20
36 changes: 36 additions & 0 deletions app/forms/concerns/decidim/account_form_override.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# frozen_string_literal: true

require "active_support/concern"

module Decidim
module AccountFormOverride
extend ActiveSupport::Concern

included do
def map_model(model)
map_model_centers(model)
map_model_extra_user_fields(model)
end

private

def map_model_centers(model)
self.center_id = model.center.try(:id)
self.scope_id = model.scope.try(:id)
end

def map_model_extra_user_fields(model)
extended_data = model.extended_data.with_indifferent_access

self.country = extended_data[:country]
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.phone_number = extended_data[:phone_number]
self.location = extended_data[:location]
self.profession = extended_data[:profession]
self.document_id = extended_data[:document_id]
end
end
end
end
7 changes: 7 additions & 0 deletions config/initializers/decidim_overrides.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# frozen_string_literal: true

Rails.application.config.to_prepare do
Decidim::RegistrationForm.include(Decidim::AccountFormOverride)
Decidim::OmniauthRegistrationForm.include(Decidim::AccountFormOverride)
Decidim::AccountForm.include(Decidim::AccountFormOverride)
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# frozen_string_literal: true
# This migration comes from decidim_extra_user_fields (originally 20221024121407)

class AddExtraUserFieldsToDecidimOrganization < ActiveRecord::Migration[6.0]
def up
add_column :decidim_organizations, :extra_user_fields, :jsonb, default: { "enabled" => false }
end

def down
remove_column :decidim_organizations, :extra_user_fields, :jsonb
end
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# frozen_string_literal: true
# This migration comes from decidim_term_customizer (originally 20190217132503)

class CreateDecidimTermCustomizerTranslationSets < ActiveRecord::Migration[5.2]
def change
create_table :decidim_term_customizer_translation_sets do |t|
t.jsonb :name
end
end
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# frozen_string_literal: true
# This migration comes from decidim_term_customizer (originally 20190217132654)

class CreateDecidimTermCustomizerTranslations < ActiveRecord::Migration[5.2]
def change
create_table :decidim_term_customizer_translations do |t|
t.string :locale
t.string :key
t.text :value

t.references(
:translation_set,
null: false,
foreign_key: { to_table: :decidim_term_customizer_translation_sets },
index: { name: "decidim_term_customizer_translation_translation_set" }
)
end
end
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# frozen_string_literal: true
# This migration comes from decidim_term_customizer (originally 20190217132726)

class CreateDecidimTermCustomizerConstraints < ActiveRecord::Migration[5.2]
def change
create_table :decidim_term_customizer_constraints do |t|
t.references :decidim_organization, null: false, foreign_key: true, index: { name: "decidim_term_customizer_constraint_organization" }
t.references :subject, polymorphic: true, index: { name: "decidim_term_customizer_constraint_subject" }

t.references(
:translation_set,
null: false,
foreign_key: { to_table: :decidim_term_customizer_translation_sets },
index: { name: "decidim_term_customizer_constraint_translation_set" }
)
end
end
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# frozen_string_literal: true
# This migration comes from decidim_centers (originally 20231129114029)

class CreateDecidimCentersCenters < ActiveRecord::Migration[6.1]
def change
create_table :decidim_centers_centers do |t|
t.references :decidim_organization, foreign_key: true, index: true
t.jsonb :title, null: false
t.datetime :deleted_at

t.timestamps
end
end
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# frozen_string_literal: true
# This migration comes from decidim_centers (originally 20231130125631)

class CreateDecidimCentersCenterUsers < ActiveRecord::Migration[6.1]
def change
create_table :decidim_centers_center_users do |t|
t.references :decidim_centers_center, foreign_key: true, index: { name: "index_decidim_center_users_on_decidim_center_id" }
t.references :decidim_user, foreign_key: true, index: { name: "index_decidim_center_users_on_decidim_user_id" }

t.timestamps
end
end
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# frozen_string_literal: true
# This migration comes from decidim_centers (originally 20231205153627)

class CreateDecidimCentersScopeUsers < ActiveRecord::Migration[6.1]
def change
create_table :decidim_centers_scope_users do |t|
t.references :decidim_scope, foreign_key: true, index: { name: "index_decidim_scope_users_on_decidim_scope_id" }
t.references :decidim_user, foreign_key: true, index: { name: "index_decidim_scope_users_on_decidim_user_id" }

t.timestamps
end
end
end
Loading

0 comments on commit b7024dc

Please sign in to comment.