[feat]Config read from environment variables

This commit is contained in:
Jimmy 2021-04-13 11:03:37 +08:00
parent b7fbba162b
commit 4fcc610b24
6 changed files with 22 additions and 8 deletions

View file

@ -1,6 +1,6 @@
# frozen_string_literal: true
DEFAULT_LOGO = Rails.configuration.conference[:default_logo]
DEFAULT_LOGO = Rails.configuration.conference[:default_logo_filename]
DEFAULT_COLOR = Rails.configuration.conference[:default_color]
module ConferenceHelper

View file

@ -1,7 +1,8 @@
# frozen_string_literal: true
EMAIL_TEMPLATE = 'email_template'
SNAPCON_BCC_ADDRESS = Rails.configuration.mailbot[:bcc_address]
EMAIL_TEMPLATE = Rails.configuration.mailbot[:email_template]
YTLF_TICKET_ID = Rails.configuration.mailbot[:ytlf_ticket_id]
class Mailbot < ActionMailer::Base

View file

@ -67,15 +67,13 @@ module Osem
config.active_job.queue_adapter = :delayed_job
config.conference = {
events_per_page: 3,
default_logo: 'snapcon_logo.png',
default_color: '#0B3559'
events_per_page: (ENV['EVENTS_PER_PAGE'] || 3),
default_logo_filename: (ENV['DEFAULT_LOGO_FILENAME'] || 'snapcon_logo.png'),
default_color: (ENV['DEFAULT_COLOR'] || '#0B3559')
}
config.mailbot = {
bcc_address: 'messages@snap.berkeley.edu',
email_template: 'email_template',
ytlf_ticket_id: 50
ytlf_ticket_id: (ENV['YTLF_TICKET_ID'] || 50)
}
config.before_configuration do

View file

@ -44,6 +44,11 @@ Osem::Application.configure do
# Set the secret key base if it's not set via other means
config.secret_key_base ||= 'f4be765bc98e516de82ac01daa8f8aa11c5ca13cb6c911887851ac89457b6c0b056b2361a21b5c08926c9386e0f91eef84fc0b103d522bf00bc0c78ea8ce7c58'
# Test email address
config.mailbot = {
bcc_address: 'test@test.com'
}
# Use omniauth mock credentials
OmniAuth.config.test_mode = true

View file

@ -101,4 +101,9 @@ Osem::Application.configure do
# Set the secret_key_base from the env, if not set by any other means
config.secret_key_base ||= ENV["SECRET_KEY_BASE"]
# Set bcc email address
config.mailbot = {
bcc_address: ENV['OSEM_MESSAGE_BCC_ADDRESS']
}
end

View file

@ -53,4 +53,9 @@ Osem::Application.configure do
end
config.assets.precompile += ['mailbot.css']
# Test email address
config.mailbot = {
bcc_address: 'test@test.com'
}
end