Skip to content

Commit 2a1973c

Browse files
committed
Using Gravatar At Activation Also
1 parent 00ff254 commit 2a1973c

1 file changed

Lines changed: 11 additions & 1 deletion

File tree

website/user_profile/views.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,6 @@ def user_register(request):
9595
'token': account_activation_token.make_token(user),
9696
})
9797
user.email_user(subject, message)
98-
print("sddsdsdsd")
9998
return HttpResponse("Please confirm your email address to complete the Registration. ")
10099
if form.errors:
101100
for field in form:
@@ -122,6 +121,17 @@ def activate(request, uidb64, token, backend='django.contrib.auth.backends.Model
122121
user.profile.email_confirmed = True
123122
user.save()
124123
login(request, user, backend='django.contrib.auth.backends.ModelBackend')
124+
profile = Profile.objects.get(user = user)
125+
image_url = "https://api.adorable.io/avatars/" + str(random.randint(0000, 9999))
126+
type = valid_url_extension(image_url)
127+
full_path = 'media/images/' + profile.user.username + '.png'
128+
try:
129+
urllib.request.urlretrieve(image_url, full_path)
130+
except:
131+
return HttpResponse("Downloadable Image Not Found!")
132+
if profile.user == request.user:
133+
profile.image = '../' + full_path
134+
profile.save()
125135
return redirect('user_profile:edit_profile')
126136
else:
127137
return render(request, 'account_activation_invalid.html')

0 commit comments

Comments
 (0)