Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
S
sun
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
1
Merge Requests
1
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
alpha
sun
Commits
822392d0
Commit
822392d0
authored
Nov 29, 2018
by
Davve
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修改用户创建问题
parent
984da8fd
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
14 additions
and
11 deletions
+14
-11
user.py
api/user.py
+3
-9
time_utils.py
utils/time_utils.py
+11
-2
No files found.
api/user.py
View file @
822392d0
...
...
@@ -3,10 +3,8 @@
# __author__ = "chenwei"
# Date: 2018/11/15
import
time
import
json
from
utils.base
import
APIView
from
utils.time_utils
import
analysis_time
from
utils.time_utils
import
generate_id
class
UserListView
(
APIView
):
...
...
@@ -34,11 +32,9 @@ class UserUpdateOrCreate(APIView):
return
data
def
post
(
self
,
request
):
user_id
=
request
.
POST
.
get
(
'id'
,
''
)
# show_time = analysis_time(request.POST.get('show_time', 0))
id
=
request
.
POST
.
get
(
'id'
,
''
)
tag_ids
=
list
(
set
(
request
.
POST
.
get
(
'tag_ids'
)
.
split
(
','
)))
if
not
user_id
:
user_id
=
time
.
time
()
user_id
=
generate_id
()
data
=
{
'user_id'
:
user_id
,
'is_recommend'
:
request
.
POST
.
get
(
'is_recommend'
),
...
...
@@ -47,11 +43,9 @@ class UserUpdateOrCreate(APIView):
'tag_ids'
:
list
(
filter
(
lambda
x
:
x
,
tag_ids
)),
'is_puppet'
:
request
.
POST
.
get
(
'is_puppet'
),
'city_id'
:
request
.
POST
.
get
(
'city'
),
# 'show_time': show_time,
'phone'
:
request
.
POST
.
get
(
'phone'
),
'email'
:
request
.
POST
.
get
(
'email'
),
'gender'
:
request
.
POST
.
get
(
'gender'
),
# 'group_ids': json.loads(request.POST.get('group_ids')),
}
try
:
...
...
utils/time_utils.py
View file @
822392d0
...
...
@@ -5,6 +5,7 @@
import
pytz
import
time
import
random
from
datetime
import
datetime
...
...
@@ -57,4 +58,13 @@ def analysis_time(time):
except
ValueError
:
target_time
=
utc_to_datetime
(
time
[:
-
5
]
+
'Z'
)
return
datetime_toString
(
target_time
)
\ No newline at end of file
return
datetime_toString
(
target_time
)
def
generate_id
():
nowTime
=
datetime
.
now
()
.
strftime
(
"
%
Y
%
m
%
d
%
H
%
M
%
S"
)
# 生成当前时间
randomNum
=
random
.
randint
(
0
,
100
);
# 生成的随机整数n,其中0<=n<=100
if
randomNum
<=
10
:
randomNum
=
str
(
0
)
+
str
(
randomNum
)
uniqueNum
=
str
(
nowTime
)
+
str
(
randomNum
)
return
uniqueNum
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment