Completely remove news start field
This commit is contained in:
parent
6de33d82b0
commit
67597c4fd4
|
|
@ -72,4 +72,6 @@ class NewsListFilterSet(filters.FilterSet):
|
||||||
return queryset
|
return queryset
|
||||||
|
|
||||||
def sort_by_field(self, queryset, name, value):
|
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}')
|
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):
|
def sort_by_start(self):
|
||||||
"""Return qs sorted by start DESC"""
|
"""Return qs sorted by start DESC"""
|
||||||
return self.order_by('-start')
|
return self.order_by('-publication_date', '-publication_time')
|
||||||
|
|
||||||
def rating_value(self):
|
def rating_value(self):
|
||||||
return self.annotate(rating=models.Count('ratings__ip', distinct=True))
|
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(). \
|
return self.model.objects.exclude(pk=news.pk).published(). \
|
||||||
annotate_in_favorites(user). \
|
annotate_in_favorites(user). \
|
||||||
with_base_related().by_type(news.news_type). \
|
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):
|
def annotate_in_favorites(self, user):
|
||||||
"""Annotate flag in_favorites"""
|
"""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,
|
locale_to_description_is_active = HStoreField(null=True, default=dict, blank=True,
|
||||||
verbose_name=_('Is description for certain locale active'),
|
verbose_name=_('Is description for certain locale active'),
|
||||||
help_text='{"en-GB": true, "fr-FR": false}')
|
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'),
|
publication_date = models.DateField(blank=True, null=True, verbose_name=_('News publication date'),
|
||||||
help_text=_('date since when news item is published'))
|
help_text=_('date since when news item is published'))
|
||||||
publication_time = models.TimeField(blank=True, null=True, verbose_name=_('News publication time'),
|
publication_time = models.TimeField(blank=True, null=True, verbose_name=_('News publication time'),
|
||||||
|
|
|
||||||
|
|
@ -22,7 +22,7 @@ class NewsMixinView:
|
||||||
qs = models.News.objects.published() \
|
qs = models.News.objects.published() \
|
||||||
.with_base_related() \
|
.with_base_related() \
|
||||||
.annotate_in_favorites(self.request.user) \
|
.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
|
country_code = self.request.country_code
|
||||||
if country_code:
|
if country_code:
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user