Skip to content

Commit

Permalink
Likes off
Browse files Browse the repository at this point in the history
  • Loading branch information
axsapronov committed May 9, 2016
1 parent 0ebea48 commit 0b9eabd
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions digest/mixins.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,14 +44,14 @@ def get_context_data(self, **kwargs):
# Получить по ним сет из Item (без дублей)
# пройтись по всем и сформировать лист

date = datetime.datetime.now() - datetime.timedelta(days=12)
items = Item.objects.filter(
id__in=set(Vote.objects.filter(content_type=ContentType.objects.get(app_label="digest", model="item"),
).values_list('object_id', flat=True)),
related_to_date__gt=date)
items_score = [(item, item.vote_total) for item in items if item.vote_total > 0]
items_score = sorted(items_score, key=lambda item: item[1], reverse=True)
context['favorite_items'] = [x[0] for x in items_score[:10]]
# date = datetime.datetime.now() - datetime.timedelta(days=12)
# items = Item.objects.filter(
# id__in=set(Vote.objects.filter(content_type=ContentType.objects.get(app_label="digest", model="item"),
# ).values_list('object_id', flat=True)),
# related_to_date__gt=date)
# items_score = [(item, item.vote_total) for item in items if item.vote_total > 0]
# items_score = sorted(items_score, key=lambda item: item[1], reverse=True)
# context['favorite_items'] = [x[0] for x in items_score[:10]]
return context


Expand Down

0 comments on commit 0b9eabd

Please sign in to comment.