|
|
|
|
@ -5,14 +5,17 @@ from django.conf import settings |
|
|
|
|
from django.core.mail import EmailMessage |
|
|
|
|
from django.template.loader import render_to_string |
|
|
|
|
|
|
|
|
|
from project.customer import consts |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
SUPPORT_EMAIL = getattr(settings, 'SUPPORT_EMAIL') |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def check_one_profile(profile, License, now, manual=False): |
|
|
|
|
profile_is_active = profile.active |
|
|
|
|
licenses = License.objects.filter(company=profile, date_from__lte=now, date_to__gte=now, status__in=[-1, 1, 2], deleted=False) |
|
|
|
|
licenses.filter(status=1).update(status=2) |
|
|
|
|
licenses = License.objects.filter(company=profile, date_from__lte=now, date_to__gte=now, |
|
|
|
|
status__in=[consts.LICENSE_TEST_PERIOD, consts.LICENSE_PAID, consts.LICENSE_ACTIVE], deleted=False) |
|
|
|
|
licenses.filter(status=consts.LICENSE_PAID).update(status=consts.LICENSE_ACTIVE) |
|
|
|
|
|
|
|
|
|
if licenses: |
|
|
|
|
profile.active = True |
|
|
|
|
@ -34,12 +37,14 @@ def check_one_profile(profile, License, now, manual=False): |
|
|
|
|
email = EmailMessage(subject=subject, to=(user_email,), body=email_body) |
|
|
|
|
email.send() |
|
|
|
|
|
|
|
|
|
licenses_remain = License.objects.filter(company=profile, date_from__gt=now + timedelta(1), status=1, deleted=False) |
|
|
|
|
licenses_to_pay = License.objects.filter(company=profile, status=0, deleted=False) |
|
|
|
|
licenses_remain = License.objects.filter(company=profile, date_from__gt=now + timedelta(1), |
|
|
|
|
status=consts.LICENSE_PAID, deleted=False) |
|
|
|
|
licenses_to_pay = License.objects.filter(company=profile, status=consts.LICENSE_UNPAID, deleted=False) |
|
|
|
|
|
|
|
|
|
if not licenses_remain and not manual: |
|
|
|
|
licenses = License.objects.filter(company=profile, date_to__lt=now, status__in=[-1, 2], deleted=False) |
|
|
|
|
licenses.update(status=3) |
|
|
|
|
licenses = License.objects.filter(company=profile, date_to__lt=now, |
|
|
|
|
status__in=[consts.LICENSE_TEST_PERIOD, consts.LICENSE_ACTIVE], deleted=False) |
|
|
|
|
licenses.update(status=status=consts.LICENSE_EXPIRED) |
|
|
|
|
|
|
|
|
|
if licenses: |
|
|
|
|
template_name = 'myauth/license_ended.txt' |
|
|
|
|
@ -53,7 +58,8 @@ def check_one_profile(profile, License, now, manual=False): |
|
|
|
|
email = EmailMessage(subject=subject, to=(user_email,), body=email_body) |
|
|
|
|
email.send() |
|
|
|
|
|
|
|
|
|
licenses = License.objects.filter(company=profile, date_to=now + timedelta(1), status__in=[-1, 2], deleted=False) |
|
|
|
|
licenses = License.objects.filter(company=profile, date_to=now + timedelta(1), |
|
|
|
|
status__in=[consts.LICENSE_TEST_PERIOD, consts.LICENSE_ACTIVE], deleted=False) |
|
|
|
|
|
|
|
|
|
if licenses: |
|
|
|
|
template_name = 'myauth/license_ends.txt' |
|
|
|
|
@ -68,7 +74,8 @@ def check_one_profile(profile, License, now, manual=False): |
|
|
|
|
email.send() |
|
|
|
|
|
|
|
|
|
if not manual: |
|
|
|
|
licenses = License.objects.filter(company=profile, order_date=now - timedelta(9), status=0, deleted=False) |
|
|
|
|
licenses = License.objects.filter(company=profile, order_date=now - timedelta(consts.LICENSE_PAY_DAYS-1), |
|
|
|
|
status=status=consts.LICENSE_UNPAID, deleted=False) |
|
|
|
|
|
|
|
|
|
if licenses: |
|
|
|
|
template_name = 'myauth/license_to_pay.txt' |
|
|
|
|
|