mwielgoszewski/doorman

View on GitHub
doorman/templates/manage/tables/distributed_results.html

Summary

Maintainability
Test Coverage
{% macro render_task_parts(task) %}
    <td>
        <a href="{{ url_for('manage.get_node', node_id=task.node_id) }}">{{ task.node.display_name }}</a>
    </td>
    <td>{{ task.distributed_query.timestamp }}</td>
    <td>{{ task.distributed_query.not_before or 'immediately' }}</td>
    <td>{{ task.timestamp or '' }}</td>
    {% if not status %}
    <td>
        {%- if task.status == DistributedQueryTask.NEW -%}
        NEW
        {%- elif task.status == DistributedQueryTask.PENDING -%}
        PENDING
        {%- elif task.status == DistributedQueryTask.COMPLETE -%}
        COMPLETE
        {%- endif -%}
    </td>
    {% endif %}
{% endmacro %}


                <table class="table table-striped table-condensed">
                    <thead>
                        <th>node</th>
                        <th>created</th>
                        <th>run after</th>
                        <th>retrieved</th>
                        {% if not status %}<th>status</th>{% endif %}

                        {% if columns %}
                            {% for column in columns %}
                                <th>{{ column }}</th>
                            {% endfor %}
                        {% else %}
                            <th></th>
                        {% endif %}
                    </thead>

                    <tbody>
                        {% for task in tasks %}

                            {# If we have any results, render a row per-result.  Otherwise, we render a single row without them #}
                            {% if task.results | length %}
                                {% for result in task.results %}
                                    <tr>
                                        {{ render_task_parts(task) }}

                                        {% for column in columns %}
                                            <td>{{ result.columns[column] | render(column) }}</td>
                                        {% endfor %}
                                    </tr>
                                {% endfor %}
                            {% else %}
                                <tr>
                                    {{ render_task_parts(task) }}

                                    <td colspan='{{ columns | length }}'>
                                        <i>no results</i>
                                    </td>
                                </tr>
                            {% endif %}
                        {% endfor %}
                    </tbody>

                </table>