{# -*- mode: jinja-html -*- #}
{% macro render_field(field) %}
<div>
    <span class="wtf-field">{{ field.label }} :</span>
    <span class="wtf-field">{{ field()|safe }}
        {% if field.errors %}
        <ul class=errors>
            {% for error in field.errors %}
            <li>{{ error }}</li>
            {% endfor %}
        </ul>
        {% endif %}
    </span>
</div>
{% endmacro %}

{% macro render_logo(logo_form, titre=None) %}
    {% if titre %}
        <tr>
            <td colspan="2">
                <h3>{{ titre }}</h3>
                <hr/>
            </td>
        </tr>
    {%  endif %}
    <tr>
        <td style="padding-right: 20px; vertical-align: top;">
            <p class="help">{{ logo_form.form.description }} Image actuelle:</p>
            <div class="img-container"><img src="{{ logo_form.logo.get_url_small() }}"
                    alt="pas de logo chargé" /></div>
        </td>
        <td style="vertical-align: top;">
            {{ logo_form.form.dept_id() }}
            {{ logo_form.form.logo_id() }}
            Nom: {{ logo_form.form.logo.logoname }}<br/>
{#            {{ logo_form.form.description }}<br/>#}
            Format: {{ logo_form.logo.suffix }}<br/>
            Taille en px: {{ logo_form.logo.size }}<br/>
            {% if logo_form.logo.mm %}
                Taile en mm: {{ logo_form.logo.mm }}<br/>
            {%  endif %}
            Aspect ratio: {{ logo_form.logo.aspect_ratio }}<br/>
            <hr/>
            Usage: {{ logo_form.logo.get_usage() }}
            <hr/>
            <span class="wtf-field">{{  render_field(logo_form.upload) }}</span>
            {% if logo_form.can_delete %}
                {{ render_field(logo_form.do_delete) }}
            {% endif %}
        </td>
    </tr>
{% endmacro %}


{#{% block app_content %}#}

{% if scodoc_dept %}
<h1>Logos du département {{ scodoc_dept }}</h1>
{% else %}
<h1>Configuration générale</h1>
{% endif %}

<form class="sco-form" action="" method="post" enctype="multipart/form-data" novalidate>
    {{ form.hidden_tag() }}
    {% if not scodoc_dept %}
    <div class="sco_help">Les paramètres donnés ici s'appliquent à tout ScoDoc (tous les départements):</div>
        {{ render_field(form.bonus_sport_func_name)}}
        <div class="configuration_logo">
        <table>
            {{ render_logo(form.header, 'Logo en-tête') }}
            {{ render_logo(form.footer, 'Logo pied de page') }}
        </table>
        </div>
    {% endif %}

    <!-- <div class="sco_help">Les paramètres ci-dessous peuvent être changés dans chaque département
        (paramétrage).<br />On indique ici les valeurs initiales par défaut:
    </div> -->

    <div class="sco-submit">{{ form.submit() }}</div>
</form>
{#{% endblock %}#}