{% extends 'publisher/base.html' %}
{% load i18n %}
{% block title %}
    {% trans "Course Run List" %}
{% endblock title %}

{% block page_content %}
    <div class="layout-full layout">
        <div class="publisher-container">
            <h2 class="hd-2 emphasized">{{ object_list|length }} {% trans "Course runs in progress" %}</h2>
            <div class="depth depth-0">
                {% if object_list|length_is:"0" %}
                    <div class="empty-courserun-text">
                        <p>{% trans "Welcome to edX Publisher. It looks like you don't have any courses." %}</p>
                        <p>
                            {% url 'publisher:publisher_courses_new' as new_course_url %}
                            {% with link_start='<a href="' link_middle='">' link_end='</a>' %}
                                {% blocktrans trimmed %}
                                    Please {{ link_start }}{{ new_course_url }}{{ link_middle }}add a new course{{ link_end }} to create your first run
                                {% endblocktrans %}
                            {% endwith %}
                        </p>
                    </div>
                {% else %}
                    <table class="table">
                        <tr>
                            <th>{% trans "Course Run Title" %}</th>
                            <th>{% trans "Course Run Start Date" %}</th>
                            <th>{% trans "Partner" %}</th>
                            <th>{% trans "Target Content?" %}</th>
                            <th>{% trans "Priority" %}</th>
                            <th>{% trans "Status" %}</th>
                            <th>{% trans "Last Updated" %}</th>
                        </tr>
                        {% for course_run in object_list %}
                            {% url 'publisher:publisher_course_run_detail' course_run.id as detail_url %}
                            <tr>
                                <td>
                                    <a href="{{ detail_url }}">{{ course_run.title }}</a>
                                </td>
                                <td>{{ course_run.start }}</td>
                                <td>{{ course_run.partner }}</td>
                                <td>{{ course_run.target_content }}</td>
                                <td>{{ course_run.priority }}</td>
                                <td>{{ course_run.workflow_state }}</td>
                                <td>{{ course_run.modified }}</td>
                            </tr>
                        {% endfor %}
                    </table>
                {% endif %}
            </div>
            <br>
            <h2 class="hd-2 emphasized">{% trans "Recently published courses" %}</h2>
            <div class="depth depth-0">
                {% if published_courseruns|length_is:"0" %}
                    <p class="empty-courserun-text">{% trans "Looks like you haven't publish a course yet" %}</p>
                {% else %}
                    <table class="table">
                        <tr>
                            <th>{% trans "Course Run Title" %}</th>
                            <th>{% trans "Course Run Start Date" %}</th>
                            <th>{% trans "Partner" %}</th>
                            <th>{% trans "Target Content?" %}</th>
                            <th>{% trans "Priority" %}</th>
                            <th>{% trans "Status" %}</th>
                            <th>{% trans "Last Updated" %}</th>
                        </tr>
                        {% for course_run in published_courseruns %}
                            {% url 'publisher:publisher_course_run_detail' course_run.id as detail_url %}
                            <tr>
                                <td>
                                    <a href="{{ detail_url }}">{{ course_run.title }}</a>
                                </td>
                                <td>{{ course_run.start }}</td>
                                <td>{{ course_run.partner }}</td>
                                <td>{{ course_run.target_content }}</td>
                                <td>{{ course_run.priority }}</td>
                                <td>{{ course_run.workflow_state }}</td>
                                <td>{{ course_run.modified }}</td>
                            </tr>
                        {% endfor %}
                    </table>
                {% endif %}
            </div>
        </div>
    </div>
{% endblock %}
