{# Field rendering shared by the three editing screens, so a course, a
category and a page present the same controls in the same order and
staff only have to learn them once. #}
{% macro field(f) %}
{{ f.label(class="form-label") }}
{{ f(class="form-control", **kwargs) }}
{% for error in f.errors %}
{{ error }}
{% endfor %}
{% endmacro %}
{% macro flashes() %}
{% with messages = get_flashed_messages(with_categories=true) %}
{% for category, message in messages %}
{{ message }}
{% endfor %}
{% endwith %}
{% endmacro %}
{% macro visibility(form) %}
{% set timezone = config['COURSES_TIMEZONE'] %}
{# The two controls, together, with the timezone spelled out. A date typed
in the wrong zone releases material early, and the field itself is the
only place that warning is any use. #}
{% endmacro %}
{% macro state_badge(item) %}
{%- if item.is_released() -%}
{{ _('Visible') }}
{%- elif item.publish_at -%}
{{ _('Withheld until %(moment)s', moment=item.publish_at|course_datetime) }}
{%- else -%}
{{ _('Withheld') }}
{%- endif -%}
{% endmacro %}
{% macro delete_button(action, form, question) %}
{% endmacro %}