{% import "_base.html" as _base %} {% import "_wtform.html" as wtform %} {% macro revision(section) -%} {%- trans rev=section['revision'] %}r{{ rev }}{% endtrans -%} {%- if section['rules'] and section['status'] and 'mcount' in section['status'] -%} +{{ section['status']['mcount'] }} {%- endif -%} {%- endmacro %} {% macro nsubsections(section) -%} {%- if section['subsections'] -%} {%- trans count=section['subsections']|count -%} {{ count }} subsection {%- pluralize -%} {{ count }} subsections {%- endtrans -%} {%- endif -%} {%- endmacro %} {% macro nrules(section) -%} {%- if section['rules'] -%} {%- trans count=section['rules']|count -%} {{ count }} rule {%- pluralize -%} {{ count }} rules {%- endtrans -%} {%- endif -%} {%- endmacro %} {% macro section_content(section) -%} {% if section['subsections'] %} {{ nsubsections(section) }} {% elif section['rules'] %} {{ nrules(section) }} {% endif %} {% endmacro %} {% macro userlist(users) -%} {% for user in users -%} {{ _base.username(user) }}{% if not loop.last %}, {% endif %} {%- endfor %} {%- endmacro %} {% macro owners(users, inherited_owners=None) -%} {% if users or inherited_owners -%} {%- if users and inherited_owners -%} {% trans owners_list=userlist(users), inherited=userlist(inherited_owners) -%} owners: {{ owners_list }}, inherited owners: {{ inherited }} {%- endtrans %} {%- elif users -%} {% trans owners_list=userlist(users) -%} owners: {{ owners_list }} {%- endtrans %} {%- else -%} {% trans inherited=userlist(inherited_owners) -%} inherited owners: {{ inherited }} {%- endtrans %} {%- endif -%} {%- endif %} {%- endmacro %} {% macro editors(users) -%} {% if users -%} {%- trans editors_list=userlist(users) -%} editors: {{ editors_list }} {%- endtrans -%} {%- endif %} {%- endmacro %} {% macro description(desc) -%} {% if desc -%} {{ desc|markdown_safe -}} {% endif -%} {% endmacro %} {% macro rule_form_script() -%} {% endmacro %} {% macro check_current_revision_script(url) %} {% endmacro %} {% macro ruleform_attrs(section, extra_class="") -%} {% if section['stype'] == 'sandbox_resource' %} class="ruleform sandbox_resource {{ extra_class }}" data-forceupdateurl="{{ url_for('force_volatile_update', vtype='sandbox_releases', key=section['stype_options']['resource_type']) }}" {%- else %} class="ruleform {{ extra_class }}" {%- endif %} {%- endmacro %} {% macro sandbox_rule_config_source(config_source, section_path, revision) %} {% if config_source['rtype'] == 'by_alias' %} {% trans resource=_base.sandbox_resource(config_source['resource']), description=config_source['description'], alias_url=url_for('aliases', path=section_path, revision=revision), alias_id=config_source['alias_id'], alias_name=config_source['alias_name'] -%} Resource {{ resource }}: {{ description }}; by alias {{ alias_name }} {% endtrans %} {% else %} {% trans resource=_base.sandbox_resource(config_source['resource']), description=config_source['description'] -%} Resource {{ resource }}: {{ description }} {%- endtrans %} {% endif %} {% endmacro %} {% macro section_icon(section, height) -%} {% if section['stype'] == 'sandbox_resource' %} {% endif %} {%- endmacro %} {% macro yaml_editor_boilerplate() -%} {%- endmacro %} {% macro yaml_editor(selector, line_numbers=True, rows=None) -%} {%- endmacro %} {% macro rule_link(section, rule, status=None, extra_class="") -%} {{- rule['name'] -}}  h {%- if status %} {{ _base.volatile_labels(status) }} {%- endif -%} {%- endmacro %} {% macro rules_table(panel_title, section, rules, is_editable, parent_rule, rule_order_form, selector_statuses) -%} {% with reorderable=is_editable and rules and rules|length > 1 %}
{{ panel_title }} {% if is_editable %} {% if not parent_rule %} {% if reorderable %} {% endif -%} {% endif -%}
{% if rules %} {% for rule in rules -%} {% if reorderable -%} {%- endif %} {% endfor -%}

{{ rule_link(section, rule) }}

{% with status = selector_statuses.get(rule['selector']) %}{% if status %} {{ _base.volatile_labels(status) }} {% endif %}{% endwith %} {{ editors(rule['editors']) }}
{{ description(rule['desc']) }}
{% if rule['selector'] is not none %}

{{ rule['selector'] }}

{%- if is_editable and not parent_rule and not rule['subrules'] %} {%- endif %} {% else %}

{% trans %}applies to all hosts{% endtrans %}

{% endif %} {% if section['stype'] == 'sandbox_resource' %}

{{ sandbox_rule_config_source(rule['config_source'], section['path'], section['revision']) }}

{% endif %} {%- if rule.get('subrules') %}

{{- ngettext('%(num)d subrule', '%(num)d subrules', rule['subrules']|length) -}}

{% for subrule in rule['subrules'] -%} {% endfor -%}

{{- subrule['name'] -}}  h {%- if subrule['selector'] %} {{ _base.volatile_labels(selector_statuses[subrule['selector']]) }} {%- endif -%}

{{ editors(subrule['editors']) }}
{{ description(subrule['desc']) }}
{% if subrule['selector'] is not none %}

{{ subrule['selector'] }}

{% else %}

{% trans %}applies to all hosts{% endtrans %}

{% endif %} {% if section['stype'] == 'sandbox_resource' %}

{{ sandbox_rule_config_source(subrule['config_source'], section['path'], section['revision']) }}

{% endif %}
{%- endif %}
{% endif %}
{% if reorderable %}
{{ wtform.wtform(rule_order_form) }}
{% endif %} {% endwith %} {%- endmacro %} {% macro section_link(section, full_paths=False, status=None) -%} {{ section_icon(section, 21) }} {%- if not full_paths -%} {{ section['name'] }} {%- else -%} {{- section['path'] or 'Genisys' -}} {%- endif -%} {{ revision(section) }} {% if status -%} {{ _base.volatile_labels(status) }} {%- endif %} {%- endmacro %} {% macro section_tree(root, status_key=None, unique_id='', rules_macro=None, collapse_rules=True, changed_at_key='mtime') -%} {% for name, section in root['subsections']|dictsort -%}
{%- if section['subsections'] %} {%- else -%} {%- endif %} {% if not section['subsections'] -%} {{ section_link(section, full_paths=True, status=section[status_key] if status_key is not none else dict(section, raw_key=section['path'], vtype='section')) }} {% else -%} {{ section_link(section, full_paths=True) }} {% endif -%}
{% trans ctime=section[changed_at_key]|timestampformat, td=section[changed_at_key]|timedeltaformat, by=_base.username(section['changed_by']) -%} last changed {{ td }} by {{ by }} {%- endtrans %}
{% if section['subsections'] %} {{ section_tree(section, status_key, unique_id=unique_id, rules_macro=rules_macro, collapse_rules=collapse_rules, changed_at_key=changed_at_key) }} {% elif rules_macro %} {{ rules_macro(section) }} {% else %} {% endif %}
{%- endfor %} {%- endmacro %}