Commit 822392d0 authored by Davve's avatar Davve

修改用户创建问题

parent 984da8fd
......@@ -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:
......
......@@ -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
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment