{% extends "mongonaut/base.html" %}
{% load url from future %}
{% load mongonaut_tags %}

{% block breadcrumbs %}
<li><a href="{% url "index" %}">Mongonaut</a> <span class="divider">/</span></li>
<li><a href="{% url "document_list" app_label document_name %}">{{ document_name }}s</a> <span class="divider">/</span></li>
<li><a href="">{{ document_name }} {{ document.id }}</a></li>
{% endblock %}

{% block content %}

<h1>{{ document_name }} Detail</h1>


<div class="row" >
    <div class="span12" id="document-actions">
        <p>
            <div class="btn-group">
                {% if has_edit_permission %}            
                    <a class="btn btn-primary" href="{% url "document_detail_edit_form" app_label document_name document.id %}">
                        <i class="icon-pencil icon-white"></i> Edit
                    </a>
                            
                {% endif %}
                {% if has_delete_permission %}                        
                    <a id="action_delete"  class="btn btn-danger" href="#"><i class="icon-trash icon-white"></i> Delete</a>
                {% endif %}
            </div>
        </p>
        {% include "mongonaut/includes/_delete_warning.html" %}
    </div>
</div>

<div class="row">
    <div class="span6">
        <table class="table table-bordered table-striped">
            <caption>Content</caption>
            <thead>
                <tr>
                    <th>Key</th>
                    <th>Value</th>                    
                </tr>
            </thead>
            <tbody>            
            {% for key in keys %}
                <tr>
                    <td>{{ key}}</td>
                    <td>{% get_document_value document key %}</td>                    
                </tr>
            {% endfor %}
            </tbody>            
        </table>
    </div>
    <div class="span6">
            {% if list_fields %}
                <table class="table table-bordered table-striped">
                    <caption>List Fields</caption>
                    <thead>
                        <tr>
                            <th>Field name</th>
                            <th>Value</th>                    
                        </tr>
                    </thead>
                    <tbody>            
                    {% for key in list_fields %}
                        <tr>
                            <td>{{ key}}</td>
                            <td>{% get_document_value document key %}</td>                    
                        </tr>
                    {% endfor %}
                    </tbody>            
                </table>
            {% endif %}
            {% if embedded_documents %}
                <table class="table table-bordered table-striped">
                    <caption>Embedded Documents</caption>
                    <thead>
                        <tr>
                            <th>Document Name</th>
                            <th>Value</th>                    
                        </tr>
                    </thead>
                    <tbody>            
                    {% for key in embedded_documents %}
                        <tr>
                            <td>{{ key}}</td>
                            <td>{% get_document_value document key %}</td>                    
                        </tr>
                    {% endfor %}
                    </tbody>            
                </table>
            {% endif %}            
        </div>        
    </div>
</div>    

{% endblock %}

{% block extrajs %}
<form method="post" id="delete_form" action="{% url "document_delete" app_label document_name document.id %}">
{% csrf_token %}
</form>
{% endblock %}

