From 7c09b55fa9b3f5d355567e61a43bf260879b2416 Mon Sep 17 00:00:00 2001 From: Dmitriy Shesterkin Date: Thu, 6 Jul 2017 20:44:50 +0300 Subject: [PATCH] fixs --- src/customer/models.py | 5 +++-- src/customer/tasks.py | 2 +- src/tests/test_models.py | 4 ++-- templates/customer/profile/orders_list.html | 5 +++++ 4 files changed, 11 insertions(+), 5 deletions(-) diff --git a/src/customer/models.py b/src/customer/models.py index f3b488b..cc89218 100644 --- a/src/customer/models.py +++ b/src/customer/models.py @@ -653,6 +653,7 @@ class License(models.Model): @property def account_status(self): + if self.status in [0, 4]: return 'Счет не оплачен' else: @@ -665,7 +666,7 @@ class License(models.Model): freeze_date = self.order_date + timezone.timedelta(5) return f'Счет заморожен {freeze_date.strftime("%d.%m.%Y")}' if self.status == 0: - remain_day = relativedelta(self.order_date + timezone.timedelta(4), + remain_day = relativedelta(self.order_date + timezone.timedelta(5), timezone.now().date()) remain_day_str = f'{remain_day.days} ' \ f'{numeral.choose_plural(remain_day.days, "день, дня, дней")}' @@ -676,7 +677,7 @@ class License(models.Model): return f'{remain_str} {remain_day_str}' @property - def status_need_to_change(self): + def is_status_need_to_change(self): if self.status == 0: remain_day = relativedelta(self.order_date + timezone.timedelta(5), timezone.now().date()) diff --git a/src/customer/tasks.py b/src/customer/tasks.py index 2566898..29d303d 100644 --- a/src/customer/tasks.py +++ b/src/customer/tasks.py @@ -99,7 +99,7 @@ def check_not_paid_accounts(): if not_paid_accounts_list: for account in not_paid_accounts_list: - if account.status_need_to_change: + if account.is_status_need_to_change: account.set_freeze_status() account_list.append(account) diff --git a/src/tests/test_models.py b/src/tests/test_models.py index c1fef06..aaf4d7f 100644 --- a/src/tests/test_models.py +++ b/src/tests/test_models.py @@ -58,9 +58,9 @@ def test_license_status_need_to_change(lic, days): lic.order_date = timezone.now().date() - timezone.timedelta(days) lic.save() if days > 5: - assert lic.status_need_to_change is True + assert lic.is_status_need_to_change is True else: - assert lic.status_need_to_change is False + assert lic.is_status_need_to_change is False @pytest.mark.django_db diff --git a/templates/customer/profile/orders_list.html b/templates/customer/profile/orders_list.html index bb8a221..fde025a 100644 --- a/templates/customer/profile/orders_list.html +++ b/templates/customer/profile/orders_list.html @@ -69,6 +69,11 @@ {% endfor %} + +
+ +
+ {% endblock content %} {% block js %}