|
1 |
| -import datetime |
2 | 1 | import logging
|
3 | 2 | # Create your views here.
|
4 | 3 | from urllib.parse import urlparse
|
|
13 | 12 | from django.shortcuts import get_object_or_404
|
14 | 13 | from django.shortcuts import render
|
15 | 14 | from django.urls import reverse
|
| 15 | +from django.utils import timezone |
16 | 16 | from django.views.generic import FormView
|
17 | 17 |
|
18 | 18 | from djangoblog.blog_signals import oauth_user_login_signal
|
@@ -73,8 +73,7 @@ def authorize(request):
|
73 | 73 | user = manager.get_oauth_userinfo()
|
74 | 74 | if user:
|
75 | 75 | if not user.nikename or not user.nikename.strip():
|
76 |
| - import datetime |
77 |
| - user.nikename = "djangoblog" + datetime.datetime.now().strftime('%y%m%d%I%M%S') |
| 76 | + user.nikename = "djangoblog" + timezone.now().strftime('%y%m%d%I%M%S') |
78 | 77 | try:
|
79 | 78 | temp = OAuthUser.objects.get(type=type, openid=user.openid)
|
80 | 79 | temp.picture = user.picture
|
@@ -102,7 +101,7 @@ def authorize(request):
|
102 | 101 | except ObjectDoesNotExist:
|
103 | 102 | author.username = user.nikename
|
104 | 103 | else:
|
105 |
| - author.username = "djangoblog" + datetime.datetime.now().strftime('%y%m%d%I%M%S') |
| 104 | + author.username = "djangoblog" + timezone.now().strftime('%y%m%d%I%M%S') |
106 | 105 | author.source = 'authorize'
|
107 | 106 | author.save()
|
108 | 107 |
|
@@ -141,7 +140,7 @@ def emailconfirm(request, id, sign):
|
141 | 140 | if result[1]:
|
142 | 141 | author.source = 'emailconfirm'
|
143 | 142 | author.username = oauthuser.nikename.strip() if oauthuser.nikename.strip(
|
144 |
| - ) else "djangoblog" + datetime.datetime.now().strftime('%y%m%d%I%M%S') |
| 143 | + ) else "djangoblog" + timezone.now().strftime('%y%m%d%I%M%S') |
145 | 144 | author.save()
|
146 | 145 | oauthuser.author = author
|
147 | 146 | oauthuser.save()
|
|
0 commit comments