fix names of methods and fields of serializer

This commit is contained in:
michail 2019-10-01 17:42:14 +05:00
parent 055e99dba2
commit a497230883
2 changed files with 7 additions and 6 deletions

View File

@ -121,7 +121,8 @@ class News(BaseAttributes, TranslatedFieldsMixin):
return news_list
@property
def on_the_same_theme_news(self):
def same_theme(self):
# on the same theme news
# without "distinct" method the doubles are arising
like_news = News.objects.published().filter(news_type=self.news_type, tags__in=models.F("tags"))\
@ -137,7 +138,8 @@ class News(BaseAttributes, TranslatedFieldsMixin):
return news_list
@property
def you_should_read_news(self):
def should_read(self):
# you should read news
# without "distinct" method the doubles are arising
like_news = News.objects.published().filter(news_type=self.news_type).exclude(id=self.id).distinct()
@ -151,4 +153,4 @@ class News(BaseAttributes, TranslatedFieldsMixin):
news_list = [{"id": like_news[r].id, "slug": like_news[r].slug} for r in random_ids]
return news_list
return news_list

View File

@ -64,9 +64,8 @@ class NewsDetailSerializer(NewsBaseSerializer):
'is_publish',
'author',
'country',
# 'list_also_like_news',
'on_the_same_theme_news',
'you_should_read_news',
'same_theme',
'should_read',
)