* Null-check for gifts
This commit is contained in:
parent
d0ec77c067
commit
c6d8bb0349
|
|
@ -637,16 +637,17 @@ class Checklist(models.Model):
|
|||
self.generate_preview()
|
||||
|
||||
# Update available gifts count
|
||||
if self.gift != old_obj.gift:
|
||||
old_gift = getattr(old_obj, 'gift', None)
|
||||
if self.gift != old_gift:
|
||||
# Decrement new gift
|
||||
if self.gift:
|
||||
self.gift.available_count = max(0, self.gift.available_count - 1)
|
||||
self.gift.save()
|
||||
|
||||
# Increment new gift
|
||||
if old_obj.gift:
|
||||
old_obj.gift.available_count = max(0, old_obj.gift.available_count + 1)
|
||||
old_obj.gift.save()
|
||||
if old_gift:
|
||||
old_gift.available_count = max(0, old_gift.available_count + 1)
|
||||
old_gift.save()
|
||||
|
||||
# Save price details to snapshot
|
||||
if self.price_snapshot_id:
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user