{% extends 'dashboard/layout.html' %}
{% load i18n %}

{% block body_class %}{{ block.super }} content-blocks{% endblock %}

{% block title %}
    {% trans "Content blocks" %} | {{ block.super }}
{% endblock %}

{% block header %}
    <div class="page-header">
        <h1>{% trans "Content blocks" %}</h1>
    </div>
{% endblock header %}

{% block breadcrumbs %}
    <ul class="breadcrumb">
        <li>
            <a href="{% url 'dashboard:index' %}">{% trans "Dashboard" %}</a>
            <span class="divider">/</span>
        </li>
        <li class="active">{% trans "Content block management" %}</li>
    </ul>
{% endblock %}

{% block dashboard_content %}
    <div class="table-header">
        <h3><i class="icon-folder-close icon-large"></i>{% trans "Create a new content block" %}</h3>
    </div>
    <div class="well">
        <form action="{% url 'dashboard:promotion-create-redirect' %}" method="get" class="form-inline">
            {% include "partials/form_fields_inline.html" with form=select_form %}
            <button type="submit" class="btn btn-primary"><i class="icon-plus"></i> {% trans "Create block" %}</button>
        </form>
    </div>

    <table class="table table-striped table-bordered table-hover">
        <caption><i class="icon-folder-close icon-large"></i>{% trans "Content blocks" %}</caption>
        {% if num_promotions %}
            <thead>
                <tr>
                    <th>{% trans "Name" %}</th>
                    <th>{% trans "Type" %}</th>
                    <th>{% trans "Number of times used" %}</th>
                    <th>{% trans "Date created" %}</th>
                    <th>{% trans "Actions" %}</th>
                </tr>
            </thead>
            <tbody>
                {% for promotion in promotions %}
                    <tr>
                        <td><a href="{% url 'dashboard:promotion-update' ptype=promotion.code pk=promotion.id %}">{{ promotion.name }}</a></td>
                        <td>{{ promotion.type }}</td>
                        <td>{{ promotion.num_times_used }}</td>
                        <td>{{ promotion.date_created }}</td>
                        <td>
                            <div class="btn-toolbar">
                                <div class="btn-group">
                                    <a class="btn dropdown-toggle" data-toggle="dropdown" href="#">
                                        {% trans "Actions" %}
                                        <span class="caret"></span>
                                    </a>
                                    <ul class="dropdown-menu pull-right">
                                        <li><a href="{% url 'dashboard:promotion-update' ptype=promotion.code pk=promotion.id %}">{% trans "Edit" %}</a></li>
                                        <li><a href="{% url 'dashboard:promotion-delete' ptype=promotion.code pk=promotion.id %}">{% trans "Delete" %}</a></li>
                                    </ul>
                                </div>
                            </div>
                        </td>
                    </tr>
                {% endfor %}
            </tbody>
        {% else %}
            <tr><td>{% trans "No content blocks found." %}</td></tr>
        {% endif %}
    </table>
{% endblock dashboard_content %}
