Waiting list: Optionally allow multiple entries per email (#3277)

Co-authored-by: Richard Schreiber <schreiber@rami.io>
This commit is contained in:
Raphael Michel
2023-05-02 10:27:56 +02:00
committed by GitHub
parent fa4cdbfe4a
commit 3810dcd5b8
6 changed files with 22 additions and 4 deletions

View File

@@ -119,7 +119,7 @@ class WaitingListEntry(LoggedModel):
def clean(self):
try:
WaitingListEntry.clean_duplicate(self.email, self.item, self.variation, self.subevent, self.pk)
WaitingListEntry.clean_duplicate(self.event, self.email, self.item, self.variation, self.subevent, self.pk)
WaitingListEntry.clean_itemvar(self.event, self.item, self.variation)
WaitingListEntry.clean_subevent(self.event, self.subevent)
except ObjectDoesNotExist:
@@ -308,9 +308,9 @@ class WaitingListEntry(LoggedModel):
raise ValidationError(_('The subevent does not belong to this event.'))
@staticmethod
def clean_duplicate(email, item, variation, subevent, pk):
def clean_duplicate(event, email, item, variation, subevent, pk):
if WaitingListEntry.objects.filter(
item=item, variation=variation, email__iexact=email, voucher__isnull=True, subevent=subevent
).exclude(pk=pk).exists():
).exclude(pk=pk).count() >= event.settings.waiting_list_limit_per_user:
raise ValidationError(_('You are already on this waiting list! We will notify '
'you as soon as we have a ticket available for you.'))

View File

@@ -1330,6 +1330,21 @@ DEFAULTS = {
help_text=_("If you ask for a phone number, explain why you do so and what you will use the phone number for.")
)
},
'waiting_list_limit_per_user': {
'default': '1',
'type': int,
'serializer_class': serializers.IntegerField,
'form_class': forms.IntegerField,
'serializer_kwargs': dict(
min_value=1,
),
'form_kwargs': dict(
label=_("Maximum number of entries per email address for the same product"),
min_value=1,
required=True,
widget=forms.NumberInput(),
)
},
'show_checkin_number_user': {
'default': 'False',
'type': bool,