{% extends "txcollections/base.html" %}
{% load i18n %}
{% load txcommontags %}
{% load markup %}
{% load statistics %}

{% block body_class %}{{ block.super }} collection_detail{% endblock %}

{% block title %}{{ block.super }} | {{ collection.name }}{% endblock %}

{% block extra_head %}
  <link rel="alternate" type="application/rss+xml" title="RSS" href="{% url collection_feed param=collection.slug %}" />
{% endblock %}

{% block breadcrumb %}{{ block.super }} &raquo; {{ collection.name }}{% endblock %}

{% block content_main %}
  <div class="obj_bigdetails">
  <h2 class="name">{{ collection.name }}</h2>

  {% if collection.description %}<p class="description">{{ collection.description }}</p>{% endif %}

  {% if request.user.is_authenticated and perms.txcollections.change_collection %}
  <div class="editlinks"><p><a class="i16 edit buttonized" href="{% url collection_edit slug=collection.slug %}">{% trans "Edit" %}</a></p></div>
  {% endif %}

  {% with collection.long_description_html as long_desc %}
  {% if long_desc %}
  <div class="long_description">
    {{ long_desc|truncatewords_html:"100"|safe }}
  </div>
  {% endif %}
  {% endwith %}

  <div class="details separate">

  {% if collection.homepage or collection.tags %}
  <h4>{% blocktrans %}Details{% endblocktrans %}</h4>
  {% endif %}
  <table class="definition">{% if collection.homepage %}
    <tr>
      <th class="homepage i16">{% trans "Homepage:" %}</th>
      <td><a title="{% blocktrans with collection.name as collection_name %}Homepage for {{ collection_name }}{% endblocktrans %}" href="{{ collection.homepage }}">{{ collection.homepage }}</a></td>
    </tr>
    {% endif %}
    {% if collection.tags %}
    <tr>
      <th class="i16 tag">{% trans "Tags:" %}</th>
      <td class="compact">
        {% for tag in collection.tagsobj.all|slice:"0:6" %}<a class="tag" href="{% url collection_tag_list tag=tag %}">{{ tag }}</a> {% endfor %}
      </td>
    </tr>
    {% endif %}
  </table>
</div>

{% url collection_release_create slug=collection.slug as release_create %}
<div id="releases" class="releases separate">
  <div class="editlinks">
    <p><a class="simlink" href="{% url collection_feed param=collection.slug %}" title="collection feed"><img border="0" src="{{ MEDIA_URL }}images/icons/feed.png" /></a></p>
      {% if request.user.is_authenticated and perms.txcollections.add_collectionrelease %}
        <p><a class="i16 add buttonized" href="{{ release_create }}">{% trans "Add" %}</a></p>
      {% endif %}
    </p>
  </div>

  {% with collection.releases.all as releases %}
  <h3>{% blocktrans %}{{ collection }} Releases{% endblocktrans %}
  {% render_metacount releases _("releases") %}
  </h3>

  {% if releases %}
  <div class="release_list">
  <p class="explanation">{% blocktrans %}The {{ collection }} collection includes the following groups of shipped components:{% endblocktrans %}</p>
  <ul class="simple bigthings">
  {% for release in releases %}
    <li><p class="i16 release"><a href="{{ release.get_absolute_url }}">{{ release.name }}</a>
    {% if release.description %}<span class="description">– {{ release.description }}</span>{% endif %}</p></li>
  {% endfor %}
  </ul>
  </div>
  {% else %}
    {% if request.user.is_authenticated and perms.txcollections.add_collectionrelease %}
      <p class="i16 tip">{% blocktrans %}No releases are registered for this collection yet. Why don't you <a href="{{ release_create }}">add one</a>?{% endblocktrans %}</p>
    {% endif %}
  {% endif %}
  {% endwith %}
</div>

<div id="projects" class="projects">

  {% with collection.projects.all as projects %}
  <h3>{% blocktrans %}Projects in {{ collection }}{% endblocktrans %}
  {% render_metacount projects _("projects") %}
  </h3>

  {% if projects %}
  <p class="explanation">{% blocktrans %}Projects currently registered to belong in this collection:{% endblocktrans %}</p>
  <div class="project_list">
  <ul class="simple bigthings">
  {% for project in projects %}
    <li><p class="i16 project"><a href="{{ project.get_absolute_url }}">{{ project.name }}</a></p></li>
  {% endfor %}
  </ul>
  </div>
  {% else %}
{% url project_list as project_list %}
    <p class="i16 tip">{% blocktrans %}No projects are registered for this collection yet. <a href="{{ project_list }}">Find projects</a> and add them to this collection.{% endblocktrans %}</p>
  {% endif %}
  {% endwith %}
</div>

</div>
{% endblock %}{# body_main #}

{% block content_footer %}
  <div id="content_footer_center">
    {% if request.user.is_authenticated and perms.txcollections.delete_collection %}
    <div class="deletelink">
      <a class="i16 delete buttonized" href="{% url collection_delete slug=collection.slug %}">{% trans "Delete collection" %}</a>
    </div>
    {% endif %}
  </div>
{% endblock %}
