Merge pull request #65 from CactusPuppy/177717903-move-constants-to-configuration-file

Move constants to configuration file
This commit is contained in:
kingdish 2021-04-14 06:36:23 +08:00 committed by GitHub
commit e26181e1ec
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 30 additions and 5 deletions

View file

@ -1,6 +1,6 @@
# frozen_string_literal: true
EVENTS_PER_PAGE = 3
EVENTS_PER_PAGE = Rails.configuration.conference[:events_per_page]
class ConferencesController < ApplicationController
include ConferenceHelper

View file

@ -1,7 +1,7 @@
# frozen_string_literal: true
DEFAULT_LOGO = 'snapcon_logo.png'
DEFAULT_COLOR = '#0B3559'
DEFAULT_LOGO = Rails.configuration.conference[:default_logo_filename]
DEFAULT_COLOR = Rails.configuration.conference[:default_color]
module ConferenceHelper
# Return true if only call_for_papers or call_for_tracks or call_for_booths is open

View file

@ -1,8 +1,9 @@
# frozen_string_literal: true
SNAPCON_BCC_ADDRESS = 'messages@snap.berkeley.edu'
EMAIL_TEMPLATE = 'email_template'
YTLF_TICKET_ID = 50
SNAPCON_BCC_ADDRESS = Rails.configuration.mailbot[:bcc_address]
YTLF_TICKET_ID = Rails.configuration.mailbot[:ytlf_ticket_id]
class Mailbot < ActionMailer::Base
helper ConferenceHelper

View file

@ -66,6 +66,12 @@ module Osem
config.active_job.queue_adapter = :delayed_job
config.conference = {
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.before_configuration do
env_file = File.join(Rails.root, 'config', 'local_env.yml')
if File.exist?(env_file)

View file

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

View file

@ -101,4 +101,10 @@ 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"]
# Mailbot settings
config.mailbot = {
ytlf_ticket_id: (ENV['YTLF_TICKET_ID'] || 50),
bcc_address: ENV['OSEM_MESSAGE_BCC_ADDRESS']
}
end

View file

@ -51,4 +51,10 @@ Osem::Application.configure do
Timecop.travel(t)
ActiveSupport::Deprecation.silenced = true
end
# Test mailbot settings
config.mailbot = {
ytlf_ticket_id: 50,
bcc_address: 'test@test.com'
}
end