whitespaces....
This commit is contained in:
parent
a57ffcdfd7
commit
2ad895ae1b
@ -40,7 +40,7 @@ class PlayerCreateView(LoginRequiredMixin, HeadCoachCheckMixin, CreateView):
|
|||||||
player.set_unusable_password() # Password must be set via verification
|
player.set_unusable_password() # Password must be set via verification
|
||||||
player.verification_code = uuid.uuid4()
|
player.verification_code = uuid.uuid4()
|
||||||
player.save()
|
player.save()
|
||||||
|
|
||||||
# Send verification email to player
|
# Send verification email to player
|
||||||
send_verification_email(player, self.request, is_parent=False)
|
send_verification_email(player, self.request, is_parent=False)
|
||||||
|
|
||||||
@ -70,7 +70,7 @@ class PlayerCreateView(LoginRequiredMixin, HeadCoachCheckMixin, CreateView):
|
|||||||
|
|
||||||
elif new_email:
|
elif new_email:
|
||||||
parent_user, created = CustomUser.objects.get_or_create(
|
parent_user, created = CustomUser.objects.get_or_create(
|
||||||
email=new_email,
|
email=new_email,
|
||||||
defaults={'username': new_email, 'is_active': False}
|
defaults={'username': new_email, 'is_active': False}
|
||||||
)
|
)
|
||||||
if created:
|
if created:
|
||||||
@ -102,28 +102,28 @@ def user_search(request):
|
|||||||
|
|
||||||
def verify_account(request, verification_code):
|
def verify_account(request, verification_code):
|
||||||
user = get_object_or_404(CustomUser, verification_code=verification_code, is_verified=False)
|
user = get_object_or_404(CustomUser, verification_code=verification_code, is_verified=False)
|
||||||
|
|
||||||
# Determine if user is a parent (has no team) or player
|
# Determine if user is a parent (has no team) or player
|
||||||
is_parent = user.team is None
|
is_parent = user.team is None
|
||||||
|
|
||||||
FormClass = ParentVerificationForm if is_parent else PlayerVerificationForm
|
FormClass = ParentVerificationForm if is_parent else PlayerVerificationForm
|
||||||
|
|
||||||
if request.method == 'POST':
|
if request.method == 'POST':
|
||||||
form = FormClass(request.POST)
|
form = FormClass(request.POST)
|
||||||
if form.is_valid():
|
if form.is_valid():
|
||||||
user.set_password(form.cleaned_data['password'])
|
user.set_password(form.cleaned_data['password'])
|
||||||
if is_parent:
|
if is_parent:
|
||||||
user.username = form.cleaned_data['username']
|
user.username = form.cleaned_data['username']
|
||||||
|
|
||||||
user.is_active = True
|
user.is_active = True
|
||||||
user.is_verified = True
|
user.is_verified = True
|
||||||
user.verification_code = None # Invalidate the code
|
user.verification_code = None # Invalidate the code
|
||||||
user.save()
|
user.save()
|
||||||
|
|
||||||
login(request, user) # Log the user in
|
login(request, user) # Log the user in
|
||||||
messages.success(request, 'Your account has been verified! You are now logged in.')
|
messages.success(request, 'Your account has been verified! You are now logged in.')
|
||||||
return redirect('dashboard')
|
return redirect('dashboard')
|
||||||
else:
|
else:
|
||||||
form = FormClass()
|
form = FormClass()
|
||||||
|
|
||||||
return render(request, 'accounts/verify_account.html', {'form': form, 'is_parent': is_parent})
|
return render(request, 'accounts/verify_account.html', {'form': form, 'is_parent': is_parent})
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user