From 0071a5eb2c7c9665873dad6e2197a74a1bcae1e2 Mon Sep 17 00:00:00 2001 From: bashmak Date: Thu, 20 Apr 2017 17:30:25 +0300 Subject: [PATCH] =?UTF-8?q?=D0=A2=D0=B5=D0=BF=D0=B5=D1=80=D1=8C=20=D0=BC?= =?UTF-8?q?=D0=BE=D0=B6=D0=BD=D0=BE=20=D0=B2=D1=8B=D0=B1=D0=B8=D1=80=D0=B0?= =?UTF-8?q?=D1=82=D1=8C=20=D0=B4=D0=B0=D1=82=D1=83=20=D0=BE=D0=BA=D0=BE?= =?UTF-8?q?=D0=BD=D1=87=D0=B0=D0=BD=D0=B8=D1=8F=20=D1=83=D1=81=D0=BB=D1=83?= =?UTF-8?q?=D0=B3=D0=B8=20=D0=BF=D1=80=D0=B8=20=D0=B0=D0=BA=D1=82=D0=B8?= =?UTF-8?q?=D0=B2=D0=B0=D1=86=D0=B8=D0=B8=20=D0=BF=D0=B5=D1=80=D0=B2=D0=BE?= =?UTF-8?q?=D0=B9=20=D1=83=D1=81=D0=BB=D1=83=D0=B3=D0=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- abonapp/locale/ru/LC_MESSAGES/django.po | 10 ++++--- abonapp/models.py | 12 +++++---- abonapp/templates/abonapp/buy_tariff.html | 32 ++++++++++++++++++----- abonapp/templates/abonapp/services.html | 8 +++--- abonapp/views.py | 10 ++++++- tariff_app/models.py | 5 ++++ 6 files changed, 58 insertions(+), 19 deletions(-) diff --git a/abonapp/locale/ru/LC_MESSAGES/django.po b/abonapp/locale/ru/LC_MESSAGES/django.po index 0195353..af39eea 100644 --- a/abonapp/locale/ru/LC_MESSAGES/django.po +++ b/abonapp/locale/ru/LC_MESSAGES/django.po @@ -515,10 +515,6 @@ msgstr "Входящая скорость" msgid "Output speed" msgstr "Исходящая скорость" -#: abonapp/templates/abonapp/services.html:15 -msgid "Edit" -msgstr "Ред." - #: abonapp/templates/abonapp/services.html:52 msgid "Priority up" msgstr "Повысить приоритет" @@ -745,3 +741,9 @@ msgstr "Устройство успешно прикреплено" msgid "Device has successfully unattached" msgstr "Устройство успешно откреплено" + +msgid "Works until" +msgstr "Действует до" + +msgid "Do" +msgstr "Действия" diff --git a/abonapp/models.py b/abonapp/models.py index 1b1250f..16bdd3e 100644 --- a/abonapp/models.py +++ b/abonapp/models.py @@ -112,7 +112,7 @@ class AbonTariff(models.Model): return round(amount, 2) # Активируем тариф - def activate(self, current_user): + def activate(self, current_user, deadline=None): calc_obj = self.tariff.get_calc_type()(self) amnt = self.tariff.amount # если не хватает денег @@ -121,7 +121,10 @@ class AbonTariff(models.Model): # считаем дату активации услуги self.time_start = timezone.now() # считаем дату завершения услуги - self.deadline = calc_obj.calc_deadline() + if deadline is None: + self.deadline = calc_obj.calc_deadline() + else: + self.deadline = deadline # снимаем деньги за услугу self.abon.make_pay(current_user, amnt) self.save() @@ -225,7 +228,6 @@ class Abon(UserProfile): return ats[0].tariff else: self._act_tar_cache = None - return class Meta: db_table = 'abonent' @@ -250,7 +252,7 @@ class Abon(UserProfile): self.ballance += amount # покупаем тариф - def pick_tariff(self, tariff, author, comment=None): + def pick_tariff(self, tariff, author, comment=None, deadline=None): assert isinstance(tariff, Tariff) # выбераем связь ТарифАбонент с самым низким приоритетом @@ -267,7 +269,7 @@ class Abon(UserProfile): # Если это первая услуга в списке (фильтр по приоритету ничего не вернул) if not abtrf: # значит пробуем её активировать - new_abtar.activate(author) + new_abtar.activate(author, deadline) else: new_abtar.save() diff --git a/abonapp/templates/abonapp/buy_tariff.html b/abonapp/templates/abonapp/buy_tariff.html index 8e84d97..f6782e9 100644 --- a/abonapp/templates/abonapp/buy_tariff.html +++ b/abonapp/templates/abonapp/buy_tariff.html @@ -5,8 +5,8 @@ @@ -15,23 +15,43 @@

{% trans 'Pick a service for' %} - {% trans 'Sub' %} + {% trans 'Sub' %}

-
{% csrf_token %}
- {% for trf in tariffs %} - + {% endfor %}
+ {% if not abon.active_tariff %} +
+ + + + +
+ {% endif %}