From fd934dd06327daa236f26f39dbc1b6d917359c8e Mon Sep 17 00:00:00 2001 From: Bachurin Sergey Date: Mon, 18 Aug 2014 16:22:03 +0300 Subject: [PATCH] 15 days fix --- project/customer/context_processors.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/project/customer/context_processors.py b/project/customer/context_processors.py index b870091..a61555e 100644 --- a/project/customer/context_processors.py +++ b/project/customer/context_processors.py @@ -9,17 +9,16 @@ def license_check_soon_ends(request): now = datetime.today() license_15days = cache.get('license_15_%s' % (request.user.username,), None) if license_15days is None: - licenses_ends = License.objects.filter(company=request.user.profile, date_to__gte=now - timedelta(15), status__in=[-1, 1, 2], deleted=False) - next_licenses = License.objects.filter(company=request.user.profile, date_from__gte=now - timedelta(15), status=1, deleted=False) + licenses_ends = License.objects.filter(company=request.user.profile, date_to__lte=now + timedelta(15), status__in=[-1, 1, 2], deleted=False) + next_licenses = License.objects.filter(company=request.user.profile, status=1, deleted=False) if licenses_ends and not next_licenses: days_to_end = licenses_ends[0].date_to - cache.set('license_15_%s' % (request.user.username,), days_to_end) + cache.set('license_15_%s' % (request.user.username,), days_to_end, 3600) license_15days = days_to_end else: license_15days = '' return { - #'license_15days': license_15days == 'Y' 'license_15days': license_15days } except: