Skip to content

Commit

Permalink
Merge pull request #940 from alphagov/disable-site-features-when-closed
Browse files Browse the repository at this point in the history
Update site now parliament has dissolved
  • Loading branch information
pixeltrix authored May 30, 2024
2 parents 7bee2bd + b9d95f1 commit fd00e07
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 6 deletions.
10 changes: 10 additions & 0 deletions app/controllers/local_petitions_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down Expand Up @@ -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"
Expand Down
2 changes: 1 addition & 1 deletion app/views/application/_footer.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<ul id="footer_nav">
<li><%= link_to 'Home', home_path %></li>
<li><%= link_to 'All petitions', petitions_path %></li>
<% unless Site.disable_petition_creation? %>
<% unless Site.disable_petition_creation? || Parliament.closed? %>
<li><%= link_to 'Start a petition', check_petitions_path %></li>
<% end %>
<li><%= link_to 'How petitions work', help_path %></li>
Expand Down
12 changes: 7 additions & 5 deletions app/views/pages/home/_local_petitions.html.erb
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<section class="section-panel local-to-you" aria-labelledby="local-to-you-heading">
<h2 id="local-to-you-heading">Local to you</h2>
<p>Find petitions being signed by people near you</p>
<%= render 'local_search' %>
</section>
<% unless Parliament.closed? %>
<section class="section-panel local-to-you" aria-labelledby="local-to-you-heading">
<h2 id="local-to-you-heading">Local to you</h2>
<p>Find petitions being signed by people near you</p>
<%= render 'local_search' %>
</section>
<% end %>

0 comments on commit fd00e07

Please sign in to comment.