Release 22 #45

Merged
ChaoticByte merged 4 commits from devel into main 2025-09-07 20:40:16 +00:00
2 changed files with 5 additions and 4 deletions
Showing only changes of commit 5fefee2282 - Show all commits

View file

@ -40,6 +40,7 @@ class Drink(models.Model):
do_not_count = models.BooleanField(default=False)
def delete(self, *args, **kwargs):
# we flag the field as deleted.
self.deleted = True
super().save()
@ -107,10 +108,9 @@ class Order(models.Model):
price_sum = models.DecimalField(max_digits=6, decimal_places=2, default=0, editable=False)
content_litres = models.DecimalField(max_digits=6, decimal_places=3, default=0, editable=False)
# TODO: Add more comments on how and why the save & delete functions are implemented
# address this in a refactoring issue.
def save(self, *args, **kwargs):
# saving this may affect other fields
# so we reimplement the save function
drink = Drink.objects.get(pk=self.drink.pk)
if self._state.adding and drink.available > 0:
if not drink.do_not_count:
@ -126,6 +126,7 @@ class Order(models.Model):
raise ValidationError("This entry can't be changed.")
def delete(self, *args, **kwargs):
# when deleting, we affect other fields as well.
self.user.balance += self.price_sum
self.user.save()
drink = Drink.objects.get(pk=self.drink.pk)

View file

@ -14,7 +14,7 @@ from time import sleep
from yaml import safe_load
banner = """ ___ _ _
banner = r""" ___ _ _
| \ _ _ (_) _ _ | |__ ___ ___
| |) || '_|| || ' \ | / /(_-< |___|
|___/ |_| |_||_||_||_\_\/__/