push notificantion test

This commit is contained in:
Parsa Nazer
2025-02-17 00:11:50 +03:30
parent 4fb1d2bdb9
commit ad022cdf6a
9 changed files with 136 additions and 9 deletions
+11 -1
View File
@@ -45,7 +45,17 @@ class OrderModel(models.Model):
# def total_without_tax(self):
# return sum(item.total() for item in self.items.all())
def save(self, *args, **kwargs):
if self.status == 'POSTED':
try:
push_object = PushSubscription.objects.get(user=self.user)
except:
print('object not found')
try:
push_object.send_notif('سفارش شما به پست شده تغییر کرد', 'سفارش شما به پست شده تغییر کرد')
except:
print('didnt send')
super().save(*args, **kwargs)
def total_with_discount(self):
total_with_item_discount = sum(item.total_with_discount() for item in self.items.all())