openaustralia/publicwhip

View on GitHub
app/views/members/_people.html.haml

Summary

Maintainability
Test Coverage
%ol.members-list.list-unstyled{:class => active_house_for_list_class(house)}
  - people.each do |person|
    %li
      = link_to person_path_simple(person), class: 'member-item object-item panel-link' do
        %article.media{class: ("member-no-photo" unless person.show_small_image?)}
          - if person.show_small_image?
            = image_tag("", data: {original: person.small_image_url}, alt: "Photo of #{person.name}", class: "member-photo lazy", width: 44, height: 58)
            %noscript
              = image_tag(person.small_image_url, alt: "Photo of #{person.name}", class: 'member-photo', width: 44, height: 58)
          .media-body
            %h2.media-heading.member-name.panel-link-title= person.name
            %p.member-role.object-primary
              %span.member-party.inline-post-title
                - if !person.currently_in_parliament?
                  Former
                = person.party_name
              %span.member-electorate= person.role

            %p.member-data.object-data.object-secondary
              - if person.rebellions_fraction
                %span.member-rebellions.object-data-rebellion
                  -if person.rebellions_fraction == 0
                    Never rebels
                  -else
                    -# TODO: Should this be an absolute count rather than percentage?
                    -# Maybe it's good to show it as a percentage because it highlights rarity?
                    Rebels
                    = fraction_to_percentage_display(person.rebellions_fraction)
                    of the time
                    -# TODO: add helper tooltip for rebellions
                    -# link_to "explain...", help_faq_path(anchor: "clarify")
              - if person.attendance_fraction
                %span.member-attendance.object-data-attendance
                  = fraction_to_percentage_display(person.attendance_fraction)
                  attendance
                  -# TODO: add helper tooltip for attendance
                  -# link_to "explain...", help_faq_path(anchor: "clarify")