Skip to content

Commit

Permalink
Merge pull request #6099 from ministryofjustice/maintenance_mode_v2
Browse files Browse the repository at this point in the history
Add maintenance mode (v2)
  • Loading branch information
jsugarman authored Dec 8, 2023
2 parents f7b2e22 + 993473b commit 369855d
Show file tree
Hide file tree
Showing 8 changed files with 59 additions and 9 deletions.
1 change: 1 addition & 0 deletions .simplecov
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ SimpleCov.start "rails" do
add_filter "lib/tasks/helpers/cfe_payload_recorder.rb"
add_filter "lib/tasks/helpers/cy_helper.rb"
add_filter "lib/utilities/redis_scanner.rb"
add_filter "app/controllers/pages_controller.rb"

enable_coverage :branch

Expand Down
23 changes: 23 additions & 0 deletions app/controllers/pages_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
class PagesController < ApplicationController
def servicedown
respond_to do |format|
format.html do
render :servicedown
end
format.json do
render json:
[{ error: "Service temporarily unavailable" }],
status: :service_unavailable
end
format.js do
render json:
[{ error: "Service temporarily unavailable" }],
status: :service_unavailable
end
format.all do
render plain: "error: Service temporarily unavailable",
status: :service_unavailable
end
end
end
end
4 changes: 4 additions & 0 deletions app/models/setting.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,10 @@ def self.linked_applications?
setting.linked_applications
end

def self.maintenance_mode?
ENV.fetch("MAINTENANCE_MODE", "false") == "true"
end

def self.setting
Setting.first || Setting.create!
end
Expand Down
5 changes: 5 additions & 0 deletions app/views/pages/servicedown.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<%= page_template page_title: t(".title"), back_link: :none do %>
<p class="govuk-body">
<%= t(".warning_html") %>
</p>
<% end %>
13 changes: 13 additions & 0 deletions config/locales/en/pages.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
---
en:
pages:
servicedown:
title: Sorry, the service is unavailable
warning_html: |
<p>
You will be able to use the service again once we resolve the problem we’ve found.
</p>
<p>
Use <a href="https://portal.legalservices.gov.uk/"><abbr title='Client and Cost Management System'>CCMS</abbr> (Client and Cost Management System)</a>
if you need to make a new application.
</p>
11 changes: 7 additions & 4 deletions config/routes.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,11 @@
Rails.application.routes.draw do
get "ping", to: "status#ping", format: :json
get "healthcheck", to: "status#status", format: :json
get "status", to: "status#ping", format: :json
get "data", to: "status#data"

match "(*any)", to: "pages#servicedown", via: :all if Setting.maintenance_mode?

root to: "providers/start#index"

require "sidekiq/web"
Expand Down Expand Up @@ -35,10 +42,6 @@
end

get "auth/failure", to: "auth#failure"
get "ping", to: "status#ping", format: :json
get "healthcheck", to: "status#status", format: :json
get "status", to: "status#ping", format: :json
get "data", to: "status#data"

resource :contact, only: [:show]
resources :accessibility_statement, only: [:index]
Expand Down
8 changes: 4 additions & 4 deletions db/schema.rb
Original file line number Diff line number Diff line change
Expand Up @@ -110,9 +110,9 @@
t.integer "failed_attempts", default: 0, null: false
t.string "unlock_token"
t.datetime "locked_at", precision: nil
t.boolean "employed"
t.datetime "remember_created_at", precision: nil
t.string "remember_token"
t.boolean "employed"
t.boolean "self_employed", default: false
t.boolean "armed_forces", default: false
t.boolean "has_national_insurance_number"
Expand Down Expand Up @@ -593,9 +593,9 @@
t.boolean "no_cash_income"
t.boolean "no_cash_outgoings"
t.date "purgeable_on"
t.string "required_document_categories", default: [], null: false, array: true
t.boolean "extra_employment_information"
t.string "extra_employment_information_details"
t.string "required_document_categories", default: [], null: false, array: true
t.string "full_employment_details"
t.datetime "client_declaration_confirmed_at", precision: nil
t.boolean "substantive_cost_override"
Expand Down Expand Up @@ -1074,8 +1074,8 @@
add_foreign_key "legal_aid_applications", "providers"
add_foreign_key "legal_framework_merits_task_lists", "legal_aid_applications", on_delete: :cascade
add_foreign_key "legal_framework_submissions", "legal_aid_applications"
add_foreign_key "linked_applications", "legal_aid_applications", column: "associated_application_id"
add_foreign_key "linked_applications", "legal_aid_applications", column: "lead_application_id"
add_foreign_key "linked_applications", "legal_aid_applications", column: "associated_application_id", validate: false
add_foreign_key "linked_applications", "legal_aid_applications", column: "lead_application_id", validate: false
add_foreign_key "matter_oppositions", "legal_aid_applications", on_delete: :cascade
add_foreign_key "offices", "firms"
add_foreign_key "offices_providers", "offices"
Expand Down
3 changes: 2 additions & 1 deletion helm_deploy/apply-for-legal-aid/templates/_envs.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -381,5 +381,6 @@ env:
secretKeyRef:
name: {{ template "apply-for-legal-aid.fullname" . }}
key: encryptionKeyDerivationSalt

- name: MAINTENANCE_MODE
value: "true"
{{- end }}

0 comments on commit 369855d

Please sign in to comment.