article_list.html 8.33 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
    <table class="article-table table table-sm my-4">
      <thead>
        <tr>
79
          {% if filter_view != "published" %}<th>Priority</th>{% endif %}
cynddl's avatar
cynddl committed
80
81
82
83
84
85
          <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}}">
93
94
95
96
97
        {% if filter_view != "published" %}
        <td class="icon-cell actions-item" onclick="javascript:call_priority({{article.id}}, {{article.priority|yesno:"false,true"}})">
          <i id="priority_{{article.id}}" class="fa fa-star{{ article.priority|yesno:",-o" }}" aria-hidden="true"></i>
        </td>
        {% endif %}
cynddl's avatar
cynddl committed
98
99
100
101
102
        <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>
103
104
105
          {% if filter_view == "published" %}
          {{article.und_score}}
          {% else %}
cynddl's avatar
cynddl committed
106
          <ul class="votes-list">
107
108
109
110
111
112
113
114
            <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
115
          </ul>
116
          {% endif %}
cynddl's avatar
cynddl committed
117
        </td>
118
        <td>{{article.created_by}}</td>
cynddl's avatar
cynddl committed
119
120
        <td class="actions-cell">
          <ul class="actions-list">
121
            {% if filter_view == 'flux' %}
122
123
            <li class="actions-item actions-item-draft" onclick="javascript:call_recover({{article.id}})"><a href="#">
              <i class="fa fa-chevron-right" aria-hidden="true"></i> Forcer</a>
124
            </li>
125
126
            <li class="actions-item actions-item-reject" onclick="javascript:call_reject({{article.id}})">
              <i class="fa fa-times" aria-hidden="true"></i> Rejeter
127
128
            </li>
            {% else %}
129
            <li class="actions-item actions-item-edit"><a href="{% url 'rp:article-edit' article.id %}">
cynddl's avatar
cynddl committed
130
131
              <i class="fa fa-pencil" aria-hidden="true"></i> Éditer</a>
            </li>
132
133
            <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
134
            </li>
135
            {% endif %}
cynddl's avatar
cynddl committed
136
137
138
          </ul>
        </td>
      </tr>
cynddl's avatar
cynddl committed
139
      {% if filter_view != 'flux' and article.tags.count %}
140
      <tr id="row_tags_{{article.id}}" class="tags-row">
cynddl's avatar
cynddl committed
141
        <td colspan="8">
cynddl's avatar
cynddl committed
142
143
144
          {% for t in article.tags.all %}
          <span class="badge badge-info">{{t}}</span>
          {% endfor %}
cynddl's avatar
cynddl committed
145
146
        </td>
      </tr>
147
      {% endif %}
cynddl's avatar
cynddl committed
148
149
150
151
152
153
    {% endfor %}
    </tbody>
    </table>
  </div>
</div>
</div>
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

<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);
    });
  }

197
198
199
200
201
202
203
204
205
206
207
208
  function clean_row(id) {
    $("#row_" + id).hide();
    $("#row_empty_" + id).hide();
    $("#row_tags_" + id).hide();
  }

  function call_recover(id) {
    $.post("/api/articles/" + id + "/recover/", function response(data) {
      clean_row(id);
    });
  }

209
210
  function call_reject(id) {
    $.post("/api/articles/" + id + "/reject/", function response(data) {
211
      clean_row(id);
212
213
214
215
216
    });
  }

  function call_publish(id) {
    $.post("/api/articles/" + id + "/publish/", function response(data) {
217
      clean_row(id);
218
219
    });
  }
220
221
222
223
224
225
226

  function call_priority(id, flag) {
    var url = "/api/articles/" + id + "/priority/" + (flag ? "on/" : "off/");
    $.post(url, {'priority': flag}, function response(data) {
      $("#priority_" + id).toggleClass("fa-star").toggleClass("fa-star-o");
    });
  }
227
</script>
luxcem's avatar
luxcem committed
228
{% endblock %}