From 21f60832486616d0b730b76ecd7e535321668977 Mon Sep 17 00:00:00 2001 From: Iacopo Spalletti Date: Sat, 8 Oct 2016 22:42:35 +0200 Subject: [PATCH] Fix order --- djangocms_blog/liveblog/models.py | 2 +- tests/test_liveblog.py | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/djangocms_blog/liveblog/models.py b/djangocms_blog/liveblog/models.py index 943c6e4..2b801ba 100644 --- a/djangocms_blog/liveblog/models.py +++ b/djangocms_blog/liveblog/models.py @@ -47,7 +47,7 @@ class LiveblogInterface(models.Model): items.extend( model.objects.filter(placeholder=self.placeholder).values('pk', 'post_date') ) - order = [item['pk'] for item in sorted(items, key=itemgetter('post_date'))] + order = reversed([item['pk'] for item in sorted(items, key=itemgetter('post_date'))]) reorder_plugins(self.placeholder, None, self.language, order) @property diff --git a/tests/test_liveblog.py b/tests/test_liveblog.py index 8cc7a37..93ec18a 100644 --- a/tests/test_liveblog.py +++ b/tests/test_liveblog.py @@ -210,11 +210,11 @@ try: post.liveblog, 'LiveblogPlugin', language='en', body='plugin 3', publish=True, post_date=current_date - timedelta(seconds=10) ) - self.assertTrue(Liveblog.objects.all().order_by('position').values_list('pk', flat=True), [3, 2, 1]) + self.assertEqual(list(Liveblog.objects.all().order_by('position').values_list('pk', flat=True)), [1, 2, 3]) plugin.post_date = current_date - timedelta(seconds=20) plugin.save() - self.assertTrue(Liveblog.objects.all().order_by('position').values_list('pk', flat=True), [1, 3, 2]) + self.assertEqual(list(Liveblog.objects.all().order_by('position').values_list('pk', flat=True)), [2, 3, 1]) except ImportError: # pragma: no cover pass