|
@@ -27,8 +27,7 @@ from ratelimit.decorators import ratelimit
|
|
|
|
|
|
from Ansjer.config import AuthCode_Expire, SERVER_DOMAIN, APNS_CONFIG, JPUSH_CONFIG, FCM_CONFIG, TUTK_PUSH_DOMAIN
|
|
|
from Controller.CheckUserData import DataValid, date_handler, RandomStr
|
|
|
-from Model.models import Device_User, Role, UidPushModel, UserOauth2Model, UserExModel, Device_Info, UidSetModel, \
|
|
|
- UserAppFrequencyModel
|
|
|
+from Model.models import Device_User, Role, UidPushModel, UserOauth2Model, UserExModel, Device_Info, UidSetModel
|
|
|
from Object.AWS.SesClassObject import SesClassObject
|
|
|
from Object.AliSmsObject import AliSmsObject
|
|
|
from Object.RedisObject import RedisObject
|
|
@@ -2627,7 +2626,7 @@ class alexaUidView(TemplateView):
|
|
|
uid_list.append(uid_q['UID'])
|
|
|
# 给uid_q['UID']赋值
|
|
|
uid_dict[uid_q['UID']] = {'nick': uid_q['NickName'], 'password': uid_q['View_Password']}
|
|
|
- us_qs = UidSetModel.objects.filter(uid__in=uid_list, is_alexa=2).values('uid', 'region_alexa')
|
|
|
+ us_qs = UidSetModel.objects.filter(uid__in=uid_list, is_alexa=1).values('uid', 'region_alexa')
|
|
|
# uid,password,region的列表
|
|
|
uid_arr = []
|
|
|
for us in us_qs:
|
|
@@ -2928,81 +2927,81 @@ class Image_Code_RegisterView(TemplateView):
|
|
|
return response.json(0, res)
|
|
|
|
|
|
|
|
|
-class UserAppFrequencyView(TemplateView):
|
|
|
- @method_decorator(csrf_exempt)
|
|
|
- def dispatch(self, *args, **kwargs):
|
|
|
- return super(UserAppFrequencyView, self).dispatch(*args, **kwargs)
|
|
|
-
|
|
|
- def post(self, request, *args, **kwargs):
|
|
|
- request.encoding = 'utf-8'
|
|
|
- request_dict = request.POST
|
|
|
- operation = kwargs.get('operation')
|
|
|
- return self.validates(request_dict, operation)
|
|
|
-
|
|
|
- def get(self, request, *args, **kwargs):
|
|
|
- request.encoding = 'utf-8'
|
|
|
- request_dict = request.GET
|
|
|
- operation = kwargs.get('operation')
|
|
|
- return self.validates(request_dict, operation)
|
|
|
-
|
|
|
- def validates(self, request_dict, operation):
|
|
|
- token = request_dict.get('token', None)
|
|
|
- response = ResponseObject()
|
|
|
-
|
|
|
- token = TokenObject(token)
|
|
|
- if token.code != 0:
|
|
|
- return response.json(token.code)
|
|
|
-
|
|
|
- if operation == 'refresh':
|
|
|
- return self.do_refresh(request_dict, token.userID, response)
|
|
|
- else:
|
|
|
- return response.json(404)
|
|
|
-
|
|
|
- def do_refresh(self, request_dict, userID, response):
|
|
|
- # return response.json(0)
|
|
|
- type = request_dict.get('type', None)
|
|
|
- month = request_dict.get('month', None)
|
|
|
- if not type or not month:
|
|
|
- return response.json(444, 'type')
|
|
|
- else:
|
|
|
- type = int(type)
|
|
|
- now_time = int(time.time())
|
|
|
- month = int(month)
|
|
|
- uaf_qs = UserAppFrequencyModel.objects.filter(user__userID=userID)
|
|
|
-
|
|
|
- if not uaf_qs.exists():
|
|
|
- user = Device_User.objects.filter(userID=userID)[0]
|
|
|
- data = {
|
|
|
- 'user': user,
|
|
|
- 'type': type,
|
|
|
- 'data_time': month,
|
|
|
- 'add_time': now_time,
|
|
|
- 'update_time': now_time,
|
|
|
- }
|
|
|
- UserAppFrequencyModel.objects.create(**data)
|
|
|
- return response.json(0)
|
|
|
- else:
|
|
|
- updateMonth = time.strftime('%m', time.localtime(month))
|
|
|
- uaf = uaf_qs.values('id', 'type', 'data_time')[0]
|
|
|
- dbMonth = time.strftime('%m', time.localtime(int(uaf['data_time'])))
|
|
|
- print('update month is ' + updateMonth)
|
|
|
- print('db month is ' + dbMonth)
|
|
|
- if updateMonth == dbMonth:
|
|
|
- UserAppFrequencyModel.objects.filter(id=uaf['id']).update(type=type)
|
|
|
- return response.json(0)
|
|
|
- elif updateMonth > dbMonth:
|
|
|
- user = Device_User.objects.filter(userID=userID)[0]
|
|
|
- data = {
|
|
|
- 'user': user,
|
|
|
- 'type': type,
|
|
|
- 'data_time': month,
|
|
|
- 'add_time': now_time,
|
|
|
- 'update_time': now_time,
|
|
|
- }
|
|
|
- UserAppFrequencyModel.objects.create(**data)
|
|
|
- return response.json(0)
|
|
|
- else:
|
|
|
- return response.json(444, 'month')
|
|
|
+# class UserAppFrequencyView(TemplateView):
|
|
|
+# @method_decorator(csrf_exempt)
|
|
|
+# def dispatch(self, *args, **kwargs):
|
|
|
+# return super(UserAppFrequencyView, self).dispatch(*args, **kwargs)
|
|
|
+#
|
|
|
+# def post(self, request, *args, **kwargs):
|
|
|
+# request.encoding = 'utf-8'
|
|
|
+# request_dict = request.POST
|
|
|
+# operation = kwargs.get('operation')
|
|
|
+# return self.validates(request_dict, operation)
|
|
|
+#
|
|
|
+# def get(self, request, *args, **kwargs):
|
|
|
+# request.encoding = 'utf-8'
|
|
|
+# request_dict = request.GET
|
|
|
+# operation = kwargs.get('operation')
|
|
|
+# return self.validates(request_dict, operation)
|
|
|
+#
|
|
|
+# def validates(self, request_dict, operation):
|
|
|
+# token = request_dict.get('token', None)
|
|
|
+# response = ResponseObject()
|
|
|
+#
|
|
|
+# token = TokenObject(token)
|
|
|
+# if token.code != 0:
|
|
|
+# return response.json(token.code)
|
|
|
+#
|
|
|
+# if operation == 'refresh':
|
|
|
+# return self.do_refresh(request_dict, token.userID, response)
|
|
|
+# else:
|
|
|
+# return response.json(404)
|
|
|
+#
|
|
|
+# def do_refresh(self, request_dict, userID, response):
|
|
|
+# # return response.json(0)
|
|
|
+# type = request_dict.get('type', None)
|
|
|
+# month = request_dict.get('month', None)
|
|
|
+# if not type or not month:
|
|
|
+# return response.json(444, 'type')
|
|
|
+# else:
|
|
|
+# type = int(type)
|
|
|
+# now_time = int(time.time())
|
|
|
+# month = int(month)
|
|
|
+# uaf_qs = UserAppFrequencyModel.objects.filter(user__userID=userID)
|
|
|
+#
|
|
|
+# if not uaf_qs.exists():
|
|
|
+# user = Device_User.objects.filter(userID=userID)[0]
|
|
|
+# data = {
|
|
|
+# 'user': user,
|
|
|
+# 'type': type,
|
|
|
+# 'data_time': month,
|
|
|
+# 'add_time': now_time,
|
|
|
+# 'update_time': now_time,
|
|
|
+# }
|
|
|
+# UserAppFrequencyModel.objects.create(**data)
|
|
|
+# return response.json(0)
|
|
|
+# else:
|
|
|
+# updateMonth = time.strftime('%m', time.localtime(month))
|
|
|
+# uaf = uaf_qs.values('id', 'type', 'data_time')[0]
|
|
|
+# dbMonth = time.strftime('%m', time.localtime(int(uaf['data_time'])))
|
|
|
+# print('update month is ' + updateMonth)
|
|
|
+# print('db month is ' + dbMonth)
|
|
|
+# if updateMonth == dbMonth:
|
|
|
+# UserAppFrequencyModel.objects.filter(id=uaf['id']).update(type=type)
|
|
|
+# return response.json(0)
|
|
|
+# elif updateMonth > dbMonth:
|
|
|
+# user = Device_User.objects.filter(userID=userID)[0]
|
|
|
+# data = {
|
|
|
+# 'user': user,
|
|
|
+# 'type': type,
|
|
|
+# 'data_time': month,
|
|
|
+# 'add_time': now_time,
|
|
|
+# 'update_time': now_time,
|
|
|
+# }
|
|
|
+# UserAppFrequencyModel.objects.create(**data)
|
|
|
+# return response.json(0)
|
|
|
+# else:
|
|
|
+# return response.json(444, 'month')
|
|
|
|
|
|
|
|
|
class loginCodeView(View):
|