|
|
|
|
@ -15,8 +15,9 @@ SUPPORT_EMAIL = getattr(settings, 'SUPPORT_EMAIL') |
|
|
|
|
def check_one_profile(profile, License, now_, manual=False): |
|
|
|
|
profile_was_active = profile.active |
|
|
|
|
|
|
|
|
|
# действующие лицензии для установки/сброса признака активности профиля |
|
|
|
|
licenses = (License.objects.filter(company=profile, date_from__lte=now_, date_to__gte=now_, deleted=False) |
|
|
|
|
.filter(Q(status__in = [consts.LICENSE_TEST_PERIOD, consts.LICENSE_ACTIVE]) | Q(order_status=consts.ORDER_PAID)) |
|
|
|
|
.filter(Q(status__in=[consts.LICENSE_INACTIVE, consts.LICENSE_ACTIVE]) | Q(order_status=consts.ORDER_PAID)) |
|
|
|
|
) |
|
|
|
|
|
|
|
|
|
licenses.filter(order_status=consts.ORDER_PAID).update(status=consts.LICENSE_ACTIVE) |
|
|
|
|
@ -48,10 +49,12 @@ def check_one_profile(profile, License, now_, manual=False): |
|
|
|
|
order_status=consts.ORDER_PAID, deleted=False) |
|
|
|
|
|
|
|
|
|
if not licenses_remain: |
|
|
|
|
# ожидающие оплаты лицензии (без учёта даты заказа) |
|
|
|
|
licenses_to_pay = License.objects.filter(company=profile, order_status=consts.ORDER_UNPAID, deleted=False) |
|
|
|
|
|
|
|
|
|
# истёкшие лицензии |
|
|
|
|
licenses = License.objects.filter(company=profile, date_to__lt=now_, |
|
|
|
|
status__in=[consts.LICENSE_TEST_PERIOD, consts.LICENSE_ACTIVE], deleted=False) |
|
|
|
|
status__in=[consts.LICENSE_INACTIVE, consts.LICENSE_ACTIVE], deleted=False) |
|
|
|
|
|
|
|
|
|
licenses.update(status=consts.LICENSE_EXPIRED) |
|
|
|
|
|
|
|
|
|
@ -68,8 +71,9 @@ 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(days=1), |
|
|
|
|
status__in=[consts.LICENSE_TEST_PERIOD, consts.LICENSE_ACTIVE], deleted=False) |
|
|
|
|
status__in=[consts.LICENSE_INACTIVE, consts.LICENSE_ACTIVE], deleted=False) |
|
|
|
|
|
|
|
|
|
if licenses: |
|
|
|
|
template_name = 'myauth/license_ends.txt' |
|
|
|
|
@ -84,6 +88,7 @@ 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, order_date = now_ - timedelta(days = consts.ORDER_PAY_DAYS - 1), |
|
|
|
|
order_status=consts.ORDER_UNPAID, deleted=False) |
|
|
|
|
|
|
|
|
|
|