parent
3d2ba87a0f
commit
95dac8b593
9 changed files with 128 additions and 82 deletions
@ -0,0 +1,49 @@ |
||||
# -*- coding: utf-8 -*- |
||||
from datetime import timedelta |
||||
from django.core.mail import EmailMessage |
||||
from django.template.loader import render_to_string |
||||
|
||||
|
||||
def check_one_profile(profile, License, now): |
||||
profile_is_active = profile.active |
||||
licenses = License.objects.filter(user=profile.user, date_from__lte=now, date_to__gte=now, status__in=[-1, 1, 2], deleted=False) |
||||
if licenses: |
||||
profile.active = True |
||||
else: |
||||
profile.active = False |
||||
profile.save() |
||||
licenses.filter(status=1).update(status=2) |
||||
|
||||
licenses = License.objects.filter(user=profile.user, date_to__lt=now, status=2, deleted=False) |
||||
licenses.update(status=3) |
||||
licenses_to_pay = License.objects.filter(user=profile.user, status=0, deleted=False) |
||||
|
||||
if licenses: |
||||
template_name = 'myauth/license_ended.txt' |
||||
subject = u'Документор: срок действия лицензии окончен' |
||||
dict_context = {'user_email': licenses[0].user, |
||||
'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=(licenses[0].user.email,), body=email_body) |
||||
email.send() |
||||
|
||||
licenses = License.objects.filter(user=profile.user, date_to=now + timedelta(1), status__in=[-1, 2], deleted=False) |
||||
licenses_remain = License.objects.filter(user=profile.user, date_from__gt=now + timedelta(1), status=1, deleted=False) |
||||
licenses_to_pay = License.objects.filter(user=profile.user, status=0, deleted=False) |
||||
|
||||
if licenses and not licenses_remain: |
||||
template_name = 'myauth/license_ends.txt' |
||||
subject = u'Документор: окончание срока действия лицензии' |
||||
dict_context = {'user_email': licenses[0].user, |
||||
'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=(licenses[0].user.email,), body=email_body) |
||||
email.send() |
||||
|
||||
|
||||
@ -0,0 +1,55 @@ |
||||
|
||||
{% url url_prefix|add:'edit' id=obj.pk as url_edit %} |
||||
{% url url_prefix|add:'copy' id=obj.pk as url_copy %} |
||||
{% url url_prefix|add:'delete' id=obj.pk as url_delete %} |
||||
{% url url_prefix|add:'email' id=obj.pk as url_email %} |
||||
{% url url_prefix|add:'img' id=obj.pk as url_img %} |
||||
{% url url_prefix|add:'pdf' id=obj.pk as url_pdf %} |
||||
{% url url_prefix|add:'xls' id=obj.pk as url_xls %} |
||||
|
||||
{% url 'docs_aktrabot_add_by_invoice' invoice_id=obj.pk as url_aktrabot_by_invoice %} |
||||
{% url 'docs_nakladn_add_by_invoice' invoice_id=obj.pk as url_nakladn_by_invoice %} |
||||
{% url 'docs_faktura_add_by_invoice' invoice_id=obj.pk as url_faktura_by_invoice %} |
||||
|
||||
<div id="doc_panel_{{ obj.pk }}" class="doc-panel" style=""> |
||||
<div style="font-size: 15px;">Скачать</div> |
||||
|
||||
<hr /> |
||||
|
||||
{% if not images %} |
||||
<a class="doc pdf-link" href="{{ url_img }}"> |
||||
<img src="{{ STATIC_URL }}img/icon-pdf.gif" title="IMG" alt="Предпросмотр документа" />Предпросмотр {{ padeji.rodit }}</a><br /> |
||||
<br /> |
||||
{% endif %} |
||||
<a class="doc pdf-link" href="{{ url_pdf }}"> |
||||
<img src="{{ STATIC_URL }}img/icon-pdf.gif" title="PDF" alt="Документ в PDF" />Документ в PDF</a><br /> |
||||
<br /> |
||||
<a class="doc excel-link" href="{{ url_xls }}"> |
||||
<img src="{{ STATIC_URL }}img/icon-excel.gif" title="Excel" alt="Документ в Excel" />Документ в Excel</a><br /> |
||||
|
||||
<br /> |
||||
<div style="font-size: 15px;">Создать</div> |
||||
|
||||
<hr /> |
||||
|
||||
{% block panel_copy %} |
||||
<a class="doc" href="{{ url_copy }}" title="Копию {{ padeji.rodit }}">Копию {{ padeji.rodit }}</a><br /> |
||||
<br /> |
||||
|
||||
{% block panel_copy_extra %}{% endblock %} |
||||
{% endblock %} |
||||
|
||||
<hr /> |
||||
|
||||
<a class="doc email-link" href="{{ url_email }}"> |
||||
<img src="{{ STATIC_URL }}img/icon-email.gif" title="Отправить" alt="Отправить" />Отправить</a><br /> |
||||
|
||||
<br /> |
||||
<a class="doc edit-link" href="{{ url_edit }}"> |
||||
<img src="{{ STATIC_URL }}img/icon-edit.gif" title="Редактировать" alt="Редактировать" />Редактировать</a><br /> |
||||
|
||||
<br /> |
||||
<a class="doc delete-link" href="{{ url_delete }}"> |
||||
<img src="{{ STATIC_URL }}img/icon-delete.gif" title="Удалить" alt="Удалить" />Удалить</a><br /> |
||||
</div> |
||||
|
||||
@ -0,0 +1,7 @@ |
||||
Здравствуйте! |
||||
|
||||
Закончилось действие вашего аккаунта на сайте Документор (http://www.dokumentor.ru). Вы не сможете создавать новые документы. {% if licenses_to_pay %}У Вас есть неоплаченные счета, которые можно оплатить, чтобы продлить действие услуги.{% else %}Чтобы продлить действие услуги, войдите в свой профиль и приобретите лицензию на дальнейшее пользование сайтом.{% endif %} |
||||
|
||||
Это письмо написано роботом. Отвечать на него не нужно. |
||||
|
||||
Связаться со службой поддержки сайта Документор Вы можете по адресу {{ support_email }} |
||||
Loading…
Reference in new issue