Browse Source

CLDC-2863: implement service_moved functionality

pull/2022/head
Sam Seed 3 years ago
parent
commit
4e2677ae23
  1. 12
      app/controllers/application_controller.rb
  2. 6
      app/controllers/maintenance_controller.rb
  3. 4
      app/services/feature_toggle.rb
  4. 2
      app/views/layouts/application.html.erb
  5. 9
      app/views/maintenance/service_moved.html.erb
  6. 2
      config/initializers/sidekiq.rb
  7. 1
      config/routes.rb

12
app/controllers/application_controller.rb

@ -7,9 +7,15 @@ class ApplicationController < ActionController::Base
before_action :set_paper_trail_whodunnit
def check_maintenance_status
if FeatureToggle.service_unavailable? && !%w[service-unavailable accessibility-statement privacy-notice cookies].include?(request.fullpath.split("?")[0].delete("/"))
redirect_to service_unavailable_path
elsif !FeatureToggle.service_unavailable? && request.fullpath.split("?")[0].delete("/") == "service-unavailable"
if FeatureToggle.service_moved?
unless %w[service-moved accessibility-statement privacy-notice cookies].include?(request.fullpath.split("?")[0].delete("/"))
redirect_to service_moved_path
end
elsif FeatureToggle.service_unavailable?
unless %w[service-unavailable accessibility-statement privacy-notice cookies].include?(request.fullpath.split("?")[0].delete("/"))
redirect_to service_unavailable_path
end
elsif %w[service-moved service-unavailable].include?(request.fullpath.split("?")[0].delete("/"))
redirect_back(fallback_location: root_path)
end
end

6
app/controllers/maintenance_controller.rb

@ -1,4 +1,10 @@
class MaintenanceController < ApplicationController
def service_moved
if current_user
sign_out
end
end
def service_unavailable
if current_user
sign_out

4
app/services/feature_toggle.rb

@ -41,4 +41,8 @@ class FeatureToggle
def self.service_unavailable?
false
end
def self.service_moved?
false
end
end

2
app/views/layouts/application.html.erb

@ -91,7 +91,7 @@
navigation_classes: "govuk-header__navigation--end",
) do |component|
component.product_name(name: t("service_name"))
unless FeatureToggle.service_unavailable?
unless FeatureToggle.service_moved? || FeatureToggle.service_unavailable?
if current_user.nil?
component.navigation_item(text: "Sign in", href: user_session_path)
else

9
app/views/maintenance/service_moved.html.erb

@ -0,0 +1,9 @@
<h1 class="govuk-heading-l govuk-!-width-two-thirds">
The URL for this service has changed.
</h1>
<div class="govuk-grid-row">
<div class="govuk-grid-column-two-thirds-from-desktop">
<p class="govuk-body">Submit social housing lettings and sales data (CORE) can now be found at <%= govuk_link_to "https://submit-social-housing-data.levellingup.gov.uk", "https://submit-social-housing-data.levellingup.gov.uk" %>. If you have bookmarked this page, you need to update it.</p>
</div>
</div>

2
config/initializers/sidekiq.rb

@ -33,7 +33,7 @@ Redis.silence_deprecations = true
Sidekiq.configure_server do |config|
config.on(:startup) do
Sidekiq::Cron::Job.all.each(&:destroy)
unless FeatureToggle.service_unavailable?
unless FeatureToggle.service_moved? || FeatureToggle.service_unavailable?
Sidekiq::Cron::Job.load_from_hash YAML.load_file("config/sidekiq_cron_schedule.yml")
end
end

1
config/routes.rb

@ -35,6 +35,7 @@ Rails.application.routes.draw do
get "/accessibility-statement", to: "content#accessibility_statement"
get "/privacy-notice", to: "content#privacy_notice"
get "/data-sharing-agreement", to: "content#data_sharing_agreement"
get "/service-moved", to: "maintenance#service_moved"
get "/service-unavailable", to: "maintenance#service_unavailable"
get "/download-23-24-lettings-form", to: "start#download_23_24_lettings_form"

Loading…
Cancel
Save