license: replaced user with company [fix]

remotes/origin/mitri4
apache 9 years ago
parent 36bd398267
commit 060c1f6c46
  1. 25
      project/customer/utils.py

@ -23,13 +23,13 @@ def check_one_profile(profile, License, now, manual=False):
if profile.active and not profile_is_active: if profile.active and not profile_is_active:
template_name = 'myauth/license_activated.txt' template_name = 'myauth/license_activated.txt'
subject = u'Документор: Профиль активирован' subject = u'Документор: Профиль активирован'
dict_context = {'user_email': licenses[0].user, dict_context = {'user_email': licenses[0].company,
'support_email': SUPPORT_EMAIL, 'support_email': SUPPORT_EMAIL,
'license_starts': licenses[0].date_from, 'license_starts': licenses[0].date_from,
'license_ends': licenses[0].date_to, 'license_ends': licenses[0].date_to,
} }
email_body = render_to_string(template_name, dict_context) email_body = render_to_string(template_name, dict_context)
email = EmailMessage(subject=subject, to=(licenses[0].user.email,), body=email_body) email = EmailMessage(subject=subject, to=(licenses[0].company.email,), body=email_body)
email.send() email.send()
licenses_remain = License.objects.filter(company=profile, date_from__gt=now + timedelta(1), status=1, deleted=False) licenses_remain = License.objects.filter(company=profile, date_from__gt=now + timedelta(1), status=1, deleted=False)
@ -42,13 +42,13 @@ def check_one_profile(profile, License, now, manual=False):
if licenses: if licenses:
template_name = 'myauth/license_ended.txt' template_name = 'myauth/license_ended.txt'
subject = u'Документор: срок действия лицензии окончен' subject = u'Документор: срок действия лицензии окончен'
dict_context = {'user_email': licenses[0].user, dict_context = {'user_email': licenses[0].company,
'support_email': SUPPORT_EMAIL, 'support_email': SUPPORT_EMAIL,
'license_ends': licenses[0].date_to, 'license_ends': licenses[0].date_to,
'licenses_to_pay': licenses_to_pay, 'licenses_to_pay': licenses_to_pay,
} }
email_body = render_to_string(template_name, dict_context) email_body = render_to_string(template_name, dict_context)
email = EmailMessage(subject=subject, to=(licenses[0].user.email,), body=email_body) email = EmailMessage(subject=subject, to=(licenses[0].company.email,), body=email_body)
email.send() 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=[-1, 2], deleted=False)
@ -56,27 +56,26 @@ def check_one_profile(profile, License, now, manual=False):
if licenses: if licenses:
template_name = 'myauth/license_ends.txt' template_name = 'myauth/license_ends.txt'
subject = u'Документор: окончание срока действия лицензии' subject = u'Документор: окончание срока действия лицензии'
dict_context = {'user_email': licenses[0].user, dict_context = {'user_email': licenses[0].company,
'support_email': SUPPORT_EMAIL, 'support_email': SUPPORT_EMAIL,
'license_ends': licenses[0].date_to, 'license_ends': licenses[0].date_to,
'licenses_to_pay': licenses_to_pay, 'licenses_to_pay': licenses_to_pay,
} }
email_body = render_to_string(template_name, dict_context) email_body = render_to_string(template_name, dict_context)
email = EmailMessage(subject=subject, to=(licenses[0].user.email,), body=email_body) email = EmailMessage(subject=subject, to=(licenses[0].company.email,), body=email_body)
email.send() email.send()
if not manual:
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(9), status=0, deleted=False)
if licenses: if licenses:
template_name = 'myauth/license_to_pay.txt' template_name = 'myauth/license_to_pay.txt'
subject = u'Документор: есть неоплаченные счета' subject = u'Документор: есть неоплаченные счета'
dict_context = {'user_email': licenses[0].user, dict_context = {'user_email': licenses[0].company,
'support_email': SUPPORT_EMAIL, 'support_email': SUPPORT_EMAIL,
} }
email_body = render_to_string(template_name, dict_context) email_body = render_to_string(template_name, dict_context)
email = EmailMessage(subject=subject, to=(licenses[0].user.email,), body=email_body) email = EmailMessage(subject=subject, to=(licenses[0].company.email,), body=email_body)
email.send() email.send()

Loading…
Cancel
Save