Skip to content

Commit

Permalink
Install Odoo module (#61)
Browse files Browse the repository at this point in the history
* Install Odoo module

* Add initializer

* Lint file
  • Loading branch information
fblupi authored Oct 6, 2023
1 parent dce35d1 commit 2ae32c4
Show file tree
Hide file tree
Showing 7 changed files with 97 additions and 8 deletions.
1 change: 1 addition & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
35 changes: 27 additions & 8 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand All @@ -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)
Expand Down Expand Up @@ -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)
Expand Down
21 changes: 21 additions & 0 deletions config/initializers/odoo.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# frozen_string_literal: true

Decidim::Odoo.configure do |config|
# Configure api credentials
config.api = {
base_url: ENV["ODOO_API_BASE_URL"].presence,
api_key: ENV["ODOO_API_API_KEY"].presence
}

# Configure omniauth secrets
config.keycloak_omniauth = {
enabled: ENV["OMNIAUTH_ODOO_KEYCLOAK_CLIENT_ID"].present?,
client_id: ENV["OMNIAUTH_ODOO_KEYCLOAK_CLIENT_ID"].presence,
client_secret: ENV["OMNIAUTH_ODOO_KEYCLOAK_CLIENT_SECRET"].presence,
client_options: {
site: ENV["OMNIAUTH_ODOO_KEYCLOAK_SITE"].presence,
realm: ENV["OMNIAUTH_ODOO_KEYCLOAK_REALM"].presence
},
icon_path: ENV["OMNIAUTH_ODOO_KEYCLOAK_ICON_PATH"].presence || "media/images/odoo_logo.svg"
}
end
4 changes: 4 additions & 0 deletions config/schedule.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
6 changes: 6 additions & 0 deletions config/secrets.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 %>
Expand Down Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -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
17 changes: 17 additions & 0 deletions db/schema.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -1883,6 +1898,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"
Expand Down

0 comments on commit 2ae32c4

Please sign in to comment.