Merge branch 'voucher' of mowoe.com:reverend/lostplaces-backend into voucher

This commit is contained in:
reverend 2020-08-03 17:34:18 +02:00
commit dc318d4f98
2 changed files with 12 additions and 1 deletions

View File

@ -11,6 +11,18 @@ class ExplorerCreationForm(UserCreationForm):
class Meta: class Meta:
model = Explorer model = Explorer
fields = ('username', 'email') 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 ExplorerChangeForm(UserChangeForm):
class Meta: class Meta:

View File

@ -2,7 +2,6 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
''' Django views. ''' ''' Django views. '''
from django.shortcuts import render, redirect, get_object_or_404 from django.shortcuts import render, redirect, get_object_or_404
from django.urls import reverse_lazy from django.urls import reverse_lazy
from django.views.generic.edit import CreateView from django.views.generic.edit import CreateView