{% extends "base.html" %}

{% block title %}
    {% if subject %}
        Kursy z dziedziny: {{ subject.title }}
    {% else %}
        Wszystkie kursy
    {% endif %}
{% endblock %}

{% block content %}
<h1>
    {% if subject %}
        Kursy z dziedziny: {{ subject.title }}
    {% else %}
        Wszystkie kursy
    {% endif %}
</h1>
<div class="contents">
     <h3>Tematy</h3>
    <ul id="modules">
        <li {% if not subject %}class="selected"{% endif %}>
            <a href="{% url "course_list" %}">Wszystkie</a>
        </li>
        {% for s in subjects %}
            <li {% if subject == s %}class="selected"{% endif %}>
                <a href="{% url "course_list_subject" s.slug %}">
                    {{ s.title }}
                    <br><span>{{ s.total_courses }} courses</span>
                </a>
            </li>
        {% endfor %}
    </ul>
</div>
<div class="module">
    {% for course in courses %}
        {% with subject=course.subject %}
            <h3><a href="{% url "course_detail" course.slug %}">{{ course.title }}</a></h3>
            <p>
                <a href="{% url "course_list_subject" subject.slug %}">{{ subject }}</a>.
                {{ course.total_modules }} modules.
                Instruktor: {{ course.owner.get_full_name }}
            </p>
        {% endwith %}
    {% endfor %}
</div>
{% endblock %}