From 8041f376e0a32f3a18edf1cdb65a3c51f076e487 Mon Sep 17 00:00:00 2001 From: Slava Date: Tue, 15 Aug 2017 15:03:31 +0300 Subject: [PATCH] fix related expos --- apps/functions/model_mixin.py | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/apps/functions/model_mixin.py b/apps/functions/model_mixin.py index cc460469..a85dcbb9 100644 --- a/apps/functions/model_mixin.py +++ b/apps/functions/model_mixin.py @@ -5,6 +5,7 @@ from itertools import chain from pytils.dt import ru_strftime import datetime +from datetime import date from dateutil.relativedelta import relativedelta from django.conf import settings @@ -179,8 +180,18 @@ class EventMixin(object): themes = list(self.theme.all().values_list('pk', flat=True)) top_paid = list( model.objects.filter( - Q(top__isnull=False, theme__in=themes) | - Q(paid_new__isnull=False, theme__in=themes) + Q( + top__isnull=False, + theme__in=themes, + top__fr__lte=date.today(), + top__to__gte=date.today() + ) | + Q( + paid_new__isnull=False, + theme__in=themes, + top__fr__lte=date.today(), + top__to__gte=date.today() + ) ).filter( is_published=True ).order_by('?')