From 6d627ac2407769afad295837f5e6d4916102c552 Mon Sep 17 00:00:00 2001 From: Kuroshini Date: Tue, 21 Jan 2020 16:00:56 +0300 Subject: [PATCH] Revert "fix news ordering" This reverts commit 1a6828b --- apps/news/models.py | 10 ---------- apps/news/views.py | 6 +++--- 2 files changed, 3 insertions(+), 13 deletions(-) diff --git a/apps/news/models.py b/apps/news/models.py index e4908368..fffed321 100644 --- a/apps/news/models.py +++ b/apps/news/models.py @@ -144,16 +144,6 @@ class NewsQuerySet(TranslationQuerysetMixin): def by_locale(self, locale): return self.filter(title__icontains=locale) - def annotate_is_null_publication(self): - return self.annotate( - is_null_publication=Case( - When(publication_date__isnull=True, then=True), - When(publication_time__isnull=True, then=True), - default=False, - output_field=models.BooleanField(default=False), - ) - ) - class News(GalleryMixin, BaseAttributes, TranslatedFieldsMixin, HasTagsMixin, FavoritesMixin): diff --git a/apps/news/views.py b/apps/news/views.py index 06278dbf..d63fc554 100644 --- a/apps/news/views.py +++ b/apps/news/views.py @@ -126,15 +126,15 @@ class NewsBackOfficeLCView(NewsBackOfficeMixinView, def get_queryset(self): """Override get_queryset method.""" - qs = super().get_queryset().with_extended_related().annotate_is_null_publication() + qs = super().get_queryset().with_extended_related() if 'ordering' in self.request.query_params: self.request.GET._mutable = True if '-publication_datetime' in self.request.query_params['ordering']: self.request.query_params['ordering'] = self.request.query_params['ordering']\ - .replace('-publication_datetime', 'is_null_publication,-publication_date,-publication_time') + .replace('-publication_datetime', '-publication_date,-publication_time') elif 'publication_datetime' in self.request.query_params['ordering']: self.request.query_params['ordering'] = self.request.query_params['ordering']\ - .replace('publication_datetime', 'is_null_publication,publication_date,publication_time') + .replace('publication_datetime', 'publication_date,publication_time') self.request.GET._mutable = False if self.request.country_code: qs = qs.by_country_code(self.request.country_code)