{%- macro render_field(field, show_label=True, indent=1) -%} {%- set indention = '\t' * indent -%} {%- if show_label %}{{ field.label }}{% endif %} {{ indention }}{{ field(**kwargs) }} {%- if field.errors %} {{ indention }}
{{ indention }} {{ indention }}
{%- endif %} {%- endmacro -%} {%- macro render_field_unlabeled(field, indent=1) -%} {{- render_field(field, show_label=False, indent=indent, **kwargs)|safe }} {%- endmacro -%} {%- macro render_checkbox(field, indent=1) -%} {%- set indention = '\t' * indent -%} {%- endmacro -%} {%- macro nullable_value(value, default='') -%} {%- if value -%}{{ value }}{%- else -%}{{ default }}{%- endif -%} {%- endmacro -%} {%- macro colorize_severity(severity, label="") -%} {%- if not severity or severity == "Unknown" -%} {% if label %}{{ label }}{% else %}Unknown{% endif %} {%- elif severity == "Low" -%} {% if label %}{{ label }}{% else %}Low{% endif %} {%- elif severity == "Medium" -%} {% if label %}{{ label }}{% else %}Medium{% endif %} {%- elif severity == "High" -%} {% if label %}{{ label }}{% else %}High{% endif %} {%- elif severity == "Critical" -%} {% if label %}{{ label }}{% else %}Critical{% endif %} {%- else -%} {{ severity }} {%- endif -%} {%- endmacro -%} {%- macro colorize_status(status, label="") -%} {%- if not status or status == "Unknown" -%} {% if label %}{{ label }}{% else %}Unknown{% endif %} {%- elif status == "Testing" -%} {% if label %}{{ label }}{% else %}Testing{% endif %} {%- elif status == "Vulnerable" -%} {% if label %}{{ label }}{% else %}Vulnerable{% endif %} {%- elif status == "Fixed" -%} {% if label %}{{ label }}{% else %}Fixed{% endif %} {%- elif status == "Not affected" -%} {% if label %}{{ label }}{% else %}Not affected{% endif %} {%- else -%} {{ status }} {%- endif -%} {%- endmacro -%} {% macro colorize_remote(value) %} {%- if value == None or value == "Unknown" -%} Unknown {%- elif value == "Remote" -%} Yes {%- else -%} No {%- endif -%} {%- endmacro -%} {%- macro colorize_unknown(value) -%} {%- if value == None or value == "Unknown" -%} Unknown {%- else -%} {{ value }} {%- endif -%} {%- endmacro -%} {%- macro colorize_boolean(value) -%} {%- if value == None or value == "Unknown" -%} Unknown {%- elif value -%} Yes {%- else -%} No {%- endif -%} {%- endmacro -%} {%- macro boolean_value(value, default='Unknown') -%} {%- if value is none -%} {{ default }} {%- elif value -%} Yes {%- else -%} No {%- endif -%} {%- endmacro -%} {%- macro bug_ticket(id) -%} {%- if id -%} FS#{{ id }} {%- endif -%} {%- endmacro -%} {%- macro colorize_diff(previous, current) %} {%- for line in previous|diff(current) %} {%- if not line.startswith('?') %} {%- endif %} {%- endfor %}
{{ line[:1] }} {{ line[2:] }}
{%- endmacro -%} {%- macro render_pagination(pagination) -%} {%- if pagination.has_prev or pagination.has_next -%} {%- endif -%} {%- endmacro -%} {%- macro transaction_operation_label(operation) -%} {%- if 0 == operation -%} created {%- elif 1 == operation -%} edited {%- elif 2 == operation -%} deleted {%- else -%} unknown {%- endif -%} {%- endmacro -%} {%- macro label_from_model(model) -%} {%- if model.__class__.__name__ in ['CVEGroupVersion', 'CVEGroup'] %}AVG-{% endif %}{{ model.id }} {%- endmacro -%} {%- macro link_to_model(model) -%} {%- set label = label_from_model(model) -%} {%- if not model.operation_type == 2 -%} {{ label }} {%- else -%} {{ label }} {%- endif -%} {%- endmacro -%} {%- macro link_to_user_log(username) -%} {%- if username -%} {{ username }} {%- else -%} system {%- endif -%} {%- endmacro -%} {%- macro log_transaction_header(model, show_user) -%} {%- set transaction = model.transaction -%} {{ link_to_model(model) }} {{ transaction_operation_label(model.operation_type) }}{% if show_user %} by {{ link_to_user_log(transaction.user.name) }}{% endif %} at {{ transaction.issued_at.strftime('%d %b %Y %H:%M:%S') }} {%- endmacro -%}