Skip to content

Commit 979b711

Browse files
Merge pull request #143 from ukparliament/populate-constituency-group-sets
populate constituency group sets
2 parents 0a75dbd + 3ec03df commit 979b711

File tree

14 files changed

+5517
-8
lines changed

14 files changed

+5517
-8
lines changed

Gemfile.lock

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -293,7 +293,7 @@ GEM
293293
websocket-extensions (0.1.5)
294294
xpath (3.2.0)
295295
nokogiri (~> 1.8)
296-
zeitwerk (2.7.4)
296+
zeitwerk (2.7.5)
297297

298298
PLATFORMS
299299
aarch64-linux

app/controllers/election_controller.rb

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -93,8 +93,8 @@ def show
9393
# If the election forms part of a general election ...
9494
if @general_election
9595

96-
# ... and if the general election does not have full results ...
97-
if @general_election.publication_state < 3
96+
# ... and if the general election does not have full results and the election is not verified ...
97+
if @general_election.publication_state < 3 and @election.is_verified == false
9898

9999
# ... we order the candidacies by family name, then given name.
100100
@candidacies
@@ -114,8 +114,8 @@ def show
114114
# ... we render the candidates only template.
115115
render :template => 'election/show_candidates_only'
116116

117-
# If the general election has winners ...
118-
elsif @general_election.publication_state == 2
117+
# If the general election has winners and the election is not verified ...
118+
elsif @general_election.publication_state == 2 and @election.is_verified == false
119119

120120
# ... we order the candidacies by result position, then family name, then given name.
121121
@candidacies
@@ -179,6 +179,7 @@ def get_election( election_id )
179179
( cast(e.majority as decimal) / e.valid_vote_count ) AS majority_percentage,
180180
constituency_group.name AS constituency_group_name,
181181
constituency_area.constituency_area_id AS constituency_area_id,
182+
constituency_area.geographic_code AS constituency_area_geographic_code,
182183
winning_candidacy.candidate_given_name AS winning_candidate_given_name,
183184
winning_candidacy.candidate_family_name AS winning_candidate_family_name,
184185
electorate.population_count AS electorate_population_count,
@@ -203,7 +204,7 @@ def get_election( election_id )
203204
ON constituency_group.id = e.constituency_group_id
204205
205206
LEFT JOIN (
206-
SELECT cg.id AS constituency_group_id, ca.id AS constituency_area_id
207+
SELECT cg.id AS constituency_group_id, ca.id AS constituency_area_id, ca.geographic_code AS geographic_code
207208
FROM constituency_groups cg, constituency_areas ca
208209
WHERE cg.constituency_area_id = ca.id
209210
) constituency_area

app/helpers/election_helper.rb

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,4 +25,16 @@ def election_constituency_area_name_with_boundary_set_dates( election, boundary_
2525
end
2626
name
2727
end
28+
29+
def bbc_election_link( election )
30+
bbc_election_link = "https://www.bbc.co.uk/news/election/"
31+
bbc_election_link += election.polling_on.strftime( '%Y' )
32+
bbc_election_link += "/uk/constituencies/"
33+
bbc_election_link += election.constituency_area_geographic_code
34+
end
35+
36+
def bbc_election_link_title( election )
37+
bbc_election_link = election.constituency_group_name
38+
bbc_election_link += " results from the BBC."
39+
end
2840
end

app/models/boundary_set.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ class BoundarySet < ApplicationRecord
2323
attr_accessor :child_boundary_sets
2424

2525
belongs_to :country
26+
has_many :boundary_set_legislation_items
2627

2728
def display_title
2829
display_title = self.country_name

app/models/election.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
# declaration_at :datetime
77
# invalid_vote_count :integer
88
# is_notional :boolean default(FALSE)
9+
# is_verified :boolean default(TRUE)
910
# majority :integer
1011
# polling_on :date not null
1112
# valid_vote_count :integer

app/views/election/show_winners_only.html.erb

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,4 +29,7 @@
2929

3030
<%= render :partial => 'vote_change_disclaimer' %>
3131

32-
<%= render :partial => 'notional_based_change_disclaimer', :object => @boundary_set_having_first_general_election, :locals => {:election => @election} if @boundary_set_having_first_general_election %>
32+
<%= render :partial => 'notional_based_change_disclaimer', :object => @boundary_set_having_first_general_election, :locals => {:election => @election} if @boundary_set_having_first_general_election %>
33+
34+
35+
<%= content_tag( 'p', "The House of Commons Library are currently contacting local authorities to verify vote figures. In the meantime, #{link_to( 'unverified vote numbers for this constituency are available from the BBC', bbc_election_link( @election ), :title => bbc_election_link_title( @election ) )}.".html_safe ) %>

config/database.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ development: &development
66
#database: psephology_dissolution
77
#database: psephology_candidacies
88
#database: psephology_winners
9+
#database: psephology_part_verified
910
#database: psephology_numbers
1011
host: localhost
1112
pool: 5

0 commit comments

Comments
 (0)