From c9418dd71781a799331ea6565d976b8b2a2300b0 Mon Sep 17 00:00:00 2001 From: Tosh Lyons Date: Thu, 13 Nov 2014 17:00:48 -0600 Subject: [PATCH] add ordered method to qs; limit curated qs --- promote_content/queryset.py | 9 ++++++++- promote_content/tests/test_settings.py | 1 + 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/promote_content/queryset.py b/promote_content/queryset.py index b18bb97..f2e5c33 100644 --- a/promote_content/queryset.py +++ b/promote_content/queryset.py @@ -51,7 +51,9 @@ def curated(self, context=None): start_filter = Q(**start_lte) | Q(**start_null) end_filter = Q(**end_gte) | Q(**end_null) - curated = self.filter(start_filter, end_filter) + curated_filter = {"%s__isnull" % curation_rel: False} + + curated = self.filter(start_filter, end_filter).filter(**curated_filter) if context is not None: # only include curation for supplied context @@ -66,6 +68,8 @@ def curated(self, context=None): ~Q(end_filter) ) else: + + # exclude curation that are applied to a particular context no_context_filter = { "%s__context_type__isnull" % curation_rel: False @@ -99,6 +103,9 @@ def curated(self, context=None): return uncurated_qs + def ordered(self): + return super(CuratedQuerySet, self).ordered() or self._is_curated + def __len__(self): if self._is_curated: return super(CuratedQuerySet, self._curated_qs).__len__() + super(CuratedQuerySet, self).__len__() diff --git a/promote_content/tests/test_settings.py b/promote_content/tests/test_settings.py index e5d32c3..528520a 100644 --- a/promote_content/tests/test_settings.py +++ b/promote_content/tests/test_settings.py @@ -22,3 +22,4 @@ 'django.contrib.admin', 'promote_content', ) +SECRET_KEY = '5-*-_t#&arg*mye1-48hv*c+pqsy6vlk2p=hp*6cezmiihiigh'