{% extends "base.html" %} {% block content %}

Pedidos de troca

{% for swap in swaps %}
{{ swap.assignment.date|dia_longo }}

{{ swap.assignment.schedule.name }}

{{ swap.requester.name }} passa o turno de {{ swap.assignment.date|dia }} {%- if swap.target_assignment %} e fica com o de {{ swap.target_assignment.date|dia }}{% endif %} {%- if swap.target_team %} ({{ swap.target_team.name }}){% endif %}.

{% if swap.message %}

{{ swap.message }}

{% endif %} {% if swap.accepted_by %}

Aceite por {{ swap.accepted_by.name }}.

{% endif %}
{{ swap.status|estado }}
{% set eligible = swap.requester_id not in my_team_ids and (swap.target_team_id is none or swap.target_team_id in my_team_ids) %} {% set can_accept = swap.status == 'open' and eligible %} {% set can_decline = swap.status in ['open', 'pending_approval'] and (current_user.is_admin or (swap.status == 'open' and eligible)) %} {% if can_accept %}
{% endif %} {% if can_decline %} {% set decline_action = '/swaps/' ~ swap.id ~ ('/admin-reject' if current_user.is_admin else '/reject') %}
{% endif %} {% if swap.requester_id in my_team_ids and swap.status in ['open', 'pending_approval'] %}
{% endif %} {% if current_user.is_admin and swap.status == 'approved' and swap.target_assignment %}
{% endif %} {% if current_user.is_admin and swap.status in ['open', 'pending_approval'] %}
{% if swap.accepted_by %} {% elif swap.target_team %} {# Nobody accepted yet: approve it exactly as it was requested. #} {% else %} {% endif %}
{% endif %}
{% else %}
Ainda não há pedidos de troca.
{% endfor %}
{% endblock %}