{% extends 'base_main.html' %}

{% block title %}сеты{% endblock %}

{% block main %}
    <table>
        <tr>
            <td>
                <h2>Сеты</h2>
            </td>
            {% if user.userinfo.can_create %}
                <td>
                    <button style="margin-left: 20px;" class="btn btn-success" data-toggle="modal" data-target="#example"><i class="fa fa-plus"></i></button>
                <div class="modal fade" id="example" tabindex="-1" role="dialog" aria-labelledby="exampleModalLongTitle" aria-hidden="true">
              <div class="modal-dialog" role="document">
              <form method="POST">
                <div class="modal-content">
                  <div class="modal-header">
                    <h5 class="modal-title" id="exampleModalLongTitle">Создать новый сет</h5>
                    <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                      <span aria-hidden="true">&times;</span>
                    </button>
                  </div>
                  <div class="modal-body">
                    <div class="container-fluid">
                        <div class="row">
                            <div class="col-12">
                            {% csrf_token %}
                            <input type="text" name="name" placeholder="Название сета">
                            </div>
                        </div>
                    </div>
                  </div>
                  <div class="modal-footer">
                    <button type="button" class="btn btn-danger" data-dismiss="modal"><i class="fa fa-times-circle"></i> Закрыть</button>
                    <button type="submit" class="btn btn-success"><i class="fa fa-plus-circle"></i> Создать</button>
                  </div>
                </div>
              </form>
              </div>
            </div>
                </td>
            {% endif %}
        </tr>
    </table>
    {% for set in user.userinfo.available_sets %}
        <a href="/set?set_id={{ set.id }}">{{ set.name }}</a> {% if set.creator == user or user.username in set.editors %}<a href="/admin/set?set_id={{ set.id }}"><i class="fa fa-pencil"></i> </a><a href="/solutions?set_id={{ set.id }}"><i class="fa fa-stack-overflow"></i> </a>{% endif %}<br>
    {% endfor %}
{% endblock %}
