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):