{% macro metric_table(metric_name, data, row_limit=3) -%} {% if data %} {% for row, cnt in data %} {% if data|length > row_limit+1 and loop.index == row_limit %} {% endif %} {% endfor %}
{{ metric_name }} Count
{{ row }} {{ cnt }}
{% endif %} {%- endmacro %} {% macro package_counts_table(data, row_limit=3) -%} {% if data %} {% for name, cnt, versions in data %} {% for version, cnt in versions %} {% endfor %} {% if data|length > row_limit+1 and loop.index == row_limit %} {% endif %} {% endfor %}
Related packages Count
{{ name }} {{ cnt }}
  {{version}} {{cnt}}
{% endif %} {%- endmacro %} {% macro history_graph(history, datefmt, releases) -%}
{%- endmacro %} {% macro backtrace_table_columns(frame, type) -%} {% if frame.nice_order %} {{ frame.nice_order }} {% else %} {{ frame.order }} {% endif %} {% if not frame.reliable %} ? {% endif %} {% if frame.symbolsource.symbol.nice_name %} {{ frame.symbolsource.symbol.nice_name }} {% else %} {{ frame.symbolsource.symbol.name }} {% endif %} {% if frame.inlined %} (inlined) {% endif %} {% if type != 'PYTHON' %} {{ frame.symbolsource.path }} {% endif %} {%- if frame.symbolsource.source_path %} {{ frame.symbolsource.source_path }} {%- elif frame.symbolsource.offset %} {{ frame.symbolsource.offset|memory_address }} {%- if frame.symbolsource.build_id %}
Build id: {{frame.symbolsource.build_id}} {%- endif %} {%- endif %} {%- if frame.symbolsource.line_number %} {%- if frame.symbolsource.func_offset %} {{ frame.symbolsource.line_number}} {%- else %} {{ frame.symbolsource.line_number}} {%- endif %} {%- else %} {{ frame.symbolsource.func_offset|memory_address or '-' }} {%- endif %} {%- endmacro %} {% macro show_backtrace(backtrace, type, oops) -%} {% if type != 'PYTHON' %} {% endif %} {% for frame in backtrace %} {{ backtrace_table_columns(frame, type) }} {% endfor %}
Frame # FunctionBinarySource or offset Line
{% if type == 'kerneloops' and oops %}
{{ oops }}
{% endif %} {%- endmacro %} {% macro external_bugs(bugs) -%} {% for bug in bugs %} {% if bug.status == "CLOSED" %}{{ bug }}{% else %}{{ bug }}{% endif %} {% endfor %} {%- endmacro %} {% macro external_urls(urls) -%} {% for url_obj in urls %}
  • {{ url_obj.url }}
  • {% endfor %} {%- endmacro %} {# PAGINATOR #} {% macro paginator(pagination, query_count) -%} {% if pagination.url_prev_page() %} Previous page {% endif %} {% if pagination.url_next_page(query_count) %} Next page {% endif %} {%- endmacro %} {# FORM RENDERING #} {% macro render_field_default(field) -%}
    {% if (field.type != 'HiddenField' or field.type !='CSRFTokenField') %} {{ field.label }} {% endif %}
    {% if (field.type == 'DaterangeField') %}
    {% endif %} {{ field(class_='form-control', **kwargs) }}
    {% if field.description %}

    {{field.description}}

    {% endif %} {% if field.errors %} {% for e in field.errors %}

    {{ e }}

    {% endfor %} {% endif %}
    {%- endmacro %} {# Renders checkbox fields since they are represented differently in bootstrap Params: field - WTForm field (there are no check, but you should put here only BooleanField. kwargs - pass any arguments you want in order to put them into the html attributes. There are few exceptions: for - for_, class - class_, class__ - class_ Example usage: {{ macros.render_checkbox_field(form.remember_me) }} #} {% macro render_checkbox_field(field) -%}
    {% if field.description %}

    {{field.description}}

    {% endif %} {%- endmacro %} {# Renders radio field Params: field - WTForm field (there are no check, but you should put here only BooleanField. kwargs - pass any arguments you want in order to put them into the html attributes. There are few exceptions: for - for_, class - class_, class__ - class_ Example usage: {{ macros.render_radio_field(form.answers) }} #} {% macro render_radio_field(field) -%} {% for value, label, _ in field.iter_choices() %}
    {% endfor %} {% if field.description %}

    {{field.description}}

    {% endif %} {%- endmacro %} {% macro render_field(f) -%} {% if f.type == 'BooleanField' %} {{ render_checkbox_field(f, **kwargs) }} {% elif f.type == 'RadioField' %} {{ render_radio_field(f, **kwargs) }} {% else %} {{ render_field_default(f, **kwargs) }} {% endif %} {%- endmacro %} {# Renders WTForm in bootstrap way. There are two ways to call function: - as macros: it will render all field forms using cycle to iterate over them - as call: it will insert form fields as you specify: e.g. {% call macros.render_form(form, action_url=url_for('login_view'), action_text='Login', class_='login-form') %} {{ macros.render_field(form.email, placeholder='Input email', type='email') }} {{ macros.render_field(form.password, placeholder='Input password', type='password') }} {{ macros.render_checkbox_field(form.remember_me, type='checkbox') }} {% endcall %} Params: form - WTForm class action_url - url where to submit this form action_text - text of submit button class_ - sets a class for form #} {% macro render_form(form, action_url='', action_text='Submit', class_='', btn_class='btn btn-default') -%}
    {{ form.hidden_tag() if form.hidden_tag }} {% if caller %} {{ caller() }} {% else %} {% for f in form %} {% if f.type == 'BooleanField' %} {{ render_checkbox_field(f) }} {% elif f.type == 'RadioField' %} {{ render_radio_field(f) }} {% else %} {{ render_field(f) }} {% endif %} {% endfor %} {% endif %}
    {%- endmacro %}