diff --git a/Gemfile b/Gemfile index 820da82..96c4b81 100644 --- a/Gemfile +++ b/Gemfile @@ -11,6 +11,7 @@ gem "decidim-consultations", DECIDIM_VERSION gem "decidim-action_delegator", github: "coopdevs/decidim-module-action_delegator", branch: "main" gem "decidim-decidim_awesome", github: "decidim-ice/decidim-module-decidim_awesome", branch: "main" +gem "decidim-odoo", "~> 0.2.0" gem "decidim-term_customizer", github: "mainio/decidim-module-term_customizer", branch: "master" gem "bootsnap", "~> 1.3" diff --git a/Gemfile.lock b/Gemfile.lock index b375d8f..0bc8e32 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -99,6 +99,7 @@ GEM activerecord (>= 3.0) addressable (2.8.5) public_suffix (>= 2.0.2, < 6.0) + aes_key_wrap (1.1.0) airbrussh (1.5.0) sshkit (>= 1.6.1, != 1.7.0) akami (1.3.1) @@ -127,6 +128,7 @@ GEM html_tokenizer (~> 0.0.6) parser (>= 2.4) smart_properties + bindata (2.4.15) bindex (0.8.1) bootsnap (1.16.0) msgpack (~> 1.2) @@ -355,6 +357,9 @@ GEM decidim-core (= 0.27.4) decidim-forms (= 0.27.4) icalendar (~> 2.5) + decidim-odoo (0.2.0) + decidim-core (>= 0.27.0, < 0.28) + omniauth-keycloak (~> 1.5) decidim-pages (0.27.4) decidim-core (= 0.27.4) decidim-participatory_processes (0.27.4) @@ -443,6 +448,8 @@ GEM base64 faraday-net_http (>= 2.0, < 3.1) ruby2_keywords (>= 0.0.4) + faraday-follow_redirects (0.3.0) + faraday (>= 1, < 3) faraday-net_http (3.0.2) ffi (1.16.2) figaro (1.2.0) @@ -512,6 +519,12 @@ GEM invisible_captcha (0.13.0) rails (>= 3.2.0) json (2.6.3) + json-jwt (1.16.3) + activesupport (>= 4.2) + aes_key_wrap + bindata + faraday (~> 2.0) + faraday-follow_redirects jwt (2.7.1) kaminari (1.2.2) activesupport (>= 4.1.0) @@ -571,6 +584,7 @@ GEM mixlib-shellout (3.2.7) chef-utils msgpack (1.7.2) + multi_json (1.15.0) multi_xml (0.6.0) mustache (1.1.1) net-imap (0.3.7) @@ -596,30 +610,34 @@ GEM version_gem (~> 1.1) oauth-tty (1.0.5) version_gem (~> 1.1, >= 1.1.1) - oauth2 (2.0.9) + oauth2 (1.4.11) faraday (>= 0.17.3, < 3.0) jwt (>= 1.0, < 3.0) + multi_json (~> 1.3) multi_xml (~> 0.5) rack (>= 1.2, < 4) - snaky_hash (~> 2.0) - version_gem (~> 1.1) omniauth (2.1.1) hashie (>= 3.4.6) rack (>= 2.2.3) rack-protection omniauth-facebook (5.0.0) omniauth-oauth2 (~> 1.2) - omniauth-google-oauth2 (1.1.1) + omniauth-google-oauth2 (1.0.1) jwt (>= 2.0) - oauth2 (~> 2.0.6) + oauth2 (~> 1.1) omniauth (~> 2.0) - omniauth-oauth2 (~> 1.8.0) + omniauth-oauth2 (~> 1.7.1) + omniauth-keycloak (1.5.1) + faraday + json-jwt (> 1.13.0) + omniauth (>= 2.0) + omniauth-oauth2 (~> 1.7.1) omniauth-oauth (1.2.0) oauth omniauth (>= 1.0, < 3) - omniauth-oauth2 (1.8.0) + omniauth-oauth2 (1.7.3) oauth2 (>= 1.4, < 3) - omniauth (~> 2.0) + omniauth (>= 1.9, < 3) omniauth-rails_csrf_protection (1.0.1) actionpack (>= 4.2) omniauth (~> 2.0) @@ -921,6 +939,7 @@ DEPENDENCIES decidim-consultations (= 0.27.4) decidim-decidim_awesome! decidim-dev (= 0.27.4) + decidim-odoo (~> 0.2.0) decidim-term_customizer! faker (~> 2.14) figaro (~> 1.2) diff --git a/config/schedule.rb b/config/schedule.rb index 21b3849..bab971b 100644 --- a/config/schedule.rb +++ b/config/schedule.rb @@ -8,3 +8,7 @@ rake "decidim:delete_data_portability_files" rake "decidim:open_data:export" end + +every :day, at: "2:00am" do + rake "decidim:odoo:sync:members" +end diff --git a/config/secrets.yml b/config/secrets.yml index e9359e0..a002df0 100644 --- a/config/secrets.yml +++ b/config/secrets.yml @@ -133,6 +133,9 @@ default: &default icon_path: decidim/brands/google.svg client_id: <%= ENV["OMNIAUTH_GOOGLE_CLIENT_ID"] %> client_secret: <%= ENV["OMNIAUTH_GOOGLE_CLIENT_SECRET"] %> + odoo_keycloak: + enabled: <%= Decidim::Env.new("OMNIAUTH_ODOO_KEYCLOAK_CLIENT_ID").to_boolean_string %> + icon_path: media/images/odoo_logo.svg maps: dynamic_provider: <%= Decidim::Env.new("MAPS_DYNAMIC_PROVIDER", ENV["MAPS_PROVIDER"]).to_s %> static_provider: <%= Decidim::Env.new("MAPS_STATIC_PROVIDER", ENV["MAPS_PROVIDER"]).to_s %> @@ -164,6 +167,9 @@ development: developer: enabled: true icon: phone + odoo_keycloak: + enabled: <%= Decidim::Env.new("OMNIAUTH_ODOO_KEYCLOAK_CLIENT_ID").to_boolean_string %> + icon_path: media/images/odoo_logo.svg test: <<: *default diff --git a/db/migrate/20231005094634_create_decidim_odoo_users.decidim_odoo.rb b/db/migrate/20231005094634_create_decidim_odoo_users.decidim_odoo.rb new file mode 100644 index 0000000..27ff01e --- /dev/null +++ b/db/migrate/20231005094634_create_decidim_odoo_users.decidim_odoo.rb @@ -0,0 +1,21 @@ +# frozen_string_literal: true +# This migration comes from decidim_odoo (originally 20230713143501) + +class CreateDecidimOdooUsers < ActiveRecord::Migration[6.0] + def change + create_table :decidim_odoo_users do |t| + t.references :decidim_organization, null: false, foreign_key: { to_table: :decidim_organizations }, index: { name: :index_odoo_users_on_decidim_organization_id } + t.references :decidim_user, null: false, foreign_key: { to_table: :decidim_users }, index: { name: :index_odoo_users_on_decidim_user_id } + + t.integer :odoo_user_id + t.string :ref + t.boolean :coop_candidate, default: false + t.boolean :member, default: false + + t.timestamps + + t.index %w(decidim_organization_id odoo_user_id), name: "index_unique_odoo_user_and_organization", unique: true + t.index %w(decidim_organization_id ref), name: "index_unique_ref_and_organization", unique: true + end + end +end diff --git a/db/schema.rb b/db/schema.rb index 4dba0de..5e8a7b0 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -10,7 +10,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 2023_09_26_134873) do +ActiveRecord::Schema.define(version: 2023_10_05_094634) do # These are extensions that must be enabled in order to support this database enable_extension "ltree" @@ -1107,6 +1107,21 @@ t.index ["decidim_user_id"], name: "index_decidim_notifications_on_decidim_user_id" end + create_table "decidim_odoo_users", force: :cascade do |t| + t.bigint "decidim_organization_id", null: false + t.bigint "decidim_user_id", null: false + t.integer "odoo_user_id" + t.string "ref" + t.boolean "coop_candidate", default: false + t.boolean "member", default: false + t.datetime "created_at", precision: 6, null: false + t.datetime "updated_at", precision: 6, null: false + t.index ["decidim_organization_id", "odoo_user_id"], name: "index_unique_odoo_user_and_organization", unique: true + t.index ["decidim_organization_id", "ref"], name: "index_unique_ref_and_organization", unique: true + t.index ["decidim_organization_id"], name: "index_odoo_users_on_decidim_organization_id" + t.index ["decidim_user_id"], name: "index_odoo_users_on_decidim_user_id" + end + create_table "decidim_organizations", id: :serial, force: :cascade do |t| t.string "name", null: false t.string "host", null: false @@ -1871,6 +1886,8 @@ add_foreign_key "decidim_editor_images", "decidim_users", column: "decidim_author_id" add_foreign_key "decidim_identities", "decidim_organizations" add_foreign_key "decidim_newsletters", "decidim_users", column: "author_id" + add_foreign_key "decidim_odoo_users", "decidim_organizations" + add_foreign_key "decidim_odoo_users", "decidim_users" add_foreign_key "decidim_participatory_process_steps", "decidim_participatory_processes" add_foreign_key "decidim_participatory_process_types", "decidim_organizations" add_foreign_key "decidim_participatory_processes", "decidim_organizations"