Completely remove news start field
This commit is contained in:
parent
6de33d82b0
commit
67597c4fd4
|
|
@ -72,4 +72,6 @@ class NewsListFilterSet(filters.FilterSet):
|
|||
return queryset
|
||||
|
||||
def sort_by_field(self, queryset, name, value):
|
||||
if value == self.SORT_BY_START_CHOICE:
|
||||
return queryset.order_by('-publication_date', '-publication_time')
|
||||
return queryset.order_by(f'-{value}')
|
||||
|
|
|
|||
17
apps/news/migrations/0047_remove_news_start.py
Normal file
17
apps/news/migrations/0047_remove_news_start.py
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
# Generated by Django 2.2.7 on 2019-12-18 16:20
|
||||
|
||||
from django.db import migrations
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('news', '0046_auto_20191218_1437'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.RemoveField(
|
||||
model_name='news',
|
||||
name='start',
|
||||
),
|
||||
]
|
||||
|
|
@ -65,7 +65,7 @@ class NewsQuerySet(TranslationQuerysetMixin):
|
|||
|
||||
def sort_by_start(self):
|
||||
"""Return qs sorted by start DESC"""
|
||||
return self.order_by('-start')
|
||||
return self.order_by('-publication_date', '-publication_time')
|
||||
|
||||
def rating_value(self):
|
||||
return self.annotate(rating=models.Count('ratings__ip', distinct=True))
|
||||
|
|
@ -119,7 +119,7 @@ class NewsQuerySet(TranslationQuerysetMixin):
|
|||
return self.model.objects.exclude(pk=news.pk).published(). \
|
||||
annotate_in_favorites(user). \
|
||||
with_base_related().by_type(news.news_type). \
|
||||
by_tags(news.tags.all()).distinct().order_by('-start')
|
||||
by_tags(news.tags.all()).distinct().sort_by_start()
|
||||
|
||||
def annotate_in_favorites(self, user):
|
||||
"""Annotate flag in_favorites"""
|
||||
|
|
@ -190,8 +190,6 @@ class News(GalleryModelMixin, BaseAttributes, TranslatedFieldsMixin, HasTagsMixi
|
|||
locale_to_description_is_active = HStoreField(null=True, default=dict, blank=True,
|
||||
verbose_name=_('Is description for certain locale active'),
|
||||
help_text='{"en-GB": true, "fr-FR": false}')
|
||||
start = models.DateTimeField(blank=True, null=True, default=None,
|
||||
verbose_name=_('Start'))
|
||||
publication_date = models.DateField(blank=True, null=True, verbose_name=_('News publication date'),
|
||||
help_text=_('date since when news item is published'))
|
||||
publication_time = models.TimeField(blank=True, null=True, verbose_name=_('News publication time'),
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@ class NewsMixinView:
|
|||
qs = models.News.objects.published() \
|
||||
.with_base_related() \
|
||||
.annotate_in_favorites(self.request.user) \
|
||||
.order_by('-is_highlighted', '-start')
|
||||
.order_by('-is_highlighted', '-publication_date', '-publication_time')
|
||||
|
||||
country_code = self.request.country_code
|
||||
if country_code:
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user