Fix order

This commit is contained in:
Iacopo Spalletti 2016-10-08 22:42:35 +02:00
parent bb1a2a1cd3
commit 21f6083248
No known key found for this signature in database
GPG key ID: BDCBC2EB289F60C6
2 changed files with 3 additions and 3 deletions

View file

@ -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

View file

@ -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