invoice list, paid licenses list, license statuses, update status for expired licenses

remotes/origin/yandex
Bachurin Sergey 12 years ago
parent 2737048fb8
commit aa388f256d
  1. 46
      project/customer/models.py
  2. 3
      project/customer/tasks.py
  3. 2
      project/customer/views/license.py
  4. 5
      project/static/css/style.css
  5. 16
      project/templates/customer/profile/license_list.html
  6. 19
      project/templates/customer/profile/paid_list.html

@ -1,5 +1,6 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
import os import os
from datetime import datetime
from PIL import Image from PIL import Image
from pytils import numeral from pytils import numeral
@ -386,6 +387,7 @@ class License(models.Model):
def get_email(self): def get_email(self):
return self.user.email return self.user.email
def get_action(self): def get_action(self):
if self.status == 0: if self.status == 0:
if self.payform == 0: if self.payform == 0:
@ -399,11 +401,51 @@ class License(models.Model):
else: else:
return '' return ''
def get_term(self):
if self.term == 0:
return u'45 дней'
else:
return u'%s %s' % (self.term,
numeral.choose_plural(self.term, u"месяц, месяца, месяцев"),
)
def get_action(self):
if self.status == -1:
return ''
if self.status == 0:
if self.payform == 0:
#return reverse()
return u'Скачать счёт'
elif self.payform == 1:
return u'Оплатить счёт'
elif self.payform == 2:
return u'Скачать квитанцию'
if self.status == 1:
return u'История операций'
else:
return ''
def get_paid_status(self): def get_paid_status(self):
if self.status == 1: if self.status == 1:
return u'Лицензия оплачена, ещё не активирована' return u'Лицензия оплачена, ещё не активирована'
elif self.status == 2: elif self.status in [2, -1]:
return u'Лицензия оплачена: осталось %d дней.' left = relativedelta(self.date_to, datetime.today())
if left.months:
left_str = '%d %s %d %s' % (left.months,
numeral.choose_plural(left.months, u"месяц, месяца, месяцев"),
left.days,
numeral.choose_plural(left.days, u"день, дня, дней"),
)
else:
left_str = '%d %s' % (
left.days,
numeral.choose_plural(left.days, u"день, дня, дней"),
)
return u'Лицензия активирована: осталось %s' % left_str
elif self.status == 3:
return u'Время истекло'
else:
return None
class LicensePrice(models.Model): class LicensePrice(models.Model):

@ -20,5 +20,8 @@ def check_license():
profile.save() profile.save()
licenses.filter(status=1).update(status=2) 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)
return None return None

@ -57,7 +57,7 @@ def license_list(request):
"""Список счетов на лицензии """Список счетов на лицензии
""" """
template_name = 'customer/profile/license_list.html' template_name = 'customer/profile/license_list.html'
licenses = License.objects.filter(user=request.user, deleted=False).order_by('-id') licenses = License.objects.filter(user=request.user, deleted=False, status__gt=-1).order_by('-id')
dictionary = { dictionary = {
'licenses': licenses, 'licenses': licenses,
} }

@ -203,5 +203,6 @@ table.list td { word-break: break-all; padding: 5px 0; }
/* blockUI */ /* blockUI */
div.blockOverlay { background: url('../img/ajax-loader.gif') no-repeat center center; z-index: 99999; } div.blockOverlay { background: url('../img/ajax-loader.gif') no-repeat center center; z-index: 99999; }
div.blockMsg { width: 100%; height: 100%; top: 0; left: 0; text-align: center; } div.blockMsg { width: 100%; height: 100%; top: 0; left: 0; text-align: center; }
.w100 {width:100px;} .w100 {width:100px;min-height:5px;}
.w200 {width:200px;} .w200 {width:200px;min-height:5px;}
.header {font-weight:bold; }

