mwielgoszewski/doorman

View on GitHub
doorman/templates/manage/_rule.html

Summary

Maintainability
Test Coverage
            <div class="panel panel-default" id="rule-{{ rule.id }}">
                <h4 class="panel-heading">
                    <a href="{{ url_for('manage.rule', rule_id=rule.id) }}">{{ rule.name }}</a>
                </h4>

                <table class="table table-striped table-condensed">

                    <tbody>

                        <tr>
                            <th width="15%">Description</th>
                            <td width="85%">{{ rule.description }}</td>
                        </tr>

                        <tr>
                            <th width="15%">Alerters</th>
                            <td width="85%">{{ rule.alerters | join(', ') }}</td>
                        </tr>

                        <tr>
                            <th width="15%">Conditions</th>
                            {% if rule.conditions %}
                            <td width="85%">
                                {{ rule.conditions.condition }}
                                <ul>
                                {% set group = rule.conditions %}
                                {%- for item in group.rules recursive %}
                                    <li>
                                        {%- if item.rules -%}
                                            {{ item.condition }}<br/>
                                            <ul>{{ loop(item.rules) }}</ul>
                                        {%- else -%}
                                            {%- if item.operator.startswith('column_') and not item.operator.endswith('_empty') %}
                                                Column "{{ item.value[0] }}" {{ item.operator[7:] | pretty_operator }} "{{ item.value[1] }}"
                                            {%- elif item.operator.startswith('column_') and item.operator.endswith('_empty') %}
                                                Column "{{ item.value }}" {{ item.operator[7:] | pretty_operator }}
                                            {%- else -%}
                                                {{ item.id | pretty_field }} {{ item.operator | pretty_operator }} "{{ item.value }}"
                                            {%- endif %}
                                        {%- endif -%}
                                    </li>
                                {%- endfor %}
                                </ul>
                            </td>
                            {% else %}
                            <td width="85%"><i>No conditions</i></td>
                            {% endif %}
                        </tr>

                    </tbody>

                </table>

            </div>