actions for doc on preview page, some mails

remotes/origin/yandex
Bachurin Sergey 12 years ago
parent 3d2ba87a0f
commit 95dac8b593
  1. 3
      project/customer/models.py
  2. 27
      project/customer/tasks.py
  3. 49
      project/customer/utils.py
  4. 2
      project/docs/views/base_views.py
  5. 3
      project/static/css/style.css
  6. 55
      project/templates/docs/_base/base_list.html
  7. 9
      project/templates/docs/_base/preview.html
  8. 55
      project/templates/docs/parts/doc_actions.html
  9. 7
      project/templates/myauth/license_ended.txt

@ -11,7 +11,7 @@ from django.db.models import Max
from django.contrib.auth.models import User
from django.core.urlresolvers import reverse
from . import consts, managers
from . import consts, managers, utils
PROFILE_IMAGES_UPLOAD_DIR = 'customer/profile/' # куда сохранять загруженные изображения
@ -383,6 +383,7 @@ class License(models.Model):
self.user.profile.active = True
self.user.profile.save()
self.status = 1
utils.check_one_profile(self.user.profile, License, datetime.now())
super(License, self).save(*args, **kwargs)

@ -3,11 +3,10 @@ from __future__ import absolute_import
from datetime import datetime, timedelta
from django.conf import settings
from django.template.loader import render_to_string
from django.core.mail import EmailMessage
from celery import shared_task
from .models import License, UserProfile
from .utils import check_one_profile
SUPPORT_EMAIL = getattr(settings, 'SUPPORT_EMAIL', '')
@ -25,29 +24,7 @@ def check_license():
licenses.update(status=4)
for profile in profiles:
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=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)
return email.send()
check_one_profile(profile, License, now)
return None

@ -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()

@ -379,6 +379,7 @@ class BaseViews(object):
def as_img(self, *args, **kwargs):
"""Вывести превью документа."""
try:
obj = self.get_obj(kwargs['id'])
pdf = self.get_pdf(*args, **kwargs)
_, filename = tempfile.mkstemp()
@ -407,6 +408,7 @@ class BaseViews(object):
imgs = ['%stmp/%s/%s' % (MEDIA_URL, tmp_dirname, i) for i in imgs]
dictionary = {
'obj': obj,
'images': imgs,
'padeji': self.PADEJI,
'padeji_mnoj': self.PADEJI_MNOJ,

@ -214,4 +214,5 @@ div.blockMsg { width: 100%; height: 100%; top: 0; left: 0; text-align: center; }
.header {font-weight:bold; }
#menu ul li {display:inline;}
.preview {width:1000px;height:500px;overflow:scroll;}
.preview {width:780px;height:500px;overflow:scroll;float:left;}
.list-col2 {float: left; width: 180px; margin-left: 16px; padding: 0 10px 10px 10px; border-left: solid 1px #797979;}

@ -78,61 +78,10 @@
<img src="{{ STATIC_URL }}img/left-arrow.gif" />
</div>
<div class="list-col2" style="float: left; width: 180px; margin-left: 16px; padding: 0 10px 10px 10px; border-left: solid 1px #797979;">
<div class="list-col2">
{% for obj in page.object_list %}
{% 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="display: none;">
<div style="font-size: 15px;">Скачать</div>
<hr />
<a class="doc pdf-link" href="{{ url_img }}">
<img src="{{ STATIC_URL }}img/icon-pdf.gif" title="IMG" alt="Предпросмотр документа" />Предпросмотр {{ padeji.rodit }}</a><br />
<br />
<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>
{% include "docs/parts/doc_actions.html" %}
{% endfor %}
<div class="filters">
Фильтр списка
<hr />

@ -1,7 +1,9 @@
{% extends "base.html" %}
<div class="clear"></div>
{% block title %}Просмотр {{ padeji.rodit }}{% endblock %}
<div class="clear"></div>
{% block content %}
{% url url_prefix|add:'list' as url_list %}
{% url url_prefix|add:'delete' id=obj.pk as url_delete %}
@ -10,13 +12,16 @@
<a class="back" href="{{ url_list }}">Вернуться к списку</a>
</span>
<h2 style="display:inline">Просмотр {{ padeji.rodit }}</h2>
<h2>Просмотр {{ padeji.rodit }}</h2>
<div class="preview">
{% for img in images %}
<img src='{{ img }}' alt='Страница {{ forloop.conter }}' />
<img src='{{ img }}' alt='Страница {{ forloop.counter }}' title='Страница {{ forloop.counter }}' />
{% endfor %}
</div>
<div class="list-col2">
{% include "docs/parts/doc_actions.html" %}
</div>
<div class="clear"></div>
{% endblock %}

@ -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…
Cancel
Save