openaustralia/publicwhip

View on GitHub
app/views/policies/_vote_summary.html.haml

Summary

Maintainability
Test Coverage
- divisions = policy.divisions.order(date: :desc, clock_time: :desc, name: :asc, number: :desc)
-# We're only including divisions where one or more of the people could have attended
- divisions = divisions.select{ |d| people.any? { |p| p.could_have_voted_in_division?(d) } } unless people.empty?

%h3 Most important divisions relevant to this policy
%p
  = succeed "." do
    These are the most important divisions related to the policy “#{policy.name_with_for}”
    - if people.count > 0
      which
      - if people.count == 1
        = people.first.name
      - else
        either
        = list_in_words(people.map(&:name), "or")
      could have attended
  They are weighted much
  more strongly than other divisions when calculating the position of
  = people.empty? ? "a person" : list_in_words(people.map(&:name))
  on this policy.
  - if people.count > 1
    Where a person could not have attended a division because they were not a member of parliament at the time (or in the wrong house)
    it is marked as "-".
= render "policies/vote_summary_table", people: people, policy: policy, divisions: divisions.select{ |d| d.policy_vote_strong?(policy) }

%h3 Other divisions relevant to this policy
%p
  = succeed "." do
    These are less important divisions which are related to the policy “#{policy.name_with_for}”
    - if people.count > 0
      which
      - if people.count == 1
        = people.first.name
      - else
        either
        = list_in_words(people.map(&:name), "or")
      could have attended    
  - if people.count > 1
    Where a person could not have attended a division because they were not a member of parliament at the time (or in the wrong house)
    it is marked as "-".
= render "policies/vote_summary_table", people: people, policy: policy, divisions: divisions.select{ |d| !d.policy_vote_strong?(policy) }