Commit 77ab5980 authored by cynddl's avatar cynddl
Browse files

Cleanup base template and add API calls for upvote/downvote/reject/publish in templates

parent 5f8c1d10
......@@ -58,8 +58,8 @@
{% for article in object_list|slice:":10" %}
<tr class="empty-row"><td colspan="8"></td></tr>
<tr id="row_empty_{{}}" class="empty-row"><td colspan="8"></td></tr>
<tr id="row_{{}}">
<td class="icon-cell"><i class="fa fa-dot-circle-o" aria-hidden="true" style="color:red"></i></td>
<td>{{article.created_at |date:'d/m/y'}}<br />{{article.created_at |date:'H:i'}}</td>
......@@ -67,33 +67,39 @@
<td class="title-cell"><a target="_blank" href="{{article.url}}"><strong>{{article.title}}</strong></a></td>
<ul class="votes-list">
<li><a href="">+{{article.und_score_up}} <i class="fa fa-thumbs-up" aria-hidden="true" style="color:green"></i></a></li>
<li><a href="">-{{article.und_score_down}} <i class="fa fa-thumbs-down" aria-hidden="true" style="color:red"></i></a></li>
<li class="actions-item" onclick="javascript:call_upvote({{}})">
<span id="count_up_{{}}">{{article.und_score_up}}</span>
<i class="fa fa-thumbs-up" aria-hidden="true" style="color:green"></i>
<li class="actions-item" onclick="javascript:call_downvote({{}})">
<span id="count_down_{{}}">{{article.und_score_down}}</span>
<i class="fa fa-thumbs-down" aria-hidden="true" style="color:red"></i>
<td class="actions-cell">
<ul class="actions-list">
{% if filter_view == 'flux' %}
<li class="actions-item-draft"><a href="#">
<li class="actions-item actions-item-draft"><a href="#">
<i class="fa fa-chevron-right" aria-hidden="true"></i> Mettre en attente</a>
<li class="actions-item-reject"><a href="#">
<i class="fa fa-times" aria-hidden="true"></i> Rejeter</a>
<li class="actions-item actions-item-reject" onclick="javascript:call_reject({{}})">
<i class="fa fa-times" aria-hidden="true"></i> Rejeter
{% else %}
<li class="actions-item-edit"><a href="#">
<li class="actions-item actions-item-edit"><a href="#">
<i class="fa fa-pencil" aria-hidden="true"></i> Éditer</a>
<li class="actions-item-publish"><a href="#">
<i class="fa fa-check" aria-hidden="true"></i> Publier</a>
<li class="actions-item actions-item-publish" onclick="javascript:call_publish({{}})">
<i class="fa fa-check" aria-hidden="true"></i> Publier
{% endif %}
{% if filter_view != 'flux' %}
<tr class="tags-row">
<tr id="row_tags_{{}}" class="tags-row">
<td colspan="8">
<strong>Tags</strong> tags tags
......@@ -105,4 +111,63 @@
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));
return cookieValue;
var csrftoken = getCookie('csrftoken');
function csrfSafeMethod(method) {
// these HTTP methods do not require CSRF protection
return (/^(GET|HEAD|OPTIONS|TRACE)$/.test(method));
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();
{% endblock %}
......@@ -44,6 +44,11 @@ table.article-table td.actions-cell {
background-color: #ebf3ff;
padding: 1rem 1.5rem;
li.actions-item {
cursor: pointer;
table.article-table ul {
padding: 0;
margin: 0;
......@@ -3,30 +3,21 @@
<!-- Header -->
<title>Soutenez La Quadrature du Net !</title>
<title>Revue de presse de La Quadrature du Net</title>
<meta charset="utf-8" />
<meta name="author" content="La Quadrature du Net" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<!-- Open graph -->
<meta property="og:title" content="Soutenez La Quadrature du Net !" />
<meta property="og:url" content="" />
<!-- FIXME: Change the OG image -->
<meta property="og:image" content="" />
<meta property="og:title" content="Revue de presse de La Quadrature du Net" />
<meta property="og:url" content="" />
<meta property="og:site_name" content="La Quadrature du Net" />
<meta property="og:description" content="Depuis sa création, La Quadrature du Net agit sans relâche pour qu'Internet demeure un outil de partage, de libre expression, d'émancipation et permette la participation de tous au débat démocratique." />
<meta property="og:description" content="" />
<!-- Twitter cards -->
<meta name="twitter:card" content="summary_large_image" />
<meta name="twitter:site" content="@laquadrature" />
<meta name="twitter:title" content="Soutenez la Quadrature du Net&nbsp!">
<meta name="twitter:image" content="">
<meta name="twitter:description" content="Depuis sa création, La Quadrature du Net agit sans relâche pour qu'Internet demeure un outil de partage, de libre expression, d'émancipation et permette la participation de tous au débat démocratique.">
<!-- Styles -->
<!-- Styles and scripts -->
<script src="" integrity="sha256-hwg4gsxgFZhOsEEamdOYGBf13FyQuiTwlAQgxVSNgt4=" crossorigin="anonymous"></script>
<link rel="stylesheet" href="" integrity="sha384-rwoIResjU2yc3z8GV/NPeZWAv56rSmLldC3R/AZzGRnGxQQKnKkoFVhFQhNUwEyJ" crossorigin="anonymous">
<script src="" integrity="sha384-vBWWzlZJ8ea9aCX4pEW3rVHjgjt7zpkNpZk+02D9phzyeVkE+jo0ieGizqPLForn" crossorigin="anonymous"></script>
<!-- <link rel="stylesheet" href="/static/css/bootstrap.css" media="all"> -->
<script src="" integrity="sha384-vBWWzlZJ8ea9aCX4pEW3rVHjgjt7zpkNpZk+02D9phzyeVkE+jo0ieGizqPLForn" crossorigin="anonymous"></script>
<link rel="stylesheet" href="/static/css/font-awesome.css" media="all">
<link rel="stylesheet" href="/static/css/fonts.css" media="all">
......@@ -135,57 +126,14 @@
<nav class="navbar navbar-toggleable-md">
<div class="collapse navbar-collapse" id="navbarSupportedContent">
<a class="navbar-brand" href="/"><img class="float-left" src="/static/img/logo.png" alt=""></a>
<ul class="navbar-nav ml-auto">
<li class="nav-item"><a class="nav-link" href="#add-account">Vous êtes Padawan</a></li>
<div class="visible-xs visible-sm">
<nav id="toolbar" class="navbar navbar-default navbar-white">
<div class="container-fluid">
<div class="navbar-header">
<a class="navbar-brand" href="/">
<img src="/static/img/logo.png" alt="">
<ul class="nav navbar-nav">
<li class="pull-right"><a href="#login">Se connecter</a></li>
<li class="pull-right collapsible-menu"><a href="#action-menu">Menu</a>
<span class="menu-collapsed-target" id="perso-menu"></span>
<div class="menu-collapsed">
<ul class="nav navbar-nav">
<li><a href="/perso/logout">Déconnexion</a></li>
<li><a href="/perso">Page Perso</a></li>
<li><a href="#">Fermer</a></li>
<span class="menu-collapsed-target" id="action-menu"></span>
<div class="menu-collapsed">
<ul class="nav navbar-nav">
<li> <a href="/why" >À quoi sert votre don&nbsp;?</a></li>
<li> <a href="/what" >Que fait LQDN&nbsp;?</a></li>
<li> <a href="/who" >Comment fonctionne LQDN&nbsp;?</a></li>
<li> <a href="/faq" >FAQ</a></li>
<li> <a href="/material" >Relayer</a></li>
<li> <a href="/" >Home</a></li>
<li><a href="#">Fermer</a></li>
</div> -->
<section class="text-center container-fluid white">
<div id="subtitle" class="row justify-content-center">
<div class="page-header col-md-10">
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment