From 7bdb20828d7b02077a49ae8d72e637fdebe450e0 Mon Sep 17 00:00:00 2001
From: Laville Augustin
Date: Tue, 11 Nov 2014 14:40:15 +0100
Subject: [PATCH 1/5] =?UTF-8?q?Fix=20#1731=20:=20trier=20les=20tutoriels?=
=?UTF-8?q?=20par=20ordre=20alphab=C3=A9tique?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
zds/member/views.py | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/zds/member/views.py b/zds/member/views.py
index 3654815b8d..2823b849db 100644
--- a/zds/member/views.py
+++ b/zds/member/views.py
@@ -392,6 +392,10 @@ def tutorials(request):
else:
user_tutorials = profile.get_tutos()
+ # Order by title
+
+ user_tutorials = user_tutorials.extra(select={'lower_title': 'lower(title)'}).order_by('lower_title')
+
return render(request, 'tutorial/member/index.html', {'tutorials': user_tutorials, 'type': state})
From efe9cec6c0b94d116f1ca6d842e6a960f0f3fbf1 Mon Sep 17 00:00:00 2001
From: Laville Augustin
Date: Tue, 11 Nov 2014 14:41:29 +0100
Subject: [PATCH 2/5] =?UTF-8?q?Fix=20#1731=20:=20trier=20les=20articles=20?=
=?UTF-8?q?par=20ordre=20alphab=C3=A9tique?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
zds/member/views.py | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/zds/member/views.py b/zds/member/views.py
index 2823b849db..88e6b1c1e6 100644
--- a/zds/member/views.py
+++ b/zds/member/views.py
@@ -423,7 +423,11 @@ def articles(request):
else:
user_articles = profile.get_articles()
- return render(request, 'article/member/index.html', {'articles': user_articles, 'type': state})
+ # Order by title
+
+ user_articles = user_articles.extra(select={'lower_title': 'lower(title)'}).order_by('lower_title')
+
+ return render(request, 'article/member/index.html', {'articles': user_articles, 'type': type})
# settings for public profile
From 730897d2a11e4beb99e327eec851afe6cbc20d32 Mon Sep 17 00:00:00 2001
From: Laville Augustin
Date: Tue, 11 Nov 2014 15:25:48 +0100
Subject: [PATCH 3/5] =?UTF-8?q?Fix=20#1731=20:=20Ajout=20de=20la=20possibi?=
=?UTF-8?q?lit=C3=A9=20de=20trier=20ses=20articles/tutoriels?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
templates/article/member/index.html | 44 ++++++++++++++++++++++---
templates/tutorial/member/index.html | 46 ++++++++++++++++++++++----
zds/member/views.py | 49 +++++++++++++++++++++++-----
3 files changed, 120 insertions(+), 19 deletions(-)
diff --git a/templates/article/member/index.html b/templates/article/member/index.html
index f0c0335537..3fa5fb284b 100644
--- a/templates/article/member/index.html
+++ b/templates/article/member/index.html
@@ -37,6 +37,13 @@
{% elif request.GET.type == "draft" %}
/ {% trans "Brouillons" %}
{% endif %}
+ {% if sort == "abc" %}
+ / Par ordre alphabétique
+ {% elif sort == "creation" %}
+ / Par date de création
+ {% elif sort == "modification" %}
+ / Par date de dernière modification
+ {% endif %}
{% endblock %}
@@ -50,6 +57,13 @@
{% elif request.GET.type == "draft" %}
/ {% trans "Brouillons" %}
{% endif %}
+ {% if sort == "abc" %}
+ / Par ordre alphabétique
+ {% elif sort == "creation" %}
+ / Par date de création
+ {% elif sort == "modification" %}
+ / Par date de dernière modification
+ {% endif %}
{% endblock %}
@@ -64,29 +78,49 @@
{% trans "Filtres" %}
+
{% endblock %}
@@ -104,4 +138,4 @@ {% trans "Filtres" %}
{% trans "Aucun article disponible" %}.
{% endif %}
-{% endblock %}
\ No newline at end of file
+{% endblock %}
diff --git a/templates/tutorial/member/index.html b/templates/tutorial/member/index.html
index b6be5eeb8b..146b39db0f 100644
--- a/templates/tutorial/member/index.html
+++ b/templates/tutorial/member/index.html
@@ -14,6 +14,13 @@
{% elif request.GET.type == "draft" %}
/ {% trans "Brouillons" %}
{% endif %}
+ {% if sort == "abc" %}
+ / Par ordre alphabétique
+ {% elif sort == "creation" %}
+ / Par date de création
+ {% elif sort == "modification" %}
+ / Par date de dernière modification
+ {% endif %}
{% endblock %}
@@ -54,6 +61,13 @@
{% elif request.GET.type == "draft" %}
/ {% trans "Brouillons" %}
{% endif %}
+ {% if sort == "abc" %}
+ / Par ordre alphabétique
+ {% elif sort == "creation" %}
+ / Par date de création
+ {% elif sort == "modification" %}
+ / Par date de dernière modification
+ {% endif %}
{% endblock %}
@@ -113,33 +127,53 @@ {{ tutorial.title }}
{% trans "Filtres" %}
+
-{% endblock %}
\ No newline at end of file
+{% endblock %}
diff --git a/zds/member/views.py b/zds/member/views.py
index 88e6b1c1e6..67301332b1 100644
--- a/zds/member/views.py
+++ b/zds/member/views.py
@@ -378,6 +378,13 @@ def tutorials(request):
except KeyError:
state = None
+ # The sort indicate the order of tutorials.
+
+ try:
+ sort_tuto = request.GET['sort']
+ except KeyError:
+ sort_tuto = 'abc'
+
# Retrieves all tutorials of the current user.
profile = request.user.profile
@@ -392,25 +399,42 @@ def tutorials(request):
else:
user_tutorials = profile.get_tutos()
- # Order by title
+ # Order articles (abc by default)
+
+ if sort_tuto == 'creation':
+ pass # nothing to do. Tutorials are already sort by creation date
+ elif sort_tuto == 'modification':
+ user_tutorials = user_tutorials.order_by('-update')
+ else:
+ user_tutorials = user_tutorials.extra(select={'lower_title': 'lower(title)'}).order_by('lower_title')
- user_tutorials = user_tutorials.extra(select={'lower_title': 'lower(title)'}).order_by('lower_title')
- return render(request, 'tutorial/member/index.html', {'tutorials': user_tutorials, 'type': state})
+ return render(
+ request,
+ 'tutorial/member/index.html',
+ {'tutorials': user_tutorials, 'type': state, 'sort': sort_tuto}
+ )
@login_required
def articles(request):
"""Returns all articles of the authenticated user."""
- # The type indicate what the user would like to display. We can display
- # public, draft or all user's articles.
+ # The type indicate what the user would like to display. We can display public, draft or all user's articles.
try:
state = request.GET['type']
except KeyError:
state = None
+ # The sort indicate the order of articles.
+
+ try:
+ sort_articles = request.GET['sort']
+ except KeyError:
+ sort_articles = 'abc'
+
+
# Retrieves all articles of the current user.
profile = request.user.profile
@@ -423,11 +447,20 @@ def articles(request):
else:
user_articles = profile.get_articles()
- # Order by title
+ # Order articles (abc by default)
- user_articles = user_articles.extra(select={'lower_title': 'lower(title)'}).order_by('lower_title')
+ if sort_articles == 'creation':
+ pass # nothing to do. Articles are already sort by creation date
+ elif sort_articles == 'modification':
+ user_articles = user_articles.order_by('-update')
+ else:
+ user_articles = user_articles.extra(select={'lower_title': 'lower(title)'}).order_by('lower_title')
- return render(request, 'article/member/index.html', {'articles': user_articles, 'type': type})
+ return render(
+ request,
+ 'article/member/index.html',
+ {'articles': user_articles, 'type': type, 'sort': sort_articles}
+ )
# settings for public profile
From 5924205d1a22e3530c596361409bc3838734e393 Mon Sep 17 00:00:00 2001
From: Laville Augustin
Date: Tue, 11 Nov 2014 16:57:58 +0100
Subject: [PATCH 4/5] Fix #1731 : PEP-8
---
zds/member/views.py | 1 -
1 file changed, 1 deletion(-)
diff --git a/zds/member/views.py b/zds/member/views.py
index 67301332b1..0ff66b2881 100644
--- a/zds/member/views.py
+++ b/zds/member/views.py
@@ -434,7 +434,6 @@ def articles(request):
except KeyError:
sort_articles = 'abc'
-
# Retrieves all articles of the current user.
profile = request.user.profile
From d0e7045f40f023fc82da8ced4a5581572b5be951 Mon Sep 17 00:00:00 2001
From: Augustin Laville
Date: Sun, 21 Dec 2014 19:14:03 +0100
Subject: [PATCH 5/5] Correction de PEP-8 mineure
---
zds/member/views.py | 1 -
1 file changed, 1 deletion(-)
diff --git a/zds/member/views.py b/zds/member/views.py
index 0ff66b2881..18b4d123ab 100644
--- a/zds/member/views.py
+++ b/zds/member/views.py
@@ -408,7 +408,6 @@ def tutorials(request):
else:
user_tutorials = user_tutorials.extra(select={'lower_title': 'lower(title)'}).order_by('lower_title')
-
return render(
request,
'tutorial/member/index.html',