{% extends "base.html" %} {% import "_base.html" as _base %} {% import "_section.html" as _section %} {% block head %} {{ super() }} {% endblock %} {% block breadcrumbs %} {%- if not rule -%} {{ _base.breadcrumbs(section, [ (gettext('history'), url_for('history', path=section['path'])) ]) }} {%- else -%} {{ _base.breadcrumbs(section, [ (gettext('%(rulename)s', rulename=rule), url_for('rule', path=section['path'], rulename=rule)), (gettext('history'), url_for('history', path=section['path'], rule=rule)) ]) }} {%- endif -%} {% endblock %} {% block content -%}

{% if rule -%} {%- trans securl=url_for('section', path=section['path']), secname='genisys' if not section['path'] else section['path'] -%} Rule "{{ rule }}" of section {{ secname }} history {%- endtrans -%} {%- else -%} {%- trans securl=url_for('section', path=section['path']), secname='genisys' if not section['path'] else section['path'] -%} {{ secname }} history {%- endtrans -%} {% endif -%}

{% if rule -%}

{% trans %}Showing only changes, affecting rule {{ rule }}.{% endtrans %}

{% trans %}Show all changes{% endtrans %} {%- else -%} {% trans %}Recursive{% endtrans %} {% trans %}(show history of all subsections){% endtrans %} {%- endif %}
{% if not history %}

{% trans %}History is empty{% endtrans %}

{% else %} {{ _base.pager(page, is_last_page, is_first_page, endpoint='history', params=dict(path=section['path'], rule=rule, recursive='1' if recursive_history else None)) }}
{% for record in history -%}

{% with when='{}'.format(record['when']|timestampformat(format='medium')|escape)|safe, who=_base.username(record['who']), section='{secpath} r{rev}'.format( securl=url_for('section', path=record['path'], revision=record['revision']), secpath=record['path']|escape or 'genisys', sechisturl=url_for('history', path=record['path']), rev=record['revision'])|safe, rule='' %} {%- if record['what'] == 'create_section' -%} {% trans %}{{ when }} {{ who }} created section {{ section }}{% endtrans %} {%- elif record['what'] == 'set_section_owners' -%} {% trans %}{{ when }} {{ who }} changed owners of section {{ section }}{% endtrans %} {%- elif record['what'] == 'set_section_desc' -%} {% trans %}{{ when }} {{ who }} changed description of section {{ section }}{% endtrans %} {%- elif record['what'] == 'delete_empty_section' -%} {% trans %}{{ when }} {{ who }} deleted empty section {{ section }}{% endtrans %} {%- elif record['what'] == 'reorder_rules' -%} {% trans %}{{ when }} {{ who }} changed order of rules in section {{ section }}{% endtrans %} {%- elif record['what'] == 'save_aliases' -%} {% trans %}{{ when }} {{ who }} changed sandbox resource aliases in section {{ section }}{% endtrans %} {%- elif record['what'] == 'revert_rules' -%} {% trans revert_to_rev=record['extra']['revert_to_rev'] -%} {{ when }} {{ who }} reverted rules to revision {{ revert_to_rev }} in section {{ section }} {%- endtrans %} {%- endif %} {%- if record['what'] in ('delete_rule', 'edit_rule', 'edit_rule_config', 'create_rule') -%} {% with rule='{rulename}'.format( url=url_for('rule', path=record['path'], rulename=record['affected_rules'][0], revision=record['revision']), rulename=record['affected_rules'][0]|escape)|safe -%} {%- if record['what'] == 'delete_rule' -%} {% trans %}{{ when }} {{ who }} deleted rule {{ rule }} from section {{ section }} {% endtrans %} {%- elif record['what'] == 'create_rule' -%} {% trans %}{{ when }} {{ who }} created rule {{ rule }} in section {{ section }}{% endtrans %} {%- elif record['what'] == 'edit_rule' -%} {% trans %}{{ when }} {{ who }} edited rule {{ rule }} of section {{ section }} {% endtrans %} {%- elif record['what'] == 'edit_rule_config' -%} {% trans %}{{ when }} {{ who }} changed config of rule {{ rule }} in section {{ section }} {% endtrans %} {%- endif -%} {%- endwith -%} {%- endif %} {% endwith -%} {%- if record['result'] == 'success' -%} {%- elif record['result'] == 'model_error' -%} {{ gettext(record['exc_class']) }} {%- else -%} {% trans %}Unhandled error{% endtrans %} {% endif -%}

{% if not rule and record.get('affected_rules') and record['affected_rules']|length == 1 -%}

{%- trans url=url_for('history', path=record['path'], rule=record['affected_rules'][0]), affected_rule=record['affected_rules'][0] -%} Show only changes affecting rule {{ affected_rule }} {%- endtrans %}

{%- elif not rule and record.get('affected_rules') -%}

{% trans %}Affected rules:{% endtrans %} {% for rulename in record['affected_rules'] %} {{ rulename }} {%- if not loop.last %}, {% endif %} {% endfor %}

