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
0
Merge Requests
0
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
钟尚武
sun
Commits
822392d0
Commit
822392d0
authored
Nov 29, 2018
by
Davve
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修改用户创建问题
parent
984da8fd
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
13 additions
and
9 deletions
+13
-9
user.py
api/user.py
+3
-9
time_utils.py
utils/time_utils.py
+10
-0
No files found.
api/user.py
View file @
822392d0
...
@@ -3,10 +3,8 @@
...
@@ -3,10 +3,8 @@
# __author__ = "chenwei"
# __author__ = "chenwei"
# Date: 2018/11/15
# Date: 2018/11/15
import
time
import
json
from
utils.base
import
APIView
from
utils.base
import
APIView
from
utils.time_utils
import
analysis_time
from
utils.time_utils
import
generate_id
class
UserListView
(
APIView
):
class
UserListView
(
APIView
):
...
@@ -34,11 +32,9 @@ class UserUpdateOrCreate(APIView):
...
@@ -34,11 +32,9 @@ class UserUpdateOrCreate(APIView):
return
data
return
data
def
post
(
self
,
request
):
def
post
(
self
,
request
):
user_id
=
request
.
POST
.
get
(
'id'
,
''
)
id
=
request
.
POST
.
get
(
'id'
,
''
)
# show_time = analysis_time(request.POST.get('show_time', 0))
tag_ids
=
list
(
set
(
request
.
POST
.
get
(
'tag_ids'
)
.
split
(
','
)))
tag_ids
=
list
(
set
(
request
.
POST
.
get
(
'tag_ids'
)
.
split
(
','
)))
if
not
user_id
:
user_id
=
generate_id
()
user_id
=
time
.
time
()
data
=
{
data
=
{
'user_id'
:
user_id
,
'user_id'
:
user_id
,
'is_recommend'
:
request
.
POST
.
get
(
'is_recommend'
),
'is_recommend'
:
request
.
POST
.
get
(
'is_recommend'
),
...
@@ -47,11 +43,9 @@ class UserUpdateOrCreate(APIView):
...
@@ -47,11 +43,9 @@ class UserUpdateOrCreate(APIView):
'tag_ids'
:
list
(
filter
(
lambda
x
:
x
,
tag_ids
)),
'tag_ids'
:
list
(
filter
(
lambda
x
:
x
,
tag_ids
)),
'is_puppet'
:
request
.
POST
.
get
(
'is_puppet'
),
'is_puppet'
:
request
.
POST
.
get
(
'is_puppet'
),
'city_id'
:
request
.
POST
.
get
(
'city'
),
'city_id'
:
request
.
POST
.
get
(
'city'
),
# 'show_time': show_time,
'phone'
:
request
.
POST
.
get
(
'phone'
),
'phone'
:
request
.
POST
.
get
(
'phone'
),
'email'
:
request
.
POST
.
get
(
'email'
),
'email'
:
request
.
POST
.
get
(
'email'
),
'gender'
:
request
.
POST
.
get
(
'gender'
),
'gender'
:
request
.
POST
.
get
(
'gender'
),
# 'group_ids': json.loads(request.POST.get('group_ids')),
}
}
try
:
try
:
...
...
utils/time_utils.py
View file @
822392d0
...
@@ -5,6 +5,7 @@
...
@@ -5,6 +5,7 @@
import
pytz
import
pytz
import
time
import
time
import
random
from
datetime
import
datetime
from
datetime
import
datetime
...
@@ -58,3 +59,12 @@ def analysis_time(time):
...
@@ -58,3 +59,12 @@ def analysis_time(time):
target_time
=
utc_to_datetime
(
time
[:
-
5
]
+
'Z'
)
target_time
=
utc_to_datetime
(
time
[:
-
5
]
+
'Z'
)
return
datetime_toString
(
target_time
)
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