From 7e0aac0125239df717fb7a7c09bd92ea2d346b26 Mon Sep 17 00:00:00 2001 From: Pierre-antoine Comby Date: Mon, 6 Apr 2020 12:32:44 +0200 Subject: [PATCH] add docstring for entry --- apps/activity/models.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/apps/activity/models.py b/apps/activity/models.py index ed2d94c9..60653b3c 100644 --- a/apps/activity/models.py +++ b/apps/activity/models.py @@ -104,6 +104,12 @@ class Activity(models.Model): class Entry(models.Model): + """ + Register the entry of someone: + - a member with a :model:`note.NoteUser` + - or a :model:`activity.Guest` + In the case of a Guest Entry, the inviter note is also save. + """ activity = models.ForeignKey( Activity, on_delete=models.PROTECT, @@ -131,8 +137,7 @@ class Entry(models.Model): class Meta: unique_together = (('activity', 'note', 'guest', ), ) - def save(self, force_insert=False, force_update=False, using=None, - update_fields=None): + def save(self, *args,**kwargs): qs = Entry.objects.filter(~Q(pk=self.pk), activity=self.activity, note=self.note, guest=self.guest) if qs.exists(): @@ -146,7 +151,7 @@ class Entry(models.Model): if self.note.balance < 0: raise ValidationError(_("The balance is negative.")) - ret = super().save(force_insert, force_update, using, update_fields) + ret = super().save(*args,**kwargs) if insert and self.guest: GuestTransaction.objects.create(