opengovernment/askthem

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

Summary

Maintainability
Test Coverage
<%- if @is_unaffiliated %>
  <p>&nbsp;</p>
<%- else %>
  <%= render 'shared/navigation' %>
<%- end %>

<section class="people">
  <header>
    <%= render @blurb if @blurb %>

    <div class="person_info">
      <% if @person.image? %>
        <div class="avatar">
          <%= cdn_image_tag(@person.image, state: @person.state, size: '80x80', alt: '', class: 'person_photo') %>
        </div>
      <% else %>
        <%= image_tag('placeholder.png', size: '80x80', alt: '') %>
      <% end %>

      <div class="person_details">
        <h1>
          <%= @person.name %>
        </h1>
        <h2><%= person_attributes(@person) %></h2>
        <% if @person.verified? -%>
          <i class='icon-ok-sign is-verified'><span> AskThem Verified</span></i>
        <% end -%>
        <div class="attr">
          <span class="count"><%= pluralize @person.questions.count, 'question' %></span>
          <%- if @person.questions_answered.count > 0 %>
            <span class="count"><%= link_to(pluralize(@person.questions_answered.count, "answer"), have_answers_questions_path(@person.state, person: @person)) -%></span>
          <%- end %>
        </div>
      </div>

      <% if @person.person_detail.biography? %>
        <p class="person_wikipedia"><%= truncate(@person.person_detail.biography, length: 130) %> <%= link_to 'Read more on Wikipedia', @person.person_detail.links.find_by(note: 'Wikipedia').url %></p>
      <% end %>
    </div>
    <%= link_to 'Ask this person a Question', new_question_path(@jurisdiction.abbreviation, person: @person), class: 'cta-pill' %>
  </header>

  <div class="related_wrap">
    <div class="related_data">
      <nav>
        <ul class="related_nav">
          <li><%= link_to 'Questions', person_path(@jurisdiction.abbreviation, @person.id), tab_options('questions', 'show') %></li>
          <%- if @person.is_a? StateLegislator %>
            <li><%= link_to 'Sponsored Bills', bills_person_path(@jurisdiction.abbreviation, @person.id), tab_options('bills') %></li>
            <li><%= link_to 'Votes', votes_person_path(@jurisdiction.abbreviation, @person.id), tab_options('votes') %></li>
            <li><%= link_to 'Committees', committees_person_path(@jurisdiction.abbreviation, @person.id), tab_options('committees') %></li>
          <% end %>
          <%- unless @person.state == Metadatum::Unaffiliated::ABBREVIATION %>
            <li><%= link_to 'Interest Groups', ratings_person_path(@jurisdiction.abbreviation, @person.id), tab_options('ratings') %></li>
          <%- end %>
        </ul>
      </nav>

      <div class="related_content">
        <%= render partial: @tab %>
        <aside>
          <%- if staff_member? -%>
            <div class="question-controls">
              <h4>Staff Actions:</h4>
              <ul>
                <li>
                  <%- unless @person.featured? %>
                    <%= form_for @person,
                      url: person_path(@jurisdiction, @person),
                      html: { style: "inline" } do |f| -%>
                      <%= f.hidden_field :featured, value: true -%>
                      <%= f.submit "Make Featured", class: "cta-pill" %>
                    <%- end %>
                  <%- end %>
                </li>
                <li>
                  <%= link_to "Add blurb",
                  new_blurb_path(target_url: person_path(@jurisdiction, @person)),
                  class: "cta-pill" %>
                </li>
              </ul>
            </div>
          <%- end %>

          <% if @person.email? %>
            <section>
              <h4>Email:</h4><p><%= mail_to @person.email %></p>
            </section>
          <% end %>

          <% if @person.twitter_id.present? %>
            <section>
              <h4>Twitter:</h4>
              <p>
                <%= link_to "@#{@person.twitter_id}", "//twitter.com/#{@person.twitter_id}" -%>
              </p>
            </section>
          <% end %>

          <% if @person['offices'] -%>
            <% @person['offices'].each do |office| %>
              <section>
                <% if office['type'] %>
                  <h4>
                    <%=t office['type'], scope: [:offices, :types], default: office['type'] %>
                  </h4>
                <% end %>
                <ul>
                  <% if office['phone'] && office['address'].is_a?(String) %>
                    <li>Tel: <%= office['phone'] %></li>
                  <% end %>
                  <% if office['fax'] && office['address'].is_a?(String) %>
                    <li>Fax: <%= office['fax'] %></li>
                  <% end %>
                  <% if office['address'] && office['address'].is_a?(String) %>
                    <li><%= simple_format office['address'] %></li>
                  <% end %>
                </ul>
              </section>
            <% end %>
          <% end %>
        </aside>
      </div>
    </div>
  </div>
</section>