license: fixed error when no current licenses

remotes/origin/license
Andrey 9 years ago
parent b60f3c4d14
commit 19c8029f65
  1. 14
      project/customer/context_processors.py

@ -26,20 +26,18 @@ def license_check_soon_ends(request):
now_ = datetime.today() now_ = datetime.today()
if not days_left or not cur_license: if not days_left or not cur_license:
cur_license = License.objects.filter( current_licenses = License.objects.filter(
company=request.user.profile, company=request.user.profile,
date_from__lte=now_, date_from__lte=now_,
date_to__gte=now_, date_to__gte=now_,
status__in=[consts.LICENSE_TEST_PERIOD, consts.LICENSE_PAID, consts.LICENSE_ACTIVE], status__in=[consts.LICENSE_TEST_PERIOD, consts.LICENSE_PAID, consts.LICENSE_ACTIVE],
deleted=False deleted=False
) )
if cur_license: if current_licenses:
cur_license = cur_license[0] cur_license = current_licenses[0]
days_left = (cur_license.date_to - now_.date()).days
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)
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 not license_cookie:
if license_15days is None: if license_15days is None:

Loading…
Cancel
Save