{% extends "sphene/community/admin/base.html" %}
{% load i18n %}
{% load sph_extras %}
{% load sph_pagination %}
{% load sphboard_extras %}

{% block head %}
  {{ block.super }}
  <script type="text/javascript" src="{{ STATIC_URL }}sphene/community/jquery-1.2.3.min.js"></script>

  <script type="text/javascript">
      $(document).ready(function(){

      })
  </script>
{% endblock %}

{% block content %}

<p><a href="{% sph_url 'sph_admin_users' %}">{% trans "Back to users list" %}</a></p>

<h2>{% blocktrans with author.username as username %}Posts submitted by user:{% endblocktrans %} {% sphboard_displayUserName author %}</h2>

<a onclick="return confirm('{% trans "Are you sure you want to delete ALL posts of this user?" %}')" href="{% sph_url2 sphboard_admin_posts_delete author.pk %}">{% trans "Delete all posts of this user" %}</a>

<table>
  <tr>
    <th><a href="?orderby={% get_orderby orderby "subject" %}">{% trans "Subject" %}</a></th>
    <th>{% trans "Body" %}</th>
    <th><a href="?orderby={% get_orderby orderby "postdate" %}">{% trans "Published" %}</a></th>
    <th>{% trans "Actions" %}</th>
  </tr>
  {% for post in post_list %}
    <tr>
      <td>{% sph_truncate post.subject 30 "..." %}</td>
      <td>{% sph_truncate post.body 100 "..." %}</td>
      <td>{{ post.postdate|date:"Y-m-d H:i:s" }}</td>
      <td>
          <a href="{{ post.get_absolute_url }}">{% trans "View" %}</a>
          <a onclick="return confirm('{% trans "Are you sure you want to delete this post?" %}')" href="{% sph_url2 sphboard_admin_post_delete author.pk post.pk %}">{% trans "Delete" %}</a>
      </td>
    </tr>
  {% endfor %}
  {% if not post_list %}
      <tr><td colspan="5">{% trans "User didn't publish any posts yet" %}</td></tr>
  {% endif %}
</table>

<p class="sphboard_pagination">{% sph_pagination pages page %}</p>
{% endblock %}
