From e60a6ea9be4c0becd2876654d0694c203536f180 Mon Sep 17 00:00:00 2001 From: Leonhard Strohmidel Date: Sun, 25 Sep 2022 18:03:48 +0200 Subject: [PATCH] Fixing warning when testing (unordered list in pagination) --- django_lostplaces/lostplaces/models/models.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/django_lostplaces/lostplaces/models/models.py b/django_lostplaces/lostplaces/models/models.py index 8dd2f57..d21b024 100644 --- a/django_lostplaces/lostplaces/models/models.py +++ b/django_lostplaces/lostplaces/models/models.py @@ -88,15 +88,15 @@ class Explorer(models.Model): and the list views ''' if self.user.is_superuser: - return Place.objects.filter(mode='live') + return Place.objects.filter(mode='live').order_by('submitted_when') - return Place.objects.filter( + return (Place.objects.filter( level__lte=self.level, mode='live' ) | Place.objects.filter( submitted_by=self, mode='live' - ) + )).order_by('submitted_when') def get_places_eligible_to_see(self): if self.user.is_superuser: @@ -110,6 +110,12 @@ class Explorer(models.Model): place in self.get_places_eligible_to_see() ) + def get_drafts(self): + return Place.objects.filter( + submitted_by=self, + mode='draft' + ) + def __str__(self): return self.user.username