{% extends "bee_django_coin/base.html" %}

{% block content %}
    {% include 'bee_django_coin/logo.html' %}
    {% include 'bee_django_coin/nav.html' %}
    <div class="text-center"><h3>
        类型管理
    </h3>
    </div>
    <div class="text-right">
        <a class="btn btn-default" href="{% url 'bee_django_coin:coin_type_add' %}">添加金币类型</a>
    </div>
    <div>共{{ paginator.count }}个</div>
    <table class="table">
        <thead>
        <tr>
            <th>标识符</th>
            <th>类型</th>
            <th>金币</th>
            <th>说明</th>

        </tr>
        </thead>
        <tbody>
        {% for t in coin_type_list %}
            <tr>
                <td>{{ t.identity }}</td>
                <td>{{ t.name }}</td>
                <td>{{ t.coin }}</td>
                <td>{{ t.info|default:"" }}</td>


                <td>
                    <a href="{% url 'bee_django_coin:coin_type_update' t.id %}  ">修改</a>
                    <a href="#" id="delete_{{ t.id }}"
                       data-confirm="{% url "bee_django_coin:coin_type_delete" t.id %}"
                       onclick="click_del(this)">删除</a>
                </td>
            </tr>

        {% endfor %}
        </tbody>
    </table>
    {% include 'bee_django_coin/paginator.html' %}
{% endblock %}
{% block scripts %}
    <script>
        function click_del(_this) {
            if (!confirm('确认要执行这个操作？')) {
                return false;
            }
            var url = $(_this).attr('data-confirm');
            $.post(url).done(function (data) {
                alert('删除成功!');
                location.reload();
            });
        }
    </script>
{% endblock %}