Added an env variable that allows maitenance mode (#679)

This commit is contained in:
farhatahmad
2019-07-22 16:45:56 -04:00
committed by Jesus Federico
parent f2373ad21e
commit 02c0d577f8
4 changed files with 23 additions and 1 deletions

View File

@ -36,6 +36,9 @@ class ApplicationController < ActionController::Base
# Manually handle BigBlueButton errors
rescue_from BigBlueButton::BigBlueButtonException, with: :handle_bigbluebutton_error
# Manually Handle errors when application is in readonly mode
rescue_from ActiveRecord::ReadOnlyRecord, with: :handle_readonly_error
protect_from_forgery with: :exception
MEETING_NAME_LIMIT = 90
@ -47,7 +50,7 @@ class ApplicationController < ActionController::Base
end
def maintenance_mode?
if ENV["MAINTENANCE_MODE"].present?
if ENV["MAINTENANCE_MODE"] == "full"
render "errors/greenlight_error", status: 503, formats: :html,
locals: {
status_code: 503,
@ -190,4 +193,10 @@ class ApplicationController < ActionController::Base
def handle_bigbluebutton_error
render "errors/bigbluebutton_error"
end
# Manually Handle errors when application is in readonly mode
def handle_readonly_error
flash.clear
redirect_to request.referrer, flash: { alert: I18n.t("errors.maintenance.readonly") }
end
end