mfvico/gCamp

View on GitHub
app/views/projects/index.html.erb

Summary

Maintainability
Test Coverage

<% if notice != nil %>
  <p class="alert alert-success" id="notice"><%= notice  %></p>
<% end %>
<%= page_header "Projects" do %>
  <%= link_to "New Project", new_project_path, class: "btn btn-primary" %>
<% end %>



<table class="table">
  <thead>
    <th>Project</th>
    <th>Members</th>
    <th>Tasks</th>
  </thead>
  <tbody>
    <% if current_user.admin == true %>
      <% @projects.each do |project| %>
        <tr>
          <td class="col-md-4"><%= link_to project.name, project_path(project) %></td>
          <td><%= link_to project.memberships.count, project_memberships_path(project) %></td>
          <td><%= link_to project.tasks.count, project_tasks_path(project) %></td>
        </tr>
      <% end %>
    <% else %>
      <% current_user.projects.each do |project| %>
        <tr>
          <td class="col-md-4"><%= link_to project.name, project_path(project) %></td>
          <td><%= link_to project.memberships.count, project_memberships_path(project) %></td>
          <td><%= link_to project.tasks.count, project_tasks_path(project) %></td>
        </tr>
      <% end %>
    <% end %>
  </tbody>
</table>

<% if current_user.tracker_token %>
  <div class="page-header">
    <h1>Pivotal Tracker Projects</h1>
  </div>

  <table class="table">
    <thead>
      <th>Name</th>
    </thead>
    <tbody>
    <% @tracker_projects.each do |tracker_project| %>
      <tr>
        <td>
          <%= link_to tracker_project[:name], tracker_project_path(tracker_project[:id]) %>
        </td>
      </tr>
    <% end %>
    </tbody>
  </table>
<% end %>


  <hr>