{% extends "djangovoice/feedback_base.html" %}
{% load i18n %}
{% load djangovoice_tags voting_tags gravatar comments %}

{% block title %}{{ title }}{% endblock %}

{% block content %}
	<h1>{{ title }}</h1>

	{% if feedback_list %}
		{% votes_by_user user on feedback_list as vote_dict %}
		{% scores_for_objects feedback_list as score_dict %}

		<table class="list">
		    {% for feedback in feedback_list %}
		    	{% dict_entry_for_item feedback from vote_dict as vote %}
		    	{% dict_entry_for_item feedback from score_dict as score %}
		    	{% get_comment_count for feedback as comment_count %}

			    <tr>
			        <td class="votes">
			        	<div>{{ score.score|default:0 }}</div>
		        	</td>

			        <td class="status">
			            <span class="feedback-type feedback-type-{{ feedback.type.slug }}">{{ feedback.type.title }}</span>
			        </td>

			        <td class="details">
			            <h3>
			                <a href="{{ feedback.get_absolute_url }}">{{ feedback.title }}</a>
			                <span class="feedback-status feedback-status-{{ feedback.status.slug }}">{{ feedback.status.title }}</span>
			            </h3>

			            <p>
			                <span class="feedback-comments">
			                    <a href="{{ feedback.get_absolute_url }}">
			                        {{ comment_count }} {% blocktrans %}comment{{ comment_count|pluralize }}{% endblocktrans %}
			                    </a>
			                </span>

			                <span class="feedback-user">
			                    {% if feedback.user %}
			                    	{% trans "Submitted by:" %}

				                    <a href="{{ feedback.user.get_absolute_url }}" class="avatar" title="{% trans "View profile" %}">
				                        {% gravatar feedback.user.username 15 %}
				                    </a>

				                    <a href="{{ feedback.user.get_absolute_url }}" title="View profile">{% user_name feedback.user %}</a>
			                    {% else %}
				                    {% trans "Submitted anonymously" %}
			                    {% endif %}
			                </span>

			                <span class="feedback-date">{% trans "on" %} {{ feedback.created|date:"d M Y" }}</span>
			            </p>
			        </td>

			        {% if feedback.private %}
				        <td class="feedback-private">{% trans "PRIVATE" %}</td>
			        {% endif %}
			    </tr>
		    {% endfor %}
		</table>

		<div class="pagination">
		    <span class="step-links">
		        {% if pagination.has_previous %}
			        <a href="?page=1" id="pagination-first-page">&laquo; {% trans "first" %}</a>
			        <a href="?page={{ pagination.previous_page_number }}" id="pagination-previous-page">&larr; {% trans "previous" %}</a>
		        {% endif %}

		        <span class="current">
		            {% trans "Page" %} {{ pagination.number }} {% trans "of" %} {{ pagination.paginator.num_pages }}
		        </span>

		        {% if pagination.has_next %}
			        <a href="?page={{ pagination.next_page_number }}" id="pagination-next-page">{% trans "next" %} &rarr;</a>
			        <a href="?page={{ pagination.paginator.num_pages }}" id="pagination-last-page">{% trans "last" %} &raquo;</a>
		        {% endif %}
		    </span>
		</div>
	{% else %}
		<p>{% trans "No one has contributed any feedback yet. Be the first and submit some feedback!" %}</p>
	{% endif %}
{% endblock %}

{% block sidebar %}
	{% include "djangovoice/sidebar.html" %}
{% endblock %}
