{% load i18n %}
{% load cookie_consent_tags %}


<div class="cookie-group">
    <div class="cookie-group-title">
        <h3>{{ cookie_group.name }}</h3>

        {% if not cookie_group.is_required %}
            <div class="cookie-group-form">
                {% with accepted=request|cookie_group_accepted:cookie_group.varname %}
                    {% with declined=request|cookie_group_declined:cookie_group.varname %}

                        {% if not accepted %}
                            <form class="cookie-consent-accept formrm   "
                                  action="{% url "cookie_consent_accept" cookie_group.varname %}"
                                  method="POST">
                                {% csrf_token %}
                                {% if declined %}
                                    <span
                                        class="btn btn-outline-danger btn-sm cookie-consent-declined disabled">{% trans "Declined" %}</span>
                                {% endif %}
                                <input type="submit" class="btn btn-success btn-sm" value="{% trans "Accept" %}">
                            </form>
                        {% endif %}
                        {% if not declined %}
                            <form class="cookie-consent-decline"
                                  action="{% url "cookie_consent_decline" cookie_group.varname %}" method="POST">
                                {% csrf_token %}
                                {% if accepted %}
                                    <span
                                        class="btn btn-outline-success btn-sm cookie-consent-accepted disabled">{% trans "Accepted" %}</span>
                                {% endif %}
                                <input type="submit" class="btn btn-danger btn-sm" value="{% trans "Decline" %}">
                            </form>
                        {% endif %}
                    {% endwith %}
                {% endwith %}
            </div>
        {% endif %}

    </div>

    <p>
        {{ cookie_group.description }}
    </p>
    <table class="table table-striped table-hover">
        {% for cookie in cookie_group.cookie_set.all %}
            <tr>
                <th>
                    <code>{{ cookie.name }}</code>
                    {% if cookie.domain %}
                        ({{ cookie.domain }})
                    {% endif %}
                </th>
                <td>
                    {% if cookie.description %}
                        {{ cookie.description }}
                    {% endif %}
                </td>
            </tr>
        {% endfor %}
    </table>
</div>
