{% load i18n %}

{% block body %}
<div id="appbar">
<h2>{% trans "Data Source" %} - {{ datasource.name }}</h2>
<span class="actions">
  <a href="delete" rel="popup">{% trans "Delete" %}</a>
  <a href="edit">{% trans "Edit" %}</a>
</span>
</div>

{% if datasource.description %}
<div class="bo-block">{{ datasource.description }}</div>
{% endif %}

{% if datasource.data_source %}
<h3>{% trans "Configuration" %}</h3>
<ul>
  <li>{% trans "Type of source:" %} {{ datasource.type_label }}</li>
  {% if datasource.data_source.type == 'json' or datasource.data_source.type == 'jsonp' %}
  <li>{% trans "URL:" %} <a href="{{ datasource.data_source.value }}">{{ datasource.data_source.value }}</a></li>
  {% elif datasource.data_source.type == 'formula' %}
  <li>{% trans "Python Expression:" %} {{ datasource.data_source.value }}</li>
  {% endif %}
  {% if datasource.cache_duration %}
  <li>{% trans "Cache Duration:" %} {{ datasource.humanized_cache_duration }}
  {% endif %}
</ul>
{{ view.preview_block|safe }}

{% with formdefs=view.usage_in_formdefs %}
  {% if formdefs %}
  <h3>{% trans "Usage in forms" %}</h3>
  <ul class="biglist">
  {% for formdef in formdefs %}
    <li><a href="{{ formdef.get_admin_url }}">{{ formdef.name }}</a></li>
  {% endfor %}
  </ul>
  {% endif %}
{% endwith %}

{% else %}
<p class="infonotice">{% trans "Not configured" %}</p>
{% endif %}

{% endblock %}
