aboutsummaryrefslogtreecommitdiff
path: root/users/forms.py
diff options
context:
space:
mode:
authorBobby <[email protected]>2023-05-13 18:09:54 -0400
committerBobby <[email protected]>2023-05-13 18:09:54 -0400
commitea3e2934733fd642d1b15d89363f92b736bb87d3 (patch)
tree20cbd10f40ebbc1e90b9e460faee0e43a9062403 /users/forms.py
parent3f596631c576cac7c89849650217a8fb4167d5fd (diff)
downloadthatcomputerscientist-ea3e2934733fd642d1b15d89363f92b736bb87d3.tar.xz
thatcomputerscientist-ea3e2934733fd642d1b15d89363f92b736bb87d3.zip
Bug Fix: User avatar not being randomly set on register
Diffstat (limited to 'users/forms.py')
-rw-r--r--users/forms.py5
1 files changed, 5 insertions, 0 deletions
diff --git a/users/forms.py b/users/forms.py
index d66e560d..50179abd 100644
--- a/users/forms.py
+++ b/users/forms.py
@@ -7,6 +7,8 @@ from django.template.loader import render_to_string
from django.utils.html import strip_tags
from .accountFunctions import store_token
from .mail_send import send_email
+from random import choice
+from blog.context_processors import avatar_list
class RegisterForm(forms.Form):
username = forms.CharField(label='Username', max_length=30, min_length=4)
@@ -47,6 +49,9 @@ class RegisterForm(forms.Form):
)
user.save()
user_profile = UserProfile.objects.create(user=user)
+ avatar_dir = choice(list(avatar_list().keys()))
+ avatar_file = choice(avatar_list()[avatar_dir])
+ user_profile.avatar_url = avatar_dir + '/' + avatar_file.replace('.gif', '')
user_profile.save()
uid, token = store_token(token_type='verifyemail', user=user, email=user.email)