From 8a7c4e11c924acaed05bc8935eb0ed8cd2de720a Mon Sep 17 00:00:00 2001 From: vabene1111 Date: Mon, 17 Jan 2022 15:16:13 +0100 Subject: [PATCH] fixed invite link counting --- cookbook/forms.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cookbook/forms.py b/cookbook/forms.py index e47acac0..26e51885 100644 --- a/cookbook/forms.py +++ b/cookbook/forms.py @@ -351,8 +351,8 @@ class InviteLinkForm(forms.ModelForm): def clean(self): space = self.cleaned_data['space'] - if space.max_users != 0 and (UserPreference.objects.filter(space=space).count() + InviteLink.objects.filter( - space=space).filter(valid_until__gte=datetime.today()).count()) >= space.max_users: + if space.max_users != 0 and (UserPreference.objects.filter(space=space).count() + + InviteLink.objects.filter(valid_until__gte=datetime.today(), used_by=None, space=space).count()) >= space.max_users: raise ValidationError(_('Maximum number of users for this space reached.')) def clean_email(self):