From 5d5aa82171bfb46292a0018bb67034e3a3859198 Mon Sep 17 00:00:00 2001 From: Alan Mooiman Date: Wed, 21 Mar 2018 16:11:11 -0400 Subject: [PATCH] Return entries with newest first (#333) Closes #324 --- pulseapi/profiles/serializers.py | 4 ++-- pulseapi/profiles/test_views.py | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/pulseapi/profiles/serializers.py b/pulseapi/profiles/serializers.py index a5fd395..fb6c60b 100644 --- a/pulseapi/profiles/serializers.py +++ b/pulseapi/profiles/serializers.py @@ -145,7 +145,7 @@ class UserProfilePublicSerializer(UserProfileSerializer): user = instance.user return EntrySerializer( - user.entries.public(), + user.entries.public().order_by('-id'), context=self.context, many=True, ).data if user else [] @@ -153,7 +153,7 @@ class UserProfilePublicSerializer(UserProfileSerializer): created_entries = serializers.SerializerMethodField() def get_created_entries(self, instance): - entry_creator_records = OrderedCreatorRecord.objects.filter(creator__profile=instance) + entry_creator_records = OrderedCreatorRecord.objects.filter(creator__profile=instance).order_by('-id') return [EntrySerializer(x.entry).data for x in entry_creator_records if x.entry.is_approved()] my_profile = serializers.SerializerMethodField() diff --git a/pulseapi/profiles/test_views.py b/pulseapi/profiles/test_views.py index 988641e..c4c6967 100644 --- a/pulseapi/profiles/test_views.py +++ b/pulseapi/profiles/test_views.py @@ -37,7 +37,7 @@ class TestProfileView(PulseMemberTestCase): created_entries = [] entry_creators = OrderedCreatorRecord.objects.filter( creator__profile=id - ) + ).order_by('-id') created_entries = [EntrySerializer(x.entry).data for x in entry_creators] self.assertEqual(entriesjson['profile_id'], id)