{% load i18n %}
{% load agon_ratings_tags %}
{% load base_tags %}

<article class="description tab-pane active" id="info">
  <ul class="unstyled wide">
  {% if resourcebase.title%}
    <li>
      <strong>{% trans "Title" %}:</strong>
      {{ resourcebase.title|truncatechars:80 }}
    </li>
  {% endif %}

  {% if resourcebase.abstract %}
    <li>
      <strong>{% trans "Abstract" %}:</strong>
      {{ resourcebase.abstract|escape|urlize|linebreaks|safe|truncatechars:160 }}
    </li>
  {% endif %}

  {% if resourcebase.date %}
    <li>
      <strong>{% trans resourcebase.date_type|title %} {% trans "Date" %}:</strong>
      {{ resourcebase.date }}
    </li>
  {% endif %}

  {% if resourcebase.display_type %}
    <li>
      <strong>{% trans "Type" %}:</strong>
      {{ resourcebase.display_type }}
    </li>
  {% endif %}

  {% if resourcebase.keyword_list %}
    <li>
      <strong>{% trans "Keywords" %}:</strong>
      {% for keyword in resourcebase.keyword_list %}
        {{ keyword }}
      {% endfor %}
    </li>
  {% endif %}
          
  {% if resourcebase.category %}
    <li>
      <strong>{% trans "Category" %}:</strong>
      {{ resourcebase.category }}
    </li>
  {% endif %}
  
  {% if resourcebase.regions.all %}
   <li>
      <strong>{% trans "Regions" %}:</strong>
        {{ resourcebase.regions.all|join:", " }}
    </li>
  {% endif %}
  
  {% if resourcebase.license %}
    <li>
      <strong>{% trans "License" %}:</strong>
      {{ resourcebase.license.name }}
    </li>
  {% endif %}
          
  {% if resourcebase.owner %}
    <li>
      <strong>{% trans "Owner" %}:</strong>
      <a href="{{ resourcebase.owner.get_profile.get_absolute_url }}">{{ resourcebase.owner.username }}</a>
    </li>
  {% endif %}

  {% if resourcebase.poc.user %}
    <li>
      <strong>{% trans "Point of Contact" %}:</strong>
      <a href="{{ resourcebase.poc.user.get_profile.get_absolute_url }}"> {{ resourcebase.poc.user.username }} </a>
    <li>
  {% endif %}

    <li>
        {% num_ratings resourcebase as num_votes %}
        <strong>{% trans 'Overall Rating' %}:</strong>
        {% overall_rating resourcebase resourcebase_type|default:"layer" as overall_rating %}
        <div class="overall_rating" style="" data-rating="{{ overall_rating }}"></div> ({{ num_votes }} vote{{ num_votes|pluralize }})
    </li>

    {% if request.user.is_authenticated %}
        <li>
            <strong>{% trans "Your Rating" %}:</strong>
            {% user_rating request.user resourcebase  resource_base_type|default:"layer" as user_rating %}
            <div id="user_rating" class="category-layer"></div>
        </li>
    {% endif %}

  </ul>

  <a href="#more" data-toggle="collapse" data-target=".more">More info</a>

  <div class="more collapse"> 
    <ul class="unstyled wide">
    {% if resourcebase.maintenance_frequency %}
      <li>
        <strong>{% trans "Maintenance Frequency" %}:</strong>
        {{ resourcebase.maintenance_frequency_title }}
      </li>
    {% endif %}
    
    {% if resourcebase.restriction_code_type or resourcebase.constraints_other %}
      <li>
        <strong>{% trans "Restrictions" %}:</strong>
        {% if resourcebase.constraints_other %}
            {{ resourcebase.constraints_other }}
        {% else %}
            {{ resourcebase.restriction_code_type }}
        {% endif %}
      </li>
    {% endif %}
          
    {% if resourcebase.edition %}
      <li>
        <strong>{% trans "Edition" %}:</strong>
        {{ resourcebase.edition}}
      </li>
    {% endif %}

    {% if resourcebase.purpose %}
      <li>
        <strong>{% trans "Purpose" %}:</strong>
        {{ resourcebase.purpose|escape|urlize|linebreaks|safe|truncatechars:160 }}
      </li>
    {% endif %}

    {% if resourcebase.language %}
      <li>
        <strong>{% trans "Language" %}:</strong>
        {{ resourcebase.language_title }}
      </li>
    {% endif %}

    {% if resourcebase.temporal_extent_start and resourcebase.temporal_extent_end %}
      <li>
        <strong>{% trans "Temporal Extent" %}:</strong>
        {{ resourcebase.temporal_extent_start }} - {{ resourcebase.temporal_extent_end }}
      </li>
    {% endif %}

    {% if resourcebase.data_quality_statement %}
      <li>
        <strong>{% trans "Data Quality" %}:</strong>
        {{ resourcebase.data_quality_statement }}
      </li>
    {% endif %}

    {% if resourcebase.supplemental_information %}
      <li>
        <strong>{% trans "Supplemental Information" %}:</strong> 
        {{ resourcebase.supplemental_information|truncatechars:160|escape|urlize|linebreaks|safe }}
      </li>
    {% endif %}

    {% if resourcebase.spatial_representation_type %}
      <li>
        <strong>{% trans "Spatial Representation Type" %}:</strong>
        {{ resourcebase.spatial_representation_type }}
      </li>
    {% endif %}
    </ul>
  </div>
</article>
