Skip to content

Commit 87bb19e

Browse files
committed
Add 'Show on a map' links to archived petitions
1 parent db509c4 commit 87bb19e

3 files changed

Lines changed: 12 additions & 0 deletions

File tree

app/models/archived/petition.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ class Petition < ActiveRecord::Base
5959
default_scope { preload(:parliament) }
6060

6161
delegate :threshold_for_response, :threshold_for_debate, to: :parliament
62+
delegate :show_on_a_map?, to: :parliament
6263

6364
with_options allow_nil: true, prefix: true do
6465
delegate :name, :email, to: :creator

app/models/parliament.rb

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
class Parliament < ActiveRecord::Base
44
include ActiveSupport::NumberHelper
55

6+
CUTOFF_DATE = Date.civil(2015, 5, 7)
7+
68
has_many :petitions, inverse_of: :parliament, class_name: "Archived::Petition"
79

810
class << self
@@ -184,4 +186,8 @@ def formatted_threshold_for_response
184186
def formatted_threshold_for_debate
185187
number_to_delimited(threshold_for_debate)
186188
end
189+
190+
def show_on_a_map?
191+
opening_at > CUTOFF_DATE
192+
end
187193
end

app/views/archived/petitions/show.html.erb

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,11 @@
6666
<div class="signature-count-graph" aria-hidden="true">
6767
<span class="signature-count-current" style="width: <%= archived_threshold_percentage(@petition) %>"></span>
6868
</div>
69+
<% if @petition.show_on_a_map? %>
70+
<p class="signatures-on-a-map">
71+
<a href="https://petitionmap.unboxedconsulting.com/?petition=<%= @petition.id %>">Show on a map</a>
72+
</p>
73+
<% end %>
6974
<p class="signature-count-goal">
7075
<%= number_with_delimiter(archived_threshold(@petition)) %>
7176
</p>

0 commit comments

Comments
 (0)