added task for reminder to pay, fix license lists, some cms addings

remotes/origin/yandex
Bachurin Sergey 12 years ago
parent 1b321f9806
commit e30fe7e359
  1. 34
      project/customer/tasks.py
  2. 2
      project/customer/views/license.py
  3. 2
      project/static/css/style.css
  4. 10
      project/templates/base.html
  5. 10
      project/templates/cms/menu/main.html
  6. 8
      project/templates/customer/profile/paid_list.html
  7. 7
      project/templates/myauth/license_ends.txt

@ -2,17 +2,30 @@
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
SUPPORT_EMAIL = getattr(settings, 'SUPPORT_EMAIL', '')
@shared_task
def check_license():
profiles = UserProfile.objects.all()
now = datetime.now()
licenses = License.objects.filter(date_to__lt=now, status__in=[-1, 2], deleted=False)
licenses.update(status=3)
licenses = License.objects.filter(order_date__lt=now - timedelta(10), status=0, deleted=False)
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])
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:
@ -20,10 +33,21 @@ def check_license():
profile.save()
licenses.filter(status=1).update(status=2)
licenses = License.objects.filter(user=profile.user, date_to__lt=now, status__in=[-1, 2])
licenses.update(status=3)
licenses = License.objects.filter(user=profile.user, order_date__lt=now - timedelta(10), status=0)
licenses.update(status=4)
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()
return None

@ -70,7 +70,7 @@ def paid_list(request):
"""
template_name = 'customer/profile/paid_list.html'
licenses = License.objects.filter(user=request.user,
status__in=[-1, 1, 2, 3], deleted=False).order_by('-id')
status__in=[-1, 1, 2, 3, 4], deleted=False).order_by('-id')
dictionary = {
'licenses': licenses,
}

@ -212,3 +212,5 @@ div.blockMsg { width: 100%; height: 100%; top: 0; left: 0; text-align: center; }
.w100 {width:100px;min-height:5px;}
.w200 {width:200px;min-height:5px;}
.header {font-weight:bold; }
#menu ul li {display:inline;}

@ -1,5 +1,5 @@
{# spaceless #}<!DOCTYPE html>
{% load cms_tags sekizai_tags %}
{% load cms_tags sekizai_tags menu_tags %}
<html>
<head>
<meta charset='utf-8'>
@ -25,7 +25,13 @@
<div style="margin: 10px 0; height: 30px;">
<div style="float: left; font-weight: bold; font-size: 22px;">
<a href="/">Документор</a>
<span>{% static_placeholder "phone" %}</span>
<span>{% static_placeholder "header_phone" %}</span>
<span>{% static_placeholder "header_address" %}</span>
</div>
<div id="menu">
<ul>
{% show_menu 0 100 100 100 "cms/menu/main.html" %}
</ul>
</div>
{% if user.is_authenticated %}

@ -0,0 +1,10 @@
{% load cms_tags %}
{% for child in children %}
<li class="{% if child.selected %}selected{% endif %}{% if child.ancestor %}ancestor{% endif %}{% if child.sibling %}sibling{% endif %}{% if child.descendant %}descendant{% endif %}">
{% if child.selected %}
<span>{{ child.get_menu_title }}</span>
{% else %}
<a href="{{ child.get_absolute_url }}">{{ child.get_menu_title }}</a>
{% endif %}
</li>
{% endfor %}

@ -18,11 +18,11 @@
</div>
{% for license in licenses %}
<div>
<div class='w100 left'>{{ license.paid_date|default:license.date_from }}</div>
<div class='w100 left'>{{ license.id }}</div>
<div class='w100 left'>{{ license.pay_sum }}</div>
<div class='w100 left'>{{ license.paid_date|default:'-' }}</div>
<div class='w100 left'>{% if license.pay_sum %}{{ license.id }}{% else %}-{% endif %}</div>
<div class='w100 left'>{% if license.pay_sum %}{{ license.pay_sum }}{% else %}-{% endif %}</div>
<div class='w100 left'>{{ license.get_term }}</div>
<div class='w200 left'>{{ license.date_from }} - {{ license.date_to }}</div>
<div class='w200 left'>{% if license.date_from %}{{ license.date_from }} - {{ license.date_to }}{% else %}-{% endif %}</div>
<div class='w100 left'>{{ license.get_status_display }}<br />{{ license.get_paid_status|default:'' }}</div>
<div class='w100 left'>Разные документы</div>
<div class='clear'></div>

@ -0,0 +1,7 @@
Здравствуйте!
Через 1 день заканчивается действие вашего аккаунта на сайте Документор (http://www.dokumentor.ru). Вы не сможете создавать новые документы. {% if licenses_to_pay %}У Вас есть неоплаченные счета, которые можно оплатить, чтобы продлить действие услуги.{% else %}Чтобы продлить действие услуги, войдите в свой профиль и приобретите лицензию на дальнейшее пользование сайтом.{% endif %}
Это письмо написано роботом. Отвечать на него не нужно.
Связаться со службой поддержки сайта Документор Вы можете по адресу {{ support_email }}
Loading…
Cancel
Save