Class: Decidim::Voca::DecidimServiceController

Inherits:
Gruf::Controllers::Base
  • Object
show all
Includes:
VocaDecidim
Defined in:
app/rpc/decidim/voca/decidim_service_controller.rb

Constant Summary

Constants included from VocaDecidim

VocaDecidim::DecidimOrganizationColorSettings, VocaDecidim::DecidimOrganizationFeatureFlagSettings, VocaDecidim::DecidimOrganizationFileUploadSettings, VocaDecidim::DecidimOrganizationLocaleSettings, VocaDecidim::DecidimOrganizationNamingSettings, VocaDecidim::DecidimOrganizationPermissionSettings, VocaDecidim::DecidimOrganizationSMTPSettings, VocaDecidim::GetSettingsResponse, VocaDecidim::PingResponse, VocaDecidim::SETTINGS_MACHINE_TRANSLATION_PRIORITY_OPTION, VocaDecidim::SETTINGS_REGISTER_MODE_OPTION, VocaDecidim::SETTINGS_SMTP_AUTHENTICATION_OPTION, VocaDecidim::SETTINGS_SMTP_OPENSSL_OPTION, VocaDecidim::SeedAdminRequest, VocaDecidim::SeedAdminResponse, VocaDecidim::SetSettingsRequest

Instance Method Summary collapse

Instance Method Details

#compile_assetsObject



24
25
26
27
# File 'app/rpc/decidim/voca/decidim_service_controller.rb', line 24

def compile_assets
  `bundle exec rails assets:precompile`
  ::Google::Protobuf::Empty.new
end

#get_settingsObject



15
16
17
18
19
20
21
22
# File 'app/rpc/decidim/voca/decidim_service_controller.rb', line 15

def get_settings
  ::Decidim::Voca::Rpc::GetSettings.new(
    message,
    organization
  ).get_settings
rescue ActiveRecord::RecordNotFound => _e
  fail!(:not_found, :organization_not_found, "No organization is ready, have you seeded?")
end

#pingObject



9
10
11
12
13
# File 'app/rpc/decidim/voca/decidim_service_controller.rb', line 9

def ping
  ::Decidim::Voca::Rpc::Health.new(
    message
  ).ping
end

#seed_adminObject



35
36
37
38
39
40
41
42
43
44
# File 'app/rpc/decidim/voca/decidim_service_controller.rb', line 35

def seed_admin
  seeder = ::Decidim::Voca::Rpc::SeedAdmin.new(message)
  seeder.seed
  ::VocaDecidim::SeedAdminResponse.new(
    admin_email: message.admin_email,
    admin_password: seeder.password
  )
rescue ActiveRecord::RecordNotFound => _e
  fail!(:not_found, :organization_not_found, "No organization is ready, have you seeded?")
end

#set_settingsObject



47
48
49
50
51
52
53
54
55
# File 'app/rpc/decidim/voca/decidim_service_controller.rb', line 47

def set_settings
  ::Decidim::Voca::Rpc::SetSettings.new(
    message,
    organization
  ).set_settings
  ::Google::Protobuf::Empty.new
rescue ActiveRecord::RecordNotFound => _e
  fail!(:not_found, :organization_not_found, "No organization is ready, have you seeded?")
end

#setup_dbObject



29
30
31
32
33
# File 'app/rpc/decidim/voca/decidim_service_controller.rb', line 29

def setup_db
  `bundle exec rails db:migrate`
  ::Decidim::Voca::Rpc::SetupDb.new.seed
  ::Google::Protobuf::Empty.new
end