{% load assets combo gnm humanize %}
<div class="cartads-dossiers current-forms">
{% for dossier in json.data %}
{% with producer=dossier.commune_label|as_producer %}

<div class="tile producer-{{producer.slug}}">
  <div class="tile-picture" style="background-image: url({% asset_url "passerelle:cartads:dossier" size=size crop="center" %})"></div>
  <div class="tile-head">
    <div class="tile-title">
      <h2><a href="{{dossier.formdata_url}}">{% if not dossier.text %}{{ dossier.type_dossier_label }}{% else %}{{dossier.text}}{% if dossier.cartads_infos.DescriptionProjet %} — {{dossier.cartads_infos.DescriptionProjet|truncatechars:60}}{% endif %}{% endif %}</a></h2>
      <span class="producer" style="background-image: url({% asset_url "logo:"|add:producer.slug %})">{{ producer.label }}</span>
    </div>
  </div>
  <div class="tile-content">
    <p>
      {{dossier.cartads_infos.AdresseTerrainNVoirie|default:""}}
      {{dossier.cartads_infos.AdresseTerrainLibelleVoie}}
      {% if dossier.cartads_infos.AdresseTerrainLibelleVoie and dossier.cartads_infos.AdresseTerrainCodePostal %} / {% endif %}
      {{dossier.cartads_infos.AdresseTerrainCodePostal}} {{dossier.cartads_infos.AdresseTerrainCommune}}
      {% if not dossier.text %}{{ dossier.commune_label }}{% endif %}
    </p>
    <p>
     {% if dossier.cartads_infos.DateDepot %}
     Date de dépôt : {{dossier.cartads_infos.DateDepot|strptime:"%Y-%m-%dT%H:%M:%S"|date}}
     {% endif %}
    </p>
    <p class="form-status">
      Étape actuelle : <span class="status-name">{% if not dossier.text %}Demande enregistrée{% else %}{% firstof dossier.status.publik_status_label dossier.status.status_label %}{% endif %}</span><br>
    </p>
  </div>

  <div class="tile-actions">
    <a class="action-unsubscribe" href="/gnm/cartads/unsubscribe/?numero_dossier={{dossier.text}}">Ne plus suivre ce dossier</a>
    <a class="action-more-info" href="{{dossier.formdata_url}}">Plus d’infos</a>
  </div>
</div>

{% endwith %}
{% endfor %}
</div>
