vincenttian/61A-Lab-Assistant

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

Summary

Maintainability
Test Coverage
<div class="container">
    <br>
    <h1 align="center"> Lab Time <%= @l.id %> Detail View</h1>

    <% if @current_user.is_a? Admin %>
        <h4> Assign Lab Assistant To Lab Time <%= @l.id %> </h4>
        <p> 
            <%= form_for @l do |f| %>
                
              <% case @l.course_id%>
              <% when 1 %>
                    <% options = options_from_collection_for_select(@a_las, 'id', 'email') %>
              <% when 2 %>
                  <% options = options_from_collection_for_select(@b_las, 'id', 'email') %>
              <% when 3 %>
                  <% options = options_from_collection_for_select(@c_las, 'id', 'email') %>    
              <% else %>
                  <!-- more classes in future -->
              <% end %>
              <%= f.select :id,  options, { include_blank: true }, { class: "form-control form-time" } %>
              <%= f.hidden_field :lab_time_id, :value => @l.id %>
              <input name="assign_la" type="submit" value="Assign LA" class="btn btn-primary">
            <% end %>
        </p>

    <br><br>    
    <% end %>

    <h4>Current Teaching Assistant:</h4>
    <p> 
        <% for ta in @l.teaching_assistants.to_a do %>
          <% if @current_user.is_a? LabAssistant %>
            <%= ta.email %>
          <% else %>
            <a href=<%= teaching_assistant_path(ta)%>> <%= ta.email %> </a>
          <% end %>
        <% end %>
    </p>

    <h4>Current Lab Assistants:</h4>

    <% unless @curr_las.empty? %>
        <table class="table table-bordered table-hover table-striped">
            <thead>
                <th>E-mail</th>
            </thead>
            <tbody>
            <% if @current_user.is_a? LabAssistant %>
                <% for c in @curr_las %>
                    <tr>
                        <td> <%= c.email %> </td>
                    </tr>
                <% end %>
              <% else %>
                <% for c in @curr_las %>
                    <tr>

                        <td> <a href=<%= lab_assistant_path(c)%>> <%= c.email %> </a> </td>
                    </tr>
                <% end %>
            <% end %>
            </tbody>
        </table>
    <% else %>
        <p> No Lab Assistants Assigned to Lab Yet </p>
    <% end %>
</div>