From 36d682f42deb18f21cdb41a20eea0630c047528b Mon Sep 17 00:00:00 2001 From: Andrew White Date: Thu, 30 May 2024 05:51:55 +0100 Subject: [PATCH 1/2] Disable local petitions when the site is closed This hasn't been done previously but now the lookup API is returning the new constituencies it's not helpful to have it available. --- app/controllers/local_petitions_controller.rb | 10 ++++++++++ app/views/pages/home/_local_petitions.html.erb | 12 +++++++----- 2 files changed, 17 insertions(+), 5 deletions(-) diff --git a/app/controllers/local_petitions_controller.rb b/app/controllers/local_petitions_controller.rb index 1f38269d4..353830c69 100644 --- a/app/controllers/local_petitions_controller.rb +++ b/app/controllers/local_petitions_controller.rb @@ -2,6 +2,8 @@ require 'csv' class LocalPetitionsController < ApplicationController + before_action :redirect_to_home_page, if: :parliament_closed? + before_action :sanitize_postcode, only: :index before_action :find_by_postcode, if: :postcode?, only: :index before_action :find_by_slug, only: [:show, :all] @@ -71,6 +73,14 @@ def redirect_to_constituency end end + def redirect_to_home_page + redirect_to home_url + end + + def parliament_closed? + Parliament.closed? + end + def csv_filename if action_name == 'all' "all-popular-petitions-in-#{@constituency.slug}.csv" diff --git a/app/views/pages/home/_local_petitions.html.erb b/app/views/pages/home/_local_petitions.html.erb index aac4d73e0..9a0f36525 100644 --- a/app/views/pages/home/_local_petitions.html.erb +++ b/app/views/pages/home/_local_petitions.html.erb @@ -1,5 +1,7 @@ -
-

Local to you

-

Find petitions being signed by people near you

- <%= render 'local_search' %> -
+<% unless Parliament.closed? %> +
+

Local to you

+

Find petitions being signed by people near you

+ <%= render 'local_search' %> +
+<% end %> From b9d95f13adfb2043c008bf1a03bc2918258b7474 Mon Sep 17 00:00:00 2001 From: Andrew White Date: Thu, 30 May 2024 05:54:20 +0100 Subject: [PATCH 2/2] Remove the start petition link from the footer when the site is closed --- app/views/application/_footer.html.erb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/application/_footer.html.erb b/app/views/application/_footer.html.erb index 41025be2a..f8fe0a0f3 100644 --- a/app/views/application/_footer.html.erb +++ b/app/views/application/_footer.html.erb @@ -3,7 +3,7 @@