Skip to content

Commit

Permalink
Merge pull request #46 from betagouv/maintenance
Browse files Browse the repository at this point in the history
app: add a maintenance mode
  • Loading branch information
freesteph authored Sep 26, 2023
2 parents 2c56213 + 02e2625 commit 593aa51
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 1 deletion.
12 changes: 11 additions & 1 deletion app/controllers/application_controller.rb
Original file line number Diff line number Diff line change
@@ -1,14 +1,24 @@
# frozen_string_literal: true

class ApplicationController < ActionController::Base
before_action :set_establishment
before_action :check_maintenance, :set_establishment

def after_sign_in_path_for(_resource)
classes_path
end

protected

def check_maintenance
return if request.path == maintenance_path # or endless redirect

redirect_to maintenance_path if maintenance_mode?
end

def maintenance_mode?
ENV.fetch("APLYPRO_MAINTENANCE_REASON", nil).present?
end

def set_establishment
@etab = current_principal&.establishment
end
Expand Down
4 changes: 4 additions & 0 deletions app/controllers/home_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ def index
redirect_to login_url
end

def maintenance
@msg = ENV.fetch("APLYPRO_MAINTENANCE_REASON")
end

def login
infer_page_title
end
Expand Down
5 changes: 5 additions & 0 deletions app/views/home/maintenance.html.haml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
.fr-grid-row
.fr-md-6
%h1 Aplypro n'est pas disponible pour le moment.

%p= @msg
1 change: 1 addition & 0 deletions config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@

root "home#index"

get "/maintenance", to: "home#maintenance"
get "/login", to: "home#login"
get "/select_etab", to: "home#select_etab"
end
Expand Down

0 comments on commit 593aa51

Please sign in to comment.