{%- endif %}
{%- if record['what'] == 'create_section' -%}
{% trans %}Owners{% endtrans %}
{{ _section.owners(record['extra']['owners']) }}
{% trans %}Description{% endtrans %}
{{ _section.description(record['extra']['desc']) }}
{%- elif record['what'] == 'set_section_owners' -%}
{% trans %}Owners{% endtrans %}
{{ userlist_diff(record['extra']['prev'], record['extra']['new']) }}
{% trans %}Owners{% endtrans %}
{{ userlist_diff(record['extra']['new'], record['extra']['prev']) }}
{%- elif record['what'] == 'set_section_desc' -%}
{% trans %}Description{% endtrans %}
{{ _base.textdiff(record['extra']['prev'], record['extra']['new']) }}
{% trans %}Description{% endtrans %}
{{ _base.textdiff(record['extra']['new'], record['extra']['prev']) }}
{%- elif record['what'] == 'delete_empty_section' -%}
{% trans %}Owners{% endtrans %}
{{ _section.owners(record['extra']['owners']) }}
{% trans %}Description{% endtrans %}
{{ _section.description(record['extra']['desc']) }}
{%- elif record['what'] == 'create_rule' -%}
{% trans %}Editors{% endtrans %}
{{ _section.editors(record['extra']['editors']) }}
{% trans %}Description{% endtrans %}
{{ _section.description(record['extra']['desc']) }}
{% trans %}Selector{% endtrans %}
{%- if record['extra']['selector'] is none -%}

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

{%- else -%}
{{ record['extra']['selector'] }}
{%- endif -%}
{% if record['extra']['stype'] == 'yaml' %}
{% trans %}Config{% endtrans %}
{{ record['extra']['config_source'] }}
{% else %}
{% trans %}Sandbox resource{% endtrans %}
{{ _section.sandbox_rule_config_source(record['extra']['config_source'], section['path'], record['revision']) }}
{% endif %}
{%- elif record['what'] == 'delete_rule' -%}
{% trans %}Editors{% endtrans %}
{{ _section.editors(record['extra']['editors']) }}
{% trans %}Description{% endtrans %}
{{ _section.description(record['extra']['desc']) }}
{% trans %}Selector{% endtrans %}
{%- if record['extra']['selector'] is none -%}

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

{%- else -%}
{{ record['extra']['selector'] }}
{%- endif -%}
{% if record['extra']['stype'] == 'yaml' %}
{% trans %}Config{% endtrans %}
{{ record['extra']['config_source'] }}
{% else %}
{% trans %}Sandbox resource{% endtrans %}
{{ _section.sandbox_rule_config_source(record['extra']['config_source'], section['path'], record['revision']) }}
{% endif %}
{%- elif record['what'] == 'edit_rule' -%} {% for cls, a, b in [('diff-prev', record['extra']['prev'], record['extra']['new']), ('diff-new', record['extra']['new'], record['extra']['prev'])] %}
{% if a['editors'] != b['editors'] -%}
{% trans %}Editors{% endtrans %}
{{ userlist_diff(a['editors'], b['editors']) }}
{%- endif -%} {% if a['desc'] != b['desc'] %}
{% trans %}Description{% endtrans %}
{{ _base.textdiff(a['desc'], b['desc']) }}
{%- endif -%} {% if a['selector'] != b['selector'] %}
{% trans %}Selector{% endtrans %}
{%- if a['selector'] is none -%}

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

{%- elif b['selector'] is none -%}
{{ a['selector'] }}
{%- else -%} {{ _base.textdiff(a['selector'], b['selector']) }} {%- endif -%}
{%- endif -%}
{% endfor %} {%- elif record['what'] == 'edit_rule_config' -%} {% if record['extra']['stype'] == 'yaml' %}
{% trans %}Config{% endtrans %}
{{ _base.textdiff(record['extra']['prev_source'], record['extra']['new_source']) }}
{% trans %}Config{% endtrans %}
{{ _base.textdiff(record['extra']['new_source'], record['extra']['prev_source']) }}
{% else %}
{% trans %}Sandbox resource{% endtrans %}
{{ _section.sandbox_rule_config_source(record['extra']['prev_source'], section['path'], record['revision']) }}
{% trans %}Sandbox resource{% endtrans %}
{{ _section.sandbox_rule_config_source(record['extra']['new_source'], section['path'], record['revision']) }}
{% endif %} {%- elif record['what'] == 'save_aliases' -%} {% for this, other, rev in [('prev', 'new', record['revision'] - 1), ('new', 'prev', record['revision'])] %}
{% trans %}Aliases{% endtrans %}
{% if record['extra'][this] %}
    {% for alias_id, alias in record['extra'][this]|dictsort %} {% if alias %}
  • {{ alias['name'] }}: {{ _section.sandbox_rule_config_source({'resource': alias['resource_id'], 'description': alias['resource_description']}) }}
  • {% endif %} {% endfor %}
{% else %} {% endif %}
{% endfor %} {%- elif record['what'] == 'reorder_rules' -%} {% for cls, a, b in [('diff-prev', record['extra']['prev'], record['extra']['new']), ('diff-new', record['extra']['new'], record['extra']['prev'])] %}
{% trans %}Rules order{% endtrans %}
    {%- for rulename in a %} {{- rulename -}} {%- endfor %}
{% endfor %} {%- elif record['what'] == 'revert_rules' -%}
{% trans %}Rules before revert{% endtrans %}
{% if not record['extra']['prev_rules'] %} {% else %} {% endif %}
{% trans %}Rules after revert{% endtrans %}
{% if not record['extra']['new_rules'] %} {% else %} {% endif %}
{%- endif -%}

{% endfor %}
{{ _base.pager(page, is_last_page, is_first_page, endpoint='history', params=dict(path=section['path'], rule=rule, recursive='1' if recursive_history else None)) }} {% endif %} {% endblock %} {% macro userlist_diff(list1, list2) %} {% for user in list1 -%} {% if not user in list2 -%} {{ _base.username(user) }} {%- else -%} {{ _base.username(user) }} {%- endif -%} {% if not loop.last %}, {% endif %} {%- else %} {%- endfor %} {% endmacro %}