diff --git a/project/customer/context_processors.py b/project/customer/context_processors.py index 508617b..fb73d6c 100644 --- a/project/customer/context_processors.py +++ b/project/customer/context_processors.py @@ -26,20 +26,18 @@ def license_check_soon_ends(request): now_ = datetime.today() if not days_left or not cur_license: - cur_license = License.objects.filter( + current_licenses = License.objects.filter( company=request.user.profile, date_from__lte=now_, date_to__gte=now_, status__in=[consts.LICENSE_TEST_PERIOD, consts.LICENSE_PAID, consts.LICENSE_ACTIVE], deleted=False ) - if cur_license: - cur_license = cur_license[0] - - days_left = (cur_license.date_to - now_.date()).days - - cache.set('days_left_%s' % (request.user.username,), days_left, cache_duration) - cache.set('cur_license_%s' % (request.user.username,), cur_license, cache_duration) + if current_licenses: + cur_license = current_licenses[0] + days_left = (cur_license.date_to - now_.date()).days + cache.set('days_left_%s' % (request.user.username,), days_left, cache_duration) + cache.set('cur_license_%s' % (request.user.username,), cur_license, cache_duration) if not license_cookie: if license_15days is None: