{% extends "base.html" %}
{% load static i18n %}
{% load terms_tags %}
{% load socialaccount %}


{% block content %}
  <div class="tab-content p-2">
    <div class="tab-pane active">

    {% if not request.user.is_anonymous %}
      {% if agreed_terms|length > 0 %}
      <div class="card">
        <div class="card-header"><h2>You have accepted the following terms and conditions</h2></div>
        <div class="card-body">
          <ul>
          {% for terms in agreed_terms %}
            <li>
              <a class="terms-link" href="{% url 'tc_view_specific_version_page' terms.slug terms.version_number %}{% if returnTo %}?returnTo={{ returnTo }}{% endif %}">
              {% if terms.name %}{{ terms.name|safe }}, {% endif %}version {{ terms.version_number }}
              </a>
            </li>
          {% endfor %}
          </ul>

        </div>
      </div>
      {% endif %}

      {% if not_agreed_terms|length > 0 %}
      <div class="card">
        <div class="card-header"><h2>Terms and Conditions not accepted yet</h2></div>
        <div class="card-body">
          <ul>
          {% for terms in not_agreed_terms %}
              <li>
                <a class="terms-link" href="{% url 'tc_accept_specific_page' terms.slug %}{% if returnTo %}?returnTo={{ returnTo }}{% endif %}">
                {% if terms.name %}{{ terms.name|safe }}{% endif %}
                </a>
              </li>
          {% endfor %}
          </ul>
        </div>
      </div>
      {% endif %}
    {% else %}

      {# This is shown to anonymous users #}
      {% for terms in active_terms %}
        <div class="card">
          <div class="card-header"><h2>{{ terms.name|safe }}</h2></div>
          <div class="card-body">
            {{ terms.text|safe }}
          </div>
        </div>
       {% endfor %}

      <p>If you want to use this site, <a href="{% provider_login_url 'orcid' method="oauth2" %}">sign in via ORCID</a>.
      Afterwards you have the possibility to review and accept terms and conditions.</p>

    {% endif %}
    </div>
  </div>

{% endblock %}
