opengovernment/askthem

View on GitHub
app/views/people/_person.html.erb

Summary

Maintainability
Test Coverage
<% with_button = @only_show && @only_show == "people" %>

<li>
  <div class="avatar">
    <% if person.image? %>
      <%= cdn_image_tag(person.image, state: person.state, size: "60x60", alt: "") %>
    <% else %>
      <%= image_tag("placeholder.png", size: "60x60", alt: "") %>
    <% end %>
  </div>
  <div class="person-info">
    <h2><%= link_to person.name, person_path(person["state"], person) %>&nbsp;&nbsp;<% if person.verified? -%><i class="icon-ok-sign is-verified"><span class="verified-tooltip">AskThem Verified</span></i><% end -%></h2>
    <span class="jurisdiction"><%= person_attributes(person) %></span>
    <span class="stats">
      <%- if person.questions.count > 0 %>
        <span><%= pluralize person.questions.count, "Question" %></span>
        <%- if person.questions_answered.count > 0 %>
          <span><%= link_to(pluralize(person.questions_answered.count, "Answer"), have_answers_questions_path(person.state, person: person)) -%></span>
        <%- end %>
      <%- elsif with_button == false %>
        <%= link_to "Ask the first question >>", new_question_path(person.state, person: person) -%>
      <%- end %>
    </span>
    <%- if with_button %>
      <%= link_to "Ask question", new_question_path(person.state, person: person), class: "cta-pill person-list-button" -%>
    <%- end %>
  </div>
</li>