{% extends "lazycrud/object_detail.html" %}
{% load lazycrud %}

{% block js %}
{{ block.super }}
{% include "lazycrud/_datatables_js.html" %}
{% endblock %}

{% block css %}
{% include "lazycrud/_datatables_css.html" %}
{% endblock %}

{% block right_col %}
    <div class="col-md-6">
    {% if view.related_list_title %}
        <h3>{{ view.related_list_title }}</h3>
    {% endif %}
    {% if view.related_create_url != None %}
        <div class="row">
            <div class="col-md-12">
                <a class="btn btn-success pull-right" role="button" href="{{ view.related_create_url }}"><i class="fa fa-plus"></i> {{ view.related_create_label }}</a>
            </div>
        </div>
        <hr>
    {% endif %}
        <table class="table table-striped table-hover table-datatables"
            {% if view.datatables_options %} data-datatables-options="{{ view.datatables_options }}"{% endif %}>
            <thead>
                <tr>
                {% for name in view.related_list_fields %}
                    <th>{{ view.model|fieldlabel:name }}</th>
                {% endfor %}
                </tr>
            </thead>
            <tbody>
                {% for o in related_list %}
                {% if view.no_record_link %}
                    <tr>
                {% else %}
                    <tr class="clickable_row"
                    {% if view.detail_url %}
                        data-url="{% url view.detail_url pk=o.pk %}"
                    {% else %}
                        data-url="{{ o.get_absolute_url }}"
                    {% endif %}
                    {% if view.detail_url_target %}
                        data-target="{{ view.detail_url_target }}"
                    {% endif %}
                    >
                {% endif %}
                    {% for name in view.related_list_fields %}
                        <td>{{ o|fieldvalue:name }}</td>
                    {% endfor %}
                    </tr>
                {% endfor %}
            </tbody>
        </table>
    </div>
</div>
{% endblock %}
