bcgoss/census

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

Summary

Maintainability
Test Coverage
<div class='container'>
<h2>Account Profile</h2>
<table>
  <%= render 'account_profile_row',
      header: "First name",
      data: @user.first_name %>
  <%= render 'account_profile_row',
      header: "Last name",
      data: @user.last_name %>
  <%= render 'account_profile_row',
      header: "Email",
      data: @user.email %>
  <%= render 'account_profile_row',
      header: "Slack",
      data: @user.slack %>
  <%= render 'account_profile_row',
      header: "Cohort",
      data: @user.cohort %>
  <%= render 'account_profile_row',
      header: "Twitter",
      data: @user.twitter %>
  <%= render 'account_profile_row',
      header: "LinkedIn",
      data: @user.linked_in %>
  <%= render 'account_profile_row',
      header: "GitHub",
      data: @user.git_hub %>
  <%= render 'account_profile_row',
      header: "Roles",
      data: @user.list_roles %>
</table>
<% if @user == current_user %>
<%= render 'affiliations' %>
<%= link_to 'Change password', edit_user_registration_path%>
<%= link_to "Edit profile", edit_user_path(@user), class: 'btn btn-default' %>
<%= link_to "Edit affiliations", new_affiliation_path, class: 'btn btn-default' %>
<hr />
<h3>Oauth</h3>
<p>Manage the applications you have registered with Census:</p>
<%= link_to 'Registered Applications', oauth_applications_path, class: 'btn btn-info' %><br><br>
<p>View the applications you have given permission to user your data:</p>
<%= link_to 'Authorized Applications', oauth_authorized_applications_path, class: 'btn btn-success' %>
<% elsif user_is_admin? %>
<h3>Change Roles</h3>
  <% if @user.roles.where(name: 'active student').exists? %>
    <%= link_to 'Graduated', admin_user_path(@user, role: 'graduated'), method: :patch %>
    <%= link_to 'Removed', admin_user_path(@user, role: 'removed'), method: :patch %>
    <%= link_to 'Exited', admin_user_path(@user, role: 'exited'), method: :patch %>
  <% elsif @user.roles.where(name: 'applicant').exists? %>
    <%= link_to 'Enroll', admin_user_path(@user, role: 'active student'), method: :patch %>
  <% end %>
<% end %>
</div>