{# Édition liste UEs APC #}
{% for semestre_idx in semestre_ids %}
<div class="formation_list_ues">
    <div class="formation_list_ues_titre">Unités d'Enseignement 
    semestre {{semestre_idx}} &nbsp;-&nbsp; {{"%g"|format(ects_by_sem[semestre_idx]) | safe}} ECTS
    </div>
    <div class="formation_list_ues_content">
        <ul class="apc_ue_list">
            {% for ue in ues_by_sem[semestre_idx] %}
            <li class="notes_ue_list">
                {% if editable and not loop.first %}
                <a href="{{ url_for('notes.ue_move', 
                        scodoc_dept=g.scodoc_dept, ue_id=ue.id, after=0 )
                        }}" class="aud">{{icons.arrow_up|safe}}</a>
                {% else %}
                {{icons.arrow_none|safe}}
                {% endif %}
                {% if editable and not loop.last %}
                <a href="{{ url_for('notes.ue_move', 
                        scodoc_dept=g.scodoc_dept, ue_id=ue.id, after=1 )
                        }}" class="aud">{{icons.arrow_down|safe}}</a>
                {% else %}
                {{icons.arrow_none|safe}}
                {% endif %}
                </span>

                <a class="smallbutton" href="{{ url_for('notes.ue_delete', 
                        scodoc_dept=g.scodoc_dept, ue_id=ue.id)
                        }}">{% if editable and not ue.modules.count() %}{{icons.delete|safe}}{% else
                    %}{{icons.delete_disabled|safe}}{% endif %}</a>

                <span class="ue_type_{{ue.type}}">
                    <span class="ue_color_indicator" style="background:{{
                        ue.color if ue.color is not none else 'blue'}}"></span>
                    <b>{{ue.acronyme}} <a class="discretelink" href="{{
                        url_for('notes.ue_infos', scodoc_dept=g.scodoc_dept, ue_id=ue.id)}}" title="{{ue.acronyme}}: {{
                            ('pas de compétence associée' 
                            if ue.niveau_competence is none 
                            else 'compétence ' + ue.niveau_competence.annee + ' ' + ue.niveau_competence.competence.titre_long)
                            if ue.type == 0
                            else ''
                        }}">{{ue.titre}}</a>
                    </b>
                    {% set virg = joiner(", ") %}
                    <span class="ue_code">(
                        {%- if ue.ue_code -%}{{ virg() }}code {{ue.ue_code}} {%- endif -%}
                        {{ virg() }}
                        {%- if ue.type == 0 -%}
                        {{ue.ects
                        if ue.ects is not none
                        else '<span class="missing_ue_ects">aucun</span>'|safe
                        }} ECTS
                        {%- endif -%}
                        {%- if ue.code_apogee -%}
                        {{ virg() }} Apo {{ue.code_apogee}}
                        {%- endif -%}
                        )
                    </span>

                </span>

                {% if editable and not ue.is_locked() %}
                <a class="stdlink" href="{{ url_for('notes.ue_edit', 
                        scodoc_dept=g.scodoc_dept, ue_id=ue.id)
                        }}">modifier</a>
                {% endif %}

                {% if ue.type != codes_cursus.UE_SPORT %}
                    <div class="ue_choix_niveau">
                    {% if ue.niveau_competence %}
                        {{ue.niveau_competence.competence.titre}}
                        ordre {{ue.niveau_competence.ordre}}
                        <em>{{ue.niveau_competence.libelle}}</em>
                    {% else %}
                        <span class="fontred">{{scu.EMO_WARNING|safe}}
                            pas de niveau de compétence associé !
                        </span>
                    {% endif %}
                    {% if editable and not ue.is_locked() %}
                        <a class="stdlink" href="{{
                            url_for('notes.parcour_formation', scodoc_dept=g.scodoc_dept,
                                formation_id=formation.id )
                        }}">modifier</a>
                    {% endif %}
                        <div class="formation_parcs">
                            {% for parc in ue.parcours %}
                                <div>{{ parc.code }}</div>
                            {% endfor %}
                        </div>
                    </div>
                {% endif %}

                {% if ue.type == 1 and ue.modules.count() == 0 %}
                <span class="warning" title="pas de module, donc pas de bonus calculé">aucun module rattaché !</span>
                {% endif %}
            </li>
            {% endfor %}
        </ul>
    {% if editable %}
        <ul>
            <li class="notes_ue_list notes_ue_list_add"><a class="stdlink" href="{{
                    url_for('notes.ue_create', 
                            scodoc_dept=g.scodoc_dept, 
                            formation_id=formation.id,
                            default_semestre_idx=semestre_idx,
                            )}}">ajouter une UE</a>
            </li>
        </ul>
    {% endif %}
    </div>
</div>
{% endfor %}
