{% extends "core/base.jinja" %}
{% from 'core/macros.jinja' import user_profile_link %}

{% block title %}
  {% trans %}Weekmail{% endtrans %}
{% endblock %}

{% block content %}
  <h3>{% trans %}Weekmail{% endtrans %} {{ object.id }}</h3>
  <p><a href="{{ url('com:weekmail_preview') }}">{% trans %}Preview{% endtrans %}</a></p>
  <p><a href="{{ url('com:weekmail_preview') }}?send=true">{% trans %}Send{% endtrans %}</a></p>
  <p><a href="{{ url('com:weekmail_article') }}">{% trans %}New article{% endtrans %}</a></p>
  <h4>{% trans %}Articles in no weekmail yet{% endtrans %}</h4>
  <table>
    <thead>
      <tr>
        <td>{% trans %}Author{% endtrans %}</td>
        <td>{% trans %}Club{% endtrans %}</td>
        <td>{% trans %}Title{% endtrans %}</td>
        <td>{% trans %}Content{% endtrans %}</td>
        <td>{% trans %}Actions{% endtrans %}</td>
      </tr>
    </thead>
    <tbody>
      {% for a in orphans.all() %}
        <tr>
          <td>{{ user_profile_link(a.author) }}</td>
          <td><a href="{{ a.club.get_absolute_url() }}">{{ a.club }}</a></td>
          <td>{{ a.title }}</td>
          <td>{{ a.content|markdown }}</td>
          <td>
            <a href="{{ url('com:weekmail_article_edit', article_id=a.id) }}">{% trans %}Edit{% endtrans %}</a> |
            <a href="{{ url('com:weekmail_article_delete', article_id=a.id) }}">{% trans %}Delete{% endtrans %}</a> |
            <a href="?add_article={{ a.id }}">{% trans %}Add to weekmail{% endtrans %}</a>
          </td>
        </tr>
      {% endfor %}
    </tbody>
  </table>
  <h4>{% trans %}Articles included the next weekmail{% endtrans %}</h4>
  <table>
    <thead>
      <tr>
        <td>{% trans %}Author{% endtrans %}</td>
        <td>{% trans %}Club{% endtrans %}</td>
        <td>{% trans %}Title{% endtrans %}</td>
        <td>{% trans %}Content{% endtrans %}</td>
        <td>{% trans %}Actions{% endtrans %}</td>
      </tr>
    </thead>
    <tbody>
      {% for a in object.articles.order_by('rank') %}
        <tr>
          <td>{{ user_profile_link(a.author) }}</td>
          <td><a href="{{ a.club.get_absolute_url() }}">{{ a.club }}</a></td>
          <td>{{ a.title }}</td>
          <td>{{ a.content|markdown }}</td>
          <td>
            <a href="{{ url('com:weekmail_article_edit', article_id=a.id) }}">{% trans %}Edit{% endtrans %}</a> |
            <a href="{{ url('com:weekmail_article_delete', article_id=a.id) }}">{% trans %}Delete{% endtrans %}</a> |
            <a href="?del_article={{ a.id }}">{% trans %}Delete from weekmail{% endtrans %}</a> |
            <a href="?up_article={{ a.id }}">{% trans %}Up{% endtrans %}</a> |
            <a href="?down_article={{ a.id }}">{% trans %}Down{% endtrans %}</a>
          </td>
        </tr>
      {% endfor %}
    </tbody>
  </table>
  <form action="" method="post" enctype="multipart/form-data">
    {% csrf_token %}
    {{ form.as_p() }}
    <p><input type="submit" value="{% trans %}Save{% endtrans %}" /></p>
  </form>
{% endblock %}



