Added signup formcheck signup.

This commit is contained in:
Marcus Scholz 2020-08-02 23:22:47 +02:00
parent ca1bc12e88
commit 3ab5bf6826

View File

@ -13,6 +13,17 @@ class ExplorerCreationForm(UserCreationForm):
fields = ('username', 'email')
voucher = forms.CharField(max_length=10)
def is_valid(self):
super().is_valid()
sumitted_voucher = self.cleaned_data.get('voucher')
try:
fetched_voucher = Voucher.objects.get(code=sumitted_voucher)
except Voucher.DoesNotExist:
return False
fetched_voucher.delete()
return True
class ExplorerChangeForm(UserChangeForm):
class Meta:
model = Explorer