{% extends "site_base.html" %}
{% load thumbnail %}

{% block metas %}
    <title>{{ title }} - {{ settings.SITE_TITLE }}</title>
    <meta name="description" content="{{ description|striptags|truncatewords:50 }}" />
{% endblock %}

{% block breadcrumbs %}
{% endblock %}

{% block content %}
<section id="forum">

  {% include "rforum/elements/forum-top.html" %}

  <ul class="breadcrumb">
	<li><i class="icon-home"></i> <a href="{% url app_forum-forum-index %}">{{ _('Index') }}</a> <span class="divider">/</span></li>
	<li><i class="icon-folder-open"></i> <a href="{% url app_forum-forum-detail mytopic.forum.slug %}">{{ mytopic.forum.title }}</a> <span class="divider">/</span></li>
	<li><i class="icon-file"></i> {{ mytopic.title }}</li>
  </ul>

  {% include "rforum/elements/forum-actions-topic.html" %}

  <div class="forum">
	<table class="table table-bordered">
	  <thead>
		<tr>
		  <th colspan="2"><h3>{{ mytopic.title }}</h3></th>
	  </thead>
	  <tbody>
		{% for post in mypost %}
		<tr>
		  <td>
			<a name="{{ post.id }}"></a>
			{{ post.body|safe }}
			{% if user.is_authenticated %}
			<hr />

			<!-- Delete Post -->
			<div class="modal hide fade" id="deletePost{{ post.id }}">
			  <div class="modal-header">
				<button type="button" class="close" data-dismiss="modal">×</button>
				<h3>{{ _('Delete a single post') }}</h3>
			  </div>
			  <div class="modal-body">
				<p>{{ _('You are about to delete a single post, this procedure is irreversible') }}</p>
				<p>{{ _('Do you want to proceed?') }}</p>
			  </div>
			  <div class="modal-footer">
				<a href="javascript:$('#modal-from-dom').modal('hide')" class="btn secondary" data-dismiss="modal">{{ _('No') }}</a>
				<a href="{% url app_forum-post-delete mytopic.slug post.id %}" class="btn btn-danger">{{ _('Yes') }}</a>
			  </div>
			</div>
			<!-- Delete Post -->

			<div style="float: right;">
			  {% if es_moderador %}
			  <div class="btn-group">
				<a class="btn dropdown-toggle btn-inverse" data-toggle="dropdown" href="#">
				  {{ _('Moderator actions') }}
				  <span class="caret"></span>
				</a>
				<ul class="dropdown-menu">
				  {% if es_moderador %}
				  <li><a href="{% url app_forum-post-edit mytopic.slug post.id %}"><i class="icon-pencil"></i> {{ _('Edit') }}</a></li>
				  <li><a href="" data-toggle="modal" data-target="#deletePost{{ post.id }}"><i class="icon-minus"></i> {{ _('Delete Post') }}</a></li>
				  <li><a href=""><i class="icon-minus-sign"></i> {{ _('Ban user') }}</a></li>
				  {% endif %}
				</ul>
			  </div>
			  {% endif %}

			{% if post.user == user %}
			<div class="btn-group">
			  <a class="btn dropdown-toggle btn-inverse" data-toggle="dropdown" href="#">
			    {{ _('Owner actions') }}
			    <span class="caret"></span>
			  </a>
			  <ul class="dropdown-menu">
				  <li><a href="{% url app_forum-post-edit mytopic.slug post.id %}"><i class="icon-pencil"></i> {{ _('Edit') }}</a></li>
			  </ul>
			</div>
			{% endif %}


		      <p style="margin-top: 10px;"><a href="" class="btn btn-small"><i class="icon-minus-sign"></i> {{ _('Report inappropiate') }}</a></p>
			  {% endif %}
			</div>
		  </td>
		  <td style="text-align: center; width: 200px;">
				{% include "rforum/elements/form-userdetail.html" %}
		  </td>
		</tr>

		{% endfor %}
	  </tbody>
	</table>
  </div>

  {% include "rforum/elements/forum-actions-topic.html" %}
  {% include "rforum/elements/forum-bottom.html" %}

</section>
{% endblock %}
