{% extends "passerelle/manage/service_view.html" %}
{% load i18n passerelle %}

{% block description %}
  {% if object.description %}{{object.description|linebreaks}}{% endif %}

  <p>
    {% trans "File:" %}
    {% if object|can_edit:request.user %}<a href="{% url 'csv-download' connector_slug=object.slug %}">{{object.csv_file}}</a>
      — {% trans "added on" %} {{object.csv_file_datetime}}
    {% else %}{{object.csv_file}}{% endif %}
  </p>
{% endblock %}

{% block endpoints %}
  <h4>{% trans "Access" %}</h4>
  <ul class="endpoints">
    {% url 'generic-endpoint' connector='csvdatasource' slug=object.slug endpoint='data' as csvdatasource_data_url %}
    <li class="get-method">
      <div class="description"><span class="description--label">{% trans "Returning all file lines:" %}</span>
        <a class="example-url" href="{{ csvdatasource_data_url }}">{{ csvdatasource_data_url }}</a></div>
    </li>
    <li class="get-method">
      <div class="description"><span class="description--label">{% trans "Returning lines containing 'abc' in 'text' column (case insensitive):" %}</span>
        <a class="example-url" href="{{ csvdatasource_data_url }}?q=abc">{{ csvdatasource_data_url }}?q=abc</a></div>
    </li>
    {% for query in object.queries.all %}
      <li class="get-method"><div class="description"><span class="description--label">{{ query.label }}:</span>
        <a class="example-url" href="{% url 'generic-endpoint' connector='csvdatasource' slug=object.slug endpoint='query' rest=query.slug %}/">{% url 'generic-endpoint' connector='csvdatasource' slug=object.slug endpoint='query' rest=query.slug %}/</a></div>
        {% if query.description %}&mdash; {{ query.description }}{% endif %}
      </li>
    {% endfor %}
  </ul>
  <h4>{% trans "Management" %}</h4>
  <ul class="endpoints">
    {% url 'generic-endpoint' connector='csvdatasource' slug=object.slug endpoint='update' as csvdatasource_update_url %}
    <li class="put-method">
      <div class="description">
        <span class="description--label">{% trans "Modify spreadsheet file:" %}</span>
        <a href="{{ csvdatasource_update_url }}" class="example-url">{{ csvdatasource_update_url }}</a></div>
    </li>
  </ul>
{% endblock %}
