batiste/django-page-cms

View on GitHub
pages/templates/pages/examples/debug.html

Summary

Maintainability
Test Coverage
{% if sql_queries %}
    <a href="#" id="show-sql">Show SQL queries</a>
    <div id="debug-queries">
        <p class="info"></p>
        <table class="sortable">
            <colgroup><col width="1" /><col /><col width="1" /></colgroup>
            <thead>
                <tr>
                    <th scope="col">#</th>
                    <th scope="col">SQL</th>
                    <th scope="col">Time</th>
                </tr>
            </thead>
            <tfoot>
                <tr>
                    <th>{{ sql_queries|length }}</th>
                    <th class="dupes"></th>
                    <th class="time"></th>
                </tr>
            </tfoot>
            <tbody>
                {% for query in sql_queries %}
                    <tr class="{% cycle 'odd' 'even' %}">
                        <td>{{ forloop.counter }}</td>
                        <td class="query">{{ query.sql|escape }}</td>
                        <td class="time">{{ query.time }}</td>
                    </tr>
                {% endfor %}
            </tbody>
        </table>
    </div>
    <script>
        $('#debug-queries').hide()
        $('#show-sql').text($('#show-sql').text() + ' (' + $('#debug-queries .query').length + ')')
        $('#show-sql').click(function() {
            $('#debug-queries').show();
        });
    </script>
{% endif %}