mirror of
https://gitlab.crans.org/bde/nk20
synced 2025-11-21 05:48:26 +01:00
Some permissions
This commit is contained in:
@@ -396,6 +396,12 @@ class Supplement(models.Model):
|
||||
return _("Supplement {food} for {dish}").format(
|
||||
food=str(self.food), dish=str(self.dish))
|
||||
|
||||
def save(self, *args, **kwargs):
|
||||
# Check the owner of the food
|
||||
if self.food.owner != self.dish.main.owner:
|
||||
raise ValidationError(_('You cannot select food that belongs to the same club than the main food.'))
|
||||
return super().save(*args, **kwargs)
|
||||
|
||||
|
||||
class Order(models.Model):
|
||||
"""
|
||||
@@ -471,6 +477,8 @@ class Order(models.Model):
|
||||
user=str(self.user))
|
||||
|
||||
def save(self, *args, **kwargs):
|
||||
if self.activity != self.dish.activity:
|
||||
raise ValidationError(_('Activities must be the same.'))
|
||||
created = self.pk is None
|
||||
if created:
|
||||
last_order = Order.objects.filter(activity=self.activity).last()
|
||||
@@ -486,6 +494,7 @@ class Order(models.Model):
|
||||
destination=self.activity.organizer.note,
|
||||
amount=self.amount,
|
||||
quantity=1,
|
||||
reason=str(self.dish),
|
||||
)
|
||||
transaction.save()
|
||||
else:
|
||||
|
||||
Reference in New Issue
Block a user