article_list.html 7.46 KB
Newer Older
luxcem's avatar
luxcem committed
1 2 3
{% extends "base.html" %}


4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34
{% block content-header %}
<div class="row justify-content-left">
  <div class="col-md-6 offset-md-1">
    <h4>Participez à l'aventure !</h4>
    <p>En tant que padawan
      <img class="inline-image" role="img" src="{% static 'img/padawan.svg' %}" />,
      aidez-nous à sélectionner les prochains articles à intégrer dans la
      revue de presse en votant pour les meilleurs. Les jedis
      <img class="inline-image" role="img" src="{% static 'img/jedi.svg' %}" />
      s'occupent ensuite de la relecture et de la mise en page des articles.
    </p>

    <p>Faites-vous connaître sur le
      <a target="_blank" href="https://www.laquadrature.net/wiki/IRC">salon IRC #lqdn-rp</a>
      où il vous sera fait bon accueil, ou en nous
      <a target="_blank" href="https://www.laquadrature.net/fr/contact">contactant par email</a>.
    </p>
  </div>
  <div class="col-md-4">
    <h4>Comment sélectionner un article ?</h4>
  <ol>
    <li>Il aborde les sujets sur lesquels La Quadrature est engagée (paquet télécom, ACTA, <i>etc.</i>).</li>
    <li>Il reflète ou appuie l'avis de La Quadrature.</li>
    <li>Il provient prioritairement de médias importants (presse nationale, régionale ou internationale).</li>
  </ol>

  </div>
</div>
{% endblock %}

{% block content %}
cynddl's avatar
cynddl committed
35
<div class="row">
36
<div class="col-md-12 white-bg">
cynddl's avatar
cynddl committed
37 38
  <ul class="nav nav-integrated">
    <li class="nav-item{% if filter_view == 'flux' %} active{% endif %}">
luxcem's avatar
luxcem committed
39
      <a class="nav-link" href="{% url 'rp:article-list' filter_view='flux'%}">
cynddl's avatar
cynddl committed
40 41 42 43
        Flux <img style="width: 2rem; margin-left: 0.5rem;" src="/static/img/cochon-01.png" alt="">
      </a>
    </li>
    <li class="nav-item {% if filter_view == 'draft' %} active{% endif %}">
luxcem's avatar
luxcem committed
44
      <a class="nav-link" href="{% url 'rp:article-list' filter_view='draft'%}">
cynddl's avatar
cynddl committed
45 46 47 48
        En attente <span class="badge badge-default">{{nb_draft}}</span>
      </a>
    </li>
    <li class="nav-item {% if filter_view == 'published' %} active{% endif %}">
luxcem's avatar
luxcem committed
49
      <a class="nav-link" href="{% url 'rp:article-list' filter_view='published'%}">Publiés</a>
cynddl's avatar
cynddl committed
50 51 52 53 54 55 56 57
    </li>
  </ul>

  <div class="well">
    {% if is_paginated %}
      <div class="pagination">
        <span class="page-links">
          {% if page_obj.has_previous %}
58
            <a href="?page={{ page_obj.previous_page_number }}"><i class="fa fa-chevron-left" aria-hidden="true"></i></a>
cynddl's avatar
cynddl committed
59 60 61 62 63
          {% endif %}
          <span class="page-current">
            Page {{ page_obj.number }} of {{ page_obj.paginator.num_pages }}
          </span>
          {% if page_obj.has_next %}
64
            <a href="?page={{ page_obj.next_page_number }}"><i class="fa fa-chevron-right" aria-hidden="true"></i></a>
cynddl's avatar
cynddl committed
65 66 67 68 69
          {% endif %}
        </span>
      </div>
    {% endif %}

luxcem's avatar
luxcem committed
70 71 72 73 74 75
    {% if filter_view == "rejected" %}
      <div class="alert alert-danger" role="alert">
        {% trans "Rejected articles" %}
      </div>
    {% endif %}

cynddl's avatar
cynddl committed
76 77 78 79 80 81 82 83 84 85
    <table class="article-table table table-sm my-4">
      <thead>
        <tr>
          <th>Priority</th>
          <th>ID</th>
          <th>Date</th>
          <th>Language</th>
          <th>Title</th>
          <th>Note</th>
          <th>Added&nbsp;by</th>
cynddl's avatar
cynddl committed
86
          <th>Actions<img class="inline-image ml-2" role="img" src="{% static 'img/jedi.svg' %}" /></th>
cynddl's avatar
cynddl committed
87 88 89 90
        </tr>
      </thead>
    <tbody>
    {% for article in object_list|slice:":10" %}
91 92
      <tr id="row_empty_{{article.id}}" class="empty-row"><td colspan="8"></td></tr>
      <tr id="row_{{article.id}}">
