Commit 822392d0 authored by Davve's avatar Davve

修改用户创建问题

parent 984da8fd
...@@ -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:
......
...@@ -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
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