{% macro render_select(field) -%} {# Renders selects. If there's only one choice, it hides the input. #} {% if field.iter_choices()|list|length == 1 %} {{ field(style="display: none;") }} {% else %} {{ field.label }} {{ field(class="form-control") }} {% endif %} {%- endmacro %} {% macro render_errors(field) -%} {% if field.errors %} {% for error in field.errors %} {% if error is string %} {{ error }} {% elif error is iterable %} {% endif %} {% endfor %} {% endif %} {%- endmacro %} {% macro render_input(field, inline=False) -%}
{% if inline %} {{ field.label(class="sr-only") }} {{ field(class="form-control", placeholder=field.label.text) }} {% else %} {% if field.widget.input_type == 'submit' %} {{ field(class="btn btn-default") }} {% else %} {% if field.iter_choices is defined %} {{ render_select(field) }} {% else %} {% if field.widget.input_type != 'hidden' %} {{ field.label }} {% endif %} {{ field(class="form-control") }} {% if field.description %} {{ field.description }} {% endif %} {{ render_errors(field) }} {%- endif %} {% endif %} {% endif %}
{%- endmacro %} {% macro render_form(form, inline=False) %}
{% for field in form %} {{ render_input(field, inline) }} {% endfor %}
{% endmacro %} {% macro navbar_button(text, view=None, count=None) %} {% if view %} {% with url = url_for(view) %} {{ text }}{{ (' ' ~ count ~ '')|safe if count is not none and count != 0 }} {% endwith %} {% else %}
  • {{ text }}
  • {% endif %} {% endmacro %} {% macro status_color(action_type) %} {% if action_type == ActionType.evaluating -%} warning {%- elif action_type == ActionType.approved -%} info {%- elif action_type == ActionType.paid -%} success {%- elif action_type == ActionType.incomplete or state_string == ActionType.rejected -%} danger {%- endif %} {% endmacro %}