- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
Change(models.model):
def save(self, *args, **kwargs):
is_need_to_add = False
if not self.pk and self.package.type not in [Billing.TYPE_H, Billing.TYPE_F]:
is_need_to_add = True
super(Change, self).save(*args, **kwargs)
if is_need_to_add:
package = self.package
package.done += self.delta
if self.package.status == Billing.STATUS_IN_WORK and package.count_done >= package.count_wants:
package.status = Billing.STATUS_DONE
package.save()
title, id = self.package.company.title, self.package.company.id
leads, price = self.package.count_wants, self.package.price
mail.send("trololo")
package.save()
package.check_billing()
Django ORM, внутри метода save() сразу и сохранение сущности в базу, и апдейт родительской сущности и mail нотификация менеджерам.
guest8 04.04.2019 19:30 # −999
guest8 04.04.2019 20:53 # −999
facepalm 04.04.2019 21:16 # 0
guest8 04.04.2019 21:21 # −999
guest8 04.04.2019 22:14 # −999
facepalm 04.04.2019 23:17 # 0
guest8 04.04.2019 23:22 # −999
facepalm 05.04.2019 07:50 # 0
guest8 05.04.2019 08:15 # −999
BOKCEJIbHblu_nemyx 04.04.2019 21:16 # 0
AHCKujlbHblu_netyx 06.04.2019 11:45 # 0
intestinalbrain 15.04.2019 12:30 # 0
PACTPOBblu_nemyx 15.04.2019 14:11 # 0
facepalm 19.04.2019 11:17 # 0