Add notification

This commit is contained in:
Skia
2016-12-08 19:47:28 +01:00
parent c1397ef5a5
commit 80fa99d2ac
12 changed files with 387 additions and 562 deletions

View File

@ -15,7 +15,7 @@ import datetime
from club.models import Club
from accounting.models import CurrencyField
from core.models import Group, User
from core.models import Group, User, Notification
from subscription.models import Subscriber, Subscription
from subscription.views import get_subscriber
@ -270,6 +270,12 @@ class Refilling(models.Model):
self.customer.amount += self.amount
self.customer.save()
self.is_validated = True
Notification(
user=self.customer.user,
url=reverse('core:user_account_detail',
kwargs={'user_id': self.customer.user.id, 'year': self.date.year, 'month': self.date.month}),
text=_("You just refilled of %(amount)s") % {'amount': self.amount}
).save()
super(Refilling, self).save(*args, **kwargs)
class Selling(models.Model):
@ -377,6 +383,13 @@ class Selling(models.Model):
if self.product.eticket:
self.send_mail_customer()
except: pass
Notification(
user=self.customer.user,
url=reverse('core:user_account_detail',
kwargs={'user_id': self.customer.user.id, 'year': self.date.year, 'month': self.date.month}),
text=_("You just bought %(quantity)d %(product_name)s") % {'quantity': self.quantity, 'product_name': self.label}
).save()
super(Selling, self).save(*args, **kwargs)
class Permanency(models.Model):