@ -1,16 +1,28 @@
{% extends "base.html" %} {% extends "base.html" %}
{% load pytils_numeral %} {% load pytils_numeral %}
{% block title %}Купить лицензию{% endblock %} {% block title %}Мои счета{% endblock %}
{% block content %} {% block content %}
<a href="{% url 'customer_order_license' %}">Купить лицензию</a><br /><br /> <a href="{% url 'customer_order_license' %}">Купить лицензию</a><br /><br />
<a href="{% url 'customer_paid_list' %}">Оплаченные лицензии</a><br /><br /> <a href="{% url 'customer_paid_list' %}">Оплаченные лицензии</a><br /><br />
<h1>Выписанные счета</h1> <h1>Выписанные счета</h1>
<div class='header'>
<div class='w100 left'>Номер</div>
<div class='w100 left'>Дата счёта</div>
<div class='w100 left'>Срок лицензии</div>
<div class='w100 left'>Сумма</div>
<div class='w100 left'>Вид платежа</div>
<div class='w100 left'>Статус</div>
<div class='w100 left'>Действия</div>
<div class='w100 left'>Отменить заявку</div>
<div class='clear'></div>
</div>
{% for license in licenses %} {% for license in licenses %}
<div class='license_{{ license.id }}'> <div class='license_{{ license.id }}'>
<div class='w100 left'>{{ license.id }}</div> <div class='w100 left'>{{ license.id }}</div>
<div class='w100 left'>{{ license.order_date }}</div> <div class='w100 left'>{{ license.order_date }}</div>
<div class='w100 left'>{{ license.term }}</div> <div class='w100 left'>{{ license.get_term }}</div>
<div class='w100 left'>{{ license.pay_sum|get_plural:"рубль,рубля,рублей" }}</div>
<div class='w100 left'>{{ license.get_payform_display }}</div> <div class='w100 left'>{{ license.get_payform_display }}</div>
<div class='w100 left'>{{ license.get_status_display }}</div> <div class='w100 left'>{{ license.get_status_display }}</div>
<div class='w100 left'>{{ license.get_action }}</div> <div class='w100 left'>{{ license.get_action }}</div>

@ -1,19 +1,30 @@
{% extends "base.html" %} {% extends "base.html" %}
{% load pytils_numeral %} {% load pytils_numeral %}
{% block title %}Купить лицензию{% endblock %} {% block title %}История расчётов{% endblock %}
{% block content %} {% block content %}
<a href="{% url 'customer_order_license' %}">Купить лицензию</a><br /><br /> <a href="{% url 'customer_order_license' %}">Купить лицензию</a><br /><br />
<a href="{% url 'customer_license_list' %}">Все счета</a><br /><br /> <a href="{% url 'customer_license_list' %}">Все счета</a><br /><br />
<h1>История оплат</h1> <h1>История оплат</h1>
<div class='header'>
<div class='w100 left'>Дата оплаты</div>
<div class='w100 left'>По счёту</div>
<div class='w100 left'>Сумма</div>
<div class='w100 left'>Срок лицензии</div>
<div class='w200 left'>Период действия лицензии</div>
<div class='w100 left'>Статус лицензии</div>
<div class='w100 left'>Закрывающие документы</div>
<div class='clear'></div>
</div>
{% for license in licenses %} {% for license in licenses %}
<div> <div>
<div class='w100 left'>{{ license.paid_date }}</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.id }}</div>
<div class='w100 left'>{{ license.pay_sum }}</div> <div class='w100 left'>{{ license.pay_sum }}</div>
<div class='w100 left'>{{ license.term }}</div> <div class='w100 left'>{{ license.get_term }}</div>
<div class='w200 left'>{{ license.date_from }} - {{ license.date_to }}</div> <div class='w200 left'>{{ license.date_from }} - {{ license.date_to }}</div>
<div class='w100 left'>{{ license.get_status_display }}</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> <div class='clear'></div>
</div> </div>
{% endfor %} {% endfor %}

Loading…
Cancel
Save