{% extends "base.html" %}
{% load coursetags %}

{% block content %}

<div id="course-list" class="top-archive">
{% with "help_choose_course" as help_id %}
{% with show_help as default_help_state %}

<h2>Select a Course {% include "help/help_button.html" %}</h2>

{% include "help/help_contentarea.html" %}

{% comment %}{% endcomment %}

<!--<p>
  Hello, {{user.get_full_name|default:user}}!  Please select a course:
</p>-->

<div id="coursefilter">
Viewing courses for 
        {% if not list_all_link %}
          this year. <a href="?list_all=true{{next_redirect}}">View previous years.</a>
        {% else %}
          all years. <a href="?{{next_redirect}}">View this year only.</a>
        {% endif %}
        </div>

{% if add_privilege %}
<p class="create-course">
   <a class="project" href="{%url admin:courseaffils_course_add %}">Create new course</a>
</p>
{% endif %}

<table class="course-choices">
  <thead>
    <tr>
      <td>Course Titles
      </td>
      <td>Term</td>
      <td>Instructor</td>
      <td>Role</td> 
      {% if add_privilege %} 
        <td>Actions</td>

      {% endif %}    
    </tr>
  </thead>
  <tbody>
{% for course in courses %}
 <tr><td class="course-choice">
  <a class="choose-course" href="?set_course={{course.group.name|urlencode}}{{next_redirect}}">{{course.title}}</a>
  </td>
  <td>{{course.info.termyear}}</td>
  <td>{% if course.details.instructor %}{{course.details.instructor.value}}{% endif %}</td>
  <td>{% course_role for request.user in course as foo %}{{foo}}</td>
  {% if add_privilege %}
     <td class="manage-course">  
       <a class="project" href="{%url admin:courseaffils_course_change course.id %}">manage</a>
     </td>

  {% endif %}
 </tr>
{% endfor %}

<!--{% if not list_all_link %}
<tr class="course-choices-other-years">
  <td colspan="5">
      <a href="?list_all=true{{next_redirect}}">See your courses from previous years</a>
  </td>
</tr>
{% endif %}-->

</tbody>
</table>
{% endwith %}
{% endwith %}
</div>
{% endblock %}
