|
|
|
|
@ -40,47 +40,48 @@ 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(days=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=[consts.LICENSE_TEST_PERIOD, consts.LICENSE_ACTIVE], deleted=False) |
|
|
|
|
|
|
|
|
|
licenses.update(status=consts.LICENSE_EXPIRED) |
|
|
|
|
|
|
|
|
|
if licenses: |
|
|
|
|
template_name = 'myauth/license_ended.txt' |
|
|
|
|
subject = u'Документор: срок действия лицензии окончен' |
|
|
|
|
dict_context = { |
|
|
|
|
'user_email': user_email, |
|
|
|
|
'support_email': SUPPORT_EMAIL, |
|
|
|
|
'license_ends': licenses[0].date_to, |
|
|
|
|
'licenses_to_pay': licenses_to_pay, |
|
|
|
|
} |
|
|
|
|
email_body = render_to_string(template_name, dict_context) |
|
|
|
|
email = EmailMessage(subject=subject, to=(user_email,), body=email_body) |
|
|
|
|
email.send() |
|
|
|
|
|
|
|
|
|
licenses = License.objects.filter(company=profile, date_to = now_ + timedelta(days=1), |
|
|
|
|
status__in=[consts.LICENSE_TEST_PERIOD, consts.LICENSE_ACTIVE], deleted=False) |
|
|
|
|
|
|
|
|
|
if licenses: |
|
|
|
|
template_name = 'myauth/license_ends.txt' |
|
|
|
|
subject = u'Документор: окончание срока действия лицензии' |
|
|
|
|
dict_context = { |
|
|
|
|
'user_email': user_email, |
|
|
|
|
'support_email': SUPPORT_EMAIL, |
|
|
|
|
'license_ends': licenses[0].date_to, |
|
|
|
|
'licenses_to_pay': licenses_to_pay, |
|
|
|
|
} |
|
|
|
|
email_body = render_to_string(template_name, dict_context) |
|
|
|
|
email = EmailMessage(subject=subject, to=(user_email,), body=email_body) |
|
|
|
|
email.send() |
|
|
|
|
|
|
|
|
|
# флаг manual=False, если вызов из License.save() |
|
|
|
|
if not manual: |
|
|
|
|
licenses_remain = License.objects.filter(company=profile, date_from__gt = now_ + timedelta(days=1), |
|
|
|
|
status=consts.LICENSE_PAID, deleted=False) |
|
|
|
|
|
|
|
|
|
if not licenses_remain: |
|
|
|
|
licenses_to_pay = License.objects.filter(company=profile, status=consts.LICENSE_UNPAID, deleted=False) |
|
|
|
|
|
|
|
|
|
licenses = License.objects.filter(company=profile, date_to__lt=now_, |
|
|
|
|
status__in=[consts.LICENSE_TEST_PERIOD, consts.LICENSE_ACTIVE], deleted=False) |
|
|
|
|
|
|
|
|
|
licenses.update(status=consts.LICENSE_EXPIRED) |
|
|
|
|
|
|
|
|
|
if licenses: |
|
|
|
|
template_name = 'myauth/license_ended.txt' |
|
|
|
|
subject = u'Документор: срок действия лицензии окончен' |
|
|
|
|
dict_context = { |
|
|
|
|
'user_email': user_email, |
|
|
|
|
'support_email': SUPPORT_EMAIL, |
|
|
|
|
'license_ends': licenses[0].date_to, |
|
|
|
|
'licenses_to_pay': licenses_to_pay, |
|
|
|
|
} |
|
|
|
|
email_body = render_to_string(template_name, dict_context) |
|
|
|
|
email = EmailMessage(subject=subject, to=(user_email,), body=email_body) |
|
|
|
|
email.send() |
|
|
|
|
|
|
|
|
|
licenses = License.objects.filter(company=profile, date_to = now_ + timedelta(days=1), |
|
|
|
|
status__in=[consts.LICENSE_TEST_PERIOD, consts.LICENSE_ACTIVE], deleted=False) |
|
|
|
|
|
|
|
|
|
if licenses: |
|
|
|
|
template_name = 'myauth/license_ends.txt' |
|
|
|
|
subject = u'Документор: окончание срока действия лицензии' |
|
|
|
|
dict_context = { |
|
|
|
|
'user_email': user_email, |
|
|
|
|
'support_email': SUPPORT_EMAIL, |
|
|
|
|
'license_ends': licenses[0].date_to, |
|
|
|
|
'licenses_to_pay': licenses_to_pay, |
|
|
|
|
} |
|
|
|
|
email_body = render_to_string(template_name, dict_context) |
|
|
|
|
email = EmailMessage(subject=subject, to=(user_email,), body=email_body) |
|
|
|
|
email.send() |
|
|
|
|
|
|
|
|
|
licenses = License.objects.filter(company=profile, order_date = now_ - timedelta(days = consts.LICENSE_PAY_DAYS - 1), |
|
|
|
|
status=consts.LICENSE_UNPAID, deleted=False) |
|
|
|
|
|
|
|
|
|
|