class PrepaidCreateForm(forms.Form):
regtype = forms.ModelChoiceField(label="Registration type", queryset=RegistrationType.objects.filter(id=-1))
count = forms.IntegerField(label="Number of vouchers", min_value=1, max_value=100)
- buyer = forms.ModelChoiceField(queryset=User.objects.all().order_by('username'), help_text="Pick the user who bought the batch. If he/she does not have an account, pick your own userid")
+ buyer = forms.ModelChoiceField(queryset=User.objects.filter(pk=-1).order_by('username'), help_text="Pick the user who bought the batch. If he/she does not have an account, pick your own userid")
invoice = forms.BooleanField(help_text="Automatically create invoice for these vouchers and send it to the person ordering them.", required=False)
invoiceaddress = forms.CharField(label="Invoice address", help_text="Complete address to put on invoice. Note that the name of the buyer is prepended to this!", required=False, widget=MonospaceTextarea)
confirm = forms.BooleanField(help_text="Confirm that the chosen registration type and count are correct (there is no undo past this point, the vouchers will be created!")
if 'invoice' in self.data and not self.data.get('invoiceaddress', ''):
del self.fields['confirm']
+ if 'data' in kwargs and 'buyer' in kwargs['data']:
+ self.fields['buyer'].queryset = User.objects.filter(pk__in=kwargs['data'].getlist('buyer'))
+
def clean(self):
cleaned_data = super(PrepaidCreateForm, self).clean()
if self.cleaned_data.get('invoice', False):