{% extends "crudbuilder/base.html" %}

{% load crudbuilder %}

{% block css %}
<style>
    .btn{
        margin-right:10px;
    }   
</style>
{% endblock %}


{% block breadcrumb %}
<ul class="breadcrumb">
    <li><a href="{% url app_label|add:'-'|add:custom_postfix_url|add:'-list' %}">{{pluralized_model_name|title}}</a></li>
    <li class="active">{{object}}</li>
</ul>
{% endblock %}

{% block main_content %}
    {% block actions %}
        <a class="btn btn-primary pull-right" href="{% url app_label|add:'-'|add:custom_postfix_url|add:'-update' object.id %}"><i class="glyphicon glyphicon-pencil"></i> Update</a>
        <a class="btn btn-primary pull-right" href="{% url app_label|add:'-'|add:custom_postfix_url|add:'-delete' object.id %}"><i class="glyphicon glyphicon-remove-sign"></i> Delete</a>
    {% endblock %}

<div class='container'>
    <h3>{{object}}</h3>
    <table class="table table-bordered">
        <thead>
            <tr>
                <th>Field</th>
                <th>Value</th>
            </tr>
        </thead>
        <tbody>
            {% for field in object|get_model_fields %}
        	   <tr>
        		  <td>{{object|get_verbose_field_name:field.name}}</td>
        		  <td>{{object|get_value:field.name}}</td>
        	   </tr>
            {% endfor %}
        </tbody>
    </table>

    <hr/>

    <h3>{{inlineformset.fk.related_query_name|title}}</h3>

    <table class="table table-bordered">
        <thead>
            <tr>
                {% for field in inlineformset.form.base_fields.keys %}
                    {% if inlineformset.fk.name != field %}
                    <th>{{field|undertospaced}}</th>
                    {% endif %}
                {% endfor %}
            </tr>
        </thead>
        <tbody>
            {% for object in object|inline_objects:inlineformset.fk %}
                <tr>
                {% for field in inlineformset.form.base_fields.keys %}
                    {% if inlineformset.fk.name != field %}
                    <td>{{object|get_value:field}}</td>
                    {% endif %}
                {% endfor %}
                <tr>
            {% endfor %}
        </tbody>
    </table>


</div>
{% endblock %}
