From e98ffb5cd54736283d8acf4af216d8264f53d3cf Mon Sep 17 00:00:00 2001 From: Skia Date: Thu, 10 Nov 2016 13:51:56 +0100 Subject: [PATCH] Fix unappropriate behavior when delete selling --- core/templates/core/user_account_detail.jinja | 3 +-- counter/models.py | 9 +++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/core/templates/core/user_account_detail.jinja b/core/templates/core/user_account_detail.jinja index e73c346f..0d1dcac9 100644 --- a/core/templates/core/user_account_detail.jinja +++ b/core/templates/core/user_account_detail.jinja @@ -55,8 +55,7 @@ - {% for i in customer.refillings.order_by('-date').filter( - date__year=year, date__month=month) %} + {% for i in customer.refillings.order_by('-date').filter( date__year=year, date__month=month) %} {{ i.date|localtime|date(DATETIME_FORMAT) }} - {{ i.date|localtime|time(DATETIME_FORMAT) }} {{ i.counter }} diff --git a/counter/models.py b/counter/models.py index af6b89f5..c74f1eef 100644 --- a/counter/models.py +++ b/counter/models.py @@ -223,7 +223,7 @@ class Counter(models.Model): def is_inactive(self): """ - Returns True if the counter self is inactive from SITH_COUNTER_MINUTE_INACTIVE's value minutes, else False + Returns True if the counter self is inactive from SITH_COUNTER_MINUTE_INACTIVE's value minutes, else False """ return self.is_open() and ((timezone.now() - self.permanencies.order_by('-activity').first().activity) > datetime.timedelta(minutes=settings.SITH_COUNTER_MINUTE_INACTIVE)) @@ -303,8 +303,9 @@ class Selling(models.Model): return user == self.customer.user def delete(self, *args, **kwargs): - self.customer.amount += self.quantity * self.unit_price - self.customer.save() + if self.payment_method == "SITH_ACCOUNT": + self.customer.amount += self.quantity * self.unit_price + self.customer.save() super(Selling, self).delete(*args, **kwargs) def send_mail_customer(self): @@ -331,7 +332,7 @@ class Selling(models.Model): self.customer.user.email_user( subject, message_txt, - html_message=message_html + html_message=message_html ) def save(self, *args, **kwargs):