anyone-oslo/pages

View on GitHub
app/views/admin/users/show.html.erb

Summary

Maintainability
Test Coverage
<% content_for :page_title, @user.name %>

<% content_for :page_description do %>
  You are viewing
  <%= link_to((@user == current_user ? "your own profile" : "#{@user.name}"),
              [:admin, @user]) %>
<% end %>

<% content_for(:page_description_links) do %>
  <%= link_to("Edit", edit_admin_user_path(@user)) if policy(@user).edit? %>
<% end %>

<% content_for :sidebar do %>
  <h2>People</h2>
  <% if @user.created_users.count > 0 -%>
    <p><%= @user.name %> has invited <%= @user.created_users.count %> users:</p>
    <ul>
      <% @user.created_users.each do |created_user| %>
        <li><%= link_to created_user.name, admin_user_url( created_user ) %></li>
      <% end %>
    </ul>
  <% else -%>
    <p><%= @user.name %> hasn't invited any users.</p>
  <% end -%>
<% end %>

<div class="content">
  <% if @user.image -%>
    <div style="float: right;">
      <%= editable_dynamic_image_tag(@user.image) %>
    </div>
  <% end -%>
  <h2><%= @user.name %></h2>
  <table class="show">
    <tr>
      <th>Email address:</th>
      <td><%= mail_to @user.email %></td>
    </tr>
    <% if @user.creator %>
      <tr>
        <th>Invited by:</th>
        <td><%= link_to @user.creator.name, admin_user_url( @user.creator ) %> <%= time_ago_in_words @user.created_at %> ago.</td>
      </tr>
    <% end %>
    <% if @user.created_at? -%>
      <tr>
        <th>Member since:</th>
        <td>
          <%= @user.created_at.to_formatted_s :long %>
        </td>
      </tr>
    <% end -%>
    <% if @user.last_login_at? -%>
      <tr>
        <th>Last seen:</th>
        <td>
          <% if @user.online? -%>
            Online now
          <% else -%>
            <%= time_ago_in_words @user.last_login_at %> ago, on <%= @user.last_login_at.to_formatted_s :long %>
          <% end -%>
        </td>
      </tr>
    <% end -%>
  </table>
</div>