-
Notifications
You must be signed in to change notification settings - Fork 19
/
Copy pathapplication.rb
108 lines (82 loc) · 3.49 KB
/
application.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
# frozen_string_literal: true
# Copyright (c) 2006-2023, Puzzle ITC GmbH. This file is part of
# PuzzleTime and licensed under the Affero General Public License version 3
# or later. See the COPYING file at the top-level directory or at
# https://github.com/puzzle/puzzletime.
require_relative 'boot'
require 'rails/all'
# Require the gems listed in Gemfile, including any gems
# you've limited to :test, :development, or :production.
Bundler.require(*Rails.groups)
require 'csv'
require_relative 'version'
module Puzzletime
class Application < Rails::Application
# Initialize configuration defaults for originally generated Rails version.
config.load_defaults 7.0
# FIXME: remove this if it works flawlesly
config.active_record.belongs_to_required_by_default = false
# Configuration for the application, engines, and railties goes here.
#
# These settings can be overridden in specific environments using the files
# in config/environments, which are processed later.
#
# config.time_zone = "Central Time (US & Canada)"
# config.eager_load_paths << Rails.root.join("extras")
config.autoload_paths += %W[#{config.root}/app/models/util]
# Use custom error controller
config.exceptions_app = routes
# Set Time.zone default to the specified zone and make Active Record auto-convert to this zone.
# Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC.
# config.time_zone = 'Central Time (US & Canada)'
# Attention: Setting a time zone here will confuse OpenShift.
# We leave the Time zone on UTC as recommended by
# https://robots.thoughtbot.com/its-about-time-zones
# config.time_zone = 'Bern'
# The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded.
# config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s]
locale =
if ENV['RAILS_LOCALE']
:"#{ENV['RAILS_LOCALE']}"
else
:'de-CH'
end
config.i18n.default_locale = locale
config.encoding = 'utf-8'
memcached_host = ENV['RAILS_MEMCACHED_HOST'] || 'localhost'
memcached_port = ENV['RAILS_MEMCACHED_PORT'] || '11211'
config.cache_store = :mem_cache_store, "#{memcached_host}:#{memcached_port}"
config.middleware.insert_before Rack::ETag, Rack::Deflater
config.active_record.time_zone_aware_types = %i[datetime time]
config.active_job.queue_adapter = :delayed_job
config.action_mailer.default_url_options = {
protocol: 'https',
host: ENV['RAILS_MAIL_URL_HOST'].presence || 'example.com'
}
config.to_prepare do |_|
Crm.init
Invoicing.init
CommitReminderJob.schedule
rescue ActiveRecord::StatementInvalid => e
# the db might not exist yet, lets ignore the error in this case
raise e unless e.message.include?('PG::UndefinedTable') || e.message.include?('does not exist')
end
config.active_record.yaml_column_permitted_classes = [Date, BigDecimal]
end
def self.version
@@ptime_version ||= build_version
end
def self.changelog_url
# @@ptime_changelog_url ||= 'https://github.com/puzzle/puzzletime/blob/master/CHANGELOG.md'
@@ptime_changelog_url ||= "https://github.com/puzzle/puzzletime/blob/#{commit_hash || 'master'}/CHANGELOG.md"
end
def self.build_version
Puzzletime::VERSION
end
def self.commit_hash(short: false)
return unless ENV['BUILD_COMMIT']
commit = ENV['BUILD_COMMIT'].chomp
return commit.first(8) if short
commit
end
end