cynddl's avatar
cynddl committed
93 94 95 96 97 98 99
        <td class="icon-cell"><i class="fa fa-dot-circle-o" aria-hidden="true" style="color:red"></i></td>
        <td>{{article.id}}</td>
        <td>{{article.created_at |date:'d/m/y'}}<br />{{article.created_at |date:'H:i'}}</td>
        <td>{{article.lang}}</td>
        <td class="title-cell"><a target="_blank" href="{{article.url}}"><strong>{{article.title}}</strong></a></td>
        <td>
          <ul class="votes-list">
100 101 102 103 104 105 106 107
            <li class="actions-item" onclick="javascript:call_upvote({{article.id}})">
              <span id="count_up_{{article.id}}">{{article.und_score_up}}</span>
              <i class="fa fa-thumbs-up" aria-hidden="true" style="color:green"></i>
            </li>
            <li class="actions-item" onclick="javascript:call_downvote({{article.id}})">
              <span id="count_down_{{article.id}}">{{article.und_score_down}}</span>
              <i class="fa fa-thumbs-down" aria-hidden="true" style="color:red"></i>
            </li>
cynddl's avatar
cynddl committed
108 109 110 111 112
          </ul>
        </td>
        <td>{{article.und_votes.first.username}}</td>
        <td class="actions-cell">
          <ul class="actions-list">
113
            {% if filter_view == 'flux' %}
114
            <li class="actions-item actions-item-draft"><a href="#">
115 116
              <i class="fa fa-chevron-right" aria-hidden="true"></i> Mettre en attente</a>
            </li>
117 118
            <li class="actions-item actions-item-reject" onclick="javascript:call_reject({{article.id}})">
              <i class="fa fa-times" aria-hidden="true"></i> Rejeter
119 120
            </li>
            {% else %}
121
            <li class="actions-item actions-item-edit"><a href="{% url 'rp:article-edit' article.id %}">
cynddl's avatar
cynddl committed
122 123
              <i class="fa fa-pencil" aria-hidden="true"></i> Éditer</a>
            </li>
124 125
            <li class="actions-item actions-item-publish" onclick="javascript:call_publish({{article.id}})">
              <i class="fa fa-check" aria-hidden="true"></i> Publier
cynddl's avatar
cynddl committed
126
            </li>
127
            {% endif %}
cynddl's avatar
cynddl committed
128 129 130
          </ul>
        </td>
      </tr>
131
      {% if filter_view != 'flux' %}
132
      <tr id="row_tags_{{article.id}}" class="tags-row">
cynddl's avatar
cynddl committed
133 134 135 136
        <td colspan="8">
          <strong>Tags</strong> tags tags
        </td>
      </tr>
137
      {% endif %}
cynddl's avatar
cynddl committed
138 139 140 141 142 143
    {% endfor %}
    </tbody>
    </table>
  </div>
</div>
</div>
144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202

<script>
  function getCookie(name) {
      var cookieValue = null;
      if (document.cookie && document.cookie !== '') {
          var cookies = document.cookie.split(';');
          for (var i = 0; i < cookies.length; i++) {
              var cookie = jQuery.trim(cookies[i]);
              // Does this cookie string begin with the name we want?
              if (cookie.substring(0, name.length + 1) === (name + '=')) {
                  cookieValue = decodeURIComponent(cookie.substring(name.length + 1));
                  break;
              }
          }
      }
      return cookieValue;
  }
  var csrftoken = getCookie('csrftoken');

  function csrfSafeMethod(method) {
      // these HTTP methods do not require CSRF protection
      return (/^(GET|HEAD|OPTIONS|TRACE)$/.test(method));
  }
  $.ajaxSetup({
      beforeSend: function(xhr, settings) {
          if (!csrfSafeMethod(settings.type) && !this.crossDomain) {
              xhr.setRequestHeader("X-CSRFToken", csrftoken);
          }
      }
  });

  function call_upvote(id) {
    $.post("/api/articles/" + id + "/upvote/", function response(data) {
      $("#count_up_" + id).text(data.und_score_up);
    });
  }

  function call_downvote(id) {
    $.post("/api/articles/" + id + "/downvote/", function response(data) {
      $("#count_down_" + id).text(data.und_score_down);
    });
  }

  function call_reject(id) {
    $.post("/api/articles/" + id + "/reject/", function response(data) {
      $("#row_" + id).hide();
      $("#row_empty_" + id).hide();
      $("#row_tags_" + id).hide();
    });
  }

  function call_publish(id) {
    $.post("/api/articles/" + id + "/publish/", function response(data) {
      $("#row_" + id).hide();
      $("#row_empty_" + id).hide();
      $("#row_tags_" + id).hide();
    });
  }
</script>
luxcem's avatar
luxcem committed
203
{% endblock %}