|
@@ -2,6 +2,7 @@ import base64
|
|
import datetime
|
|
import datetime
|
|
import logging
|
|
import logging
|
|
import random
|
|
import random
|
|
|
|
+import threading
|
|
import time
|
|
import time
|
|
import traceback
|
|
import traceback
|
|
from io import BytesIO
|
|
from io import BytesIO
|
|
@@ -28,9 +29,10 @@ from Ansjer.config import AuthCode_Expire, SERVER_DOMAIN, TUTK_PUSH_DOMAIN, \
|
|
LOGGER, CONFIG_US
|
|
LOGGER, CONFIG_US
|
|
from Ansjer.config import BASE_DIR, CONFIG_EUR, CONFIG_INFO, SERVER_DOMAIN_EUR, AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY
|
|
from Ansjer.config import BASE_DIR, CONFIG_EUR, CONFIG_INFO, SERVER_DOMAIN_EUR, AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY
|
|
from Controller.CheckUserData import DataValid, date_handler, RandomStr
|
|
from Controller.CheckUserData import DataValid, date_handler, RandomStr
|
|
|
|
+from Controller.UserDevice.UserSubscriptionController import UserSubscriptionControllerView
|
|
from Model.models import Device_User, Role, UidPushModel, UserOauth2Model, UserExModel, Device_Info, UidSetModel, \
|
|
from Model.models import Device_User, Role, UidPushModel, UserOauth2Model, UserExModel, Device_Info, UidSetModel, \
|
|
UserAppFrequencyModel, CountryIPModel, CountryModel, UidChannelSetModel, Order_Model, UID_Bucket, Unused_Uid_Meal, \
|
|
UserAppFrequencyModel, CountryIPModel, CountryModel, UidChannelSetModel, Order_Model, UID_Bucket, Unused_Uid_Meal, \
|
|
- GatewayPush, CountryLanguageModel, LanguageModel, VodBucketModel, LogModel
|
|
|
|
|
|
+ GatewayPush, CountryLanguageModel, LanguageModel, VodBucketModel, LogModel, UserEmailSubscriptions
|
|
from Object.AWS.AmazonS3Util import AmazonS3Util
|
|
from Object.AWS.AmazonS3Util import AmazonS3Util
|
|
from Object.AWS.SesClassObject import SesClassObject
|
|
from Object.AWS.SesClassObject import SesClassObject
|
|
from Object.AliSmsObject import AliSmsObject
|
|
from Object.AliSmsObject import AliSmsObject
|
|
@@ -1200,6 +1202,8 @@ class v3registerView(TemplateView):
|
|
unique = request_dict.get('unique', None)
|
|
unique = request_dict.get('unique', None)
|
|
number = request_dict.get('number', None)
|
|
number = request_dict.get('number', None)
|
|
region_status = request_dict.get('region_status', None)
|
|
region_status = request_dict.get('region_status', None)
|
|
|
|
+ email_scription = request_dict.get('email_scription', None)
|
|
|
|
+ push_scription = request_dict.get('push_scription', None)
|
|
|
|
|
|
if unique:
|
|
if unique:
|
|
delete_local_account(unique)
|
|
delete_local_account(unique)
|
|
@@ -1247,13 +1251,14 @@ class v3registerView(TemplateView):
|
|
return response.json(444, 'identifyingCode')
|
|
return response.json(444, 'identifyingCode')
|
|
|
|
|
|
if phone is not None:
|
|
if phone is not None:
|
|
- return self.do_phone_register(phone, password, authcode, number, region_status, response)
|
|
|
|
|
|
+ return self.do_phone_register(phone, password, authcode, number, region_status, response, push_scription)
|
|
elif email is not None:
|
|
elif email is not None:
|
|
- return self.do_email_register(email, password, authcode, number, region_status, response)
|
|
|
|
|
|
+ return self.do_email_register(email, password, authcode, number, region_status, response,
|
|
|
|
+ email_scription, push_scription)
|
|
else:
|
|
else:
|
|
return response.json(444, 'phone or email')
|
|
return response.json(444, 'phone or email')
|
|
|
|
|
|
- def do_phone_register(self, phone, password, authcode, number, region_status, response):
|
|
|
|
|
|
+ def do_phone_register(self, phone, password, authcode, number, region_status, response, push_scription):
|
|
data_valid = DataValid()
|
|
data_valid = DataValid()
|
|
if data_valid.mobile_validate(phone) is not True:
|
|
if data_valid.mobile_validate(phone) is not True:
|
|
return response.json(100)
|
|
return response.json(100)
|
|
@@ -1272,12 +1277,13 @@ class v3registerView(TemplateView):
|
|
if phone_qs.exists():
|
|
if phone_qs.exists():
|
|
return response.json(101)
|
|
return response.json(101)
|
|
try:
|
|
try:
|
|
|
|
+ userID = CommonService.getUserID(μs=False, setOTAID=True)
|
|
create_data = {
|
|
create_data = {
|
|
"username": phone,
|
|
"username": phone,
|
|
"NickName": phone,
|
|
"NickName": phone,
|
|
"phone": phone,
|
|
"phone": phone,
|
|
"password": make_password(password),
|
|
"password": make_password(password),
|
|
- "userID": CommonService.getUserID(μs=False, setOTAID=True),
|
|
|
|
|
|
+ "userID": userID,
|
|
"is_active": True,
|
|
"is_active": True,
|
|
"user_isValid": True,
|
|
"user_isValid": True,
|
|
"region_status": region_status
|
|
"region_status": region_status
|
|
@@ -1285,6 +1291,10 @@ class v3registerView(TemplateView):
|
|
if number:
|
|
if number:
|
|
create_data["region_country"] = number
|
|
create_data["region_country"] = number
|
|
Device_User.objects.create(**create_data)
|
|
Device_User.objects.create(**create_data)
|
|
|
|
+ if push_scription:
|
|
|
|
+ UserEmailSubscriptions.objects.create(phone=phone, user_id=userID, push_sub_status=1)
|
|
|
|
+ else:
|
|
|
|
+ UserEmailSubscriptions.objects.create(phone=phone, user_id=userID, push_sub_status=0)
|
|
|
|
|
|
except Exception as e:
|
|
except Exception as e:
|
|
errorInfo = traceback.format_exc()
|
|
errorInfo = traceback.format_exc()
|
|
@@ -1323,7 +1333,8 @@ class v3registerView(TemplateView):
|
|
res['phone'] = user_list[0]["phone"] if user_list[0]["phone"] is not None else ''
|
|
res['phone'] = user_list[0]["phone"] if user_list[0]["phone"] is not None else ''
|
|
return response.json(0, res)
|
|
return response.json(0, res)
|
|
|
|
|
|
- def do_email_register(self, email, password, authcode, number, region_status, response):
|
|
|
|
|
|
+ def do_email_register(self, email, password, authcode, number, region_status, response, email_scription,
|
|
|
|
+ push_scription):
|
|
data_valid = DataValid()
|
|
data_valid = DataValid()
|
|
if data_valid.email_validate(email) is not True:
|
|
if data_valid.email_validate(email) is not True:
|
|
return response.json(105)
|
|
return response.json(105)
|
|
@@ -1343,12 +1354,13 @@ class v3registerView(TemplateView):
|
|
if email_qs.exists():
|
|
if email_qs.exists():
|
|
return response.json(103)
|
|
return response.json(103)
|
|
try:
|
|
try:
|
|
|
|
+ userID = CommonService.getUserID(μs=False, setOTAID=True)
|
|
create_data = {
|
|
create_data = {
|
|
"username": email,
|
|
"username": email,
|
|
"NickName": email,
|
|
"NickName": email,
|
|
"userEmail": email,
|
|
"userEmail": email,
|
|
"password": make_password(password),
|
|
"password": make_password(password),
|
|
- "userID": CommonService.getUserID(μs=False, setOTAID=True),
|
|
|
|
|
|
+ "userID": userID,
|
|
"is_active": True,
|
|
"is_active": True,
|
|
"user_isValid": True,
|
|
"user_isValid": True,
|
|
"region_status": region_status
|
|
"region_status": region_status
|
|
@@ -1356,6 +1368,18 @@ class v3registerView(TemplateView):
|
|
if number:
|
|
if number:
|
|
create_data["region_country"] = number
|
|
create_data["region_country"] = number
|
|
Device_User.objects.create(**create_data)
|
|
Device_User.objects.create(**create_data)
|
|
|
|
+ if push_scription:
|
|
|
|
+ UserEmailSubscriptions.objects.create(user_id=userID, email=email, push_sub_status=1)
|
|
|
|
+ else:
|
|
|
|
+ UserEmailSubscriptions.objects.create(user_id=userID, email=email, push_sub_status=0)
|
|
|
|
+ if email_scription:
|
|
|
|
+ subscribers = {
|
|
|
|
+ "userEmail": email,
|
|
|
|
+ "region_country": number
|
|
|
|
+ }
|
|
|
|
+ subscription_thread = threading.Thread(target=UserSubscriptionControllerView.subscription,
|
|
|
|
+ args=(subscribers,))
|
|
|
|
+ subscription_thread.start()
|
|
|
|
|
|
except Exception as e:
|
|
except Exception as e:
|
|
errorInfo = traceback.format_exc()
|
|
errorInfo = traceback.format_exc()
|
|
@@ -3570,6 +3594,8 @@ class Image_Code_RegisterView(TemplateView):
|
|
region_status = request_dict.get('region_status', None)
|
|
region_status = request_dict.get('region_status', None)
|
|
lang = request_dict.get('lang', None)
|
|
lang = request_dict.get('lang', None)
|
|
response = ResponseObject(lang)
|
|
response = ResponseObject(lang)
|
|
|
|
+ email_scription = request_dict.get('email_scription', None)
|
|
|
|
+ push_scription = request_dict.get('push_scription', None)
|
|
|
|
|
|
if not all([userEmail, password, lang, imageCodeId, valid_code]):
|
|
if not all([userEmail, password, lang, imageCodeId, valid_code]):
|
|
return response.json(444)
|
|
return response.json(444)
|
|
@@ -3638,12 +3664,13 @@ class Image_Code_RegisterView(TemplateView):
|
|
return response.json(103)
|
|
return response.json(103)
|
|
|
|
|
|
# 创建用户
|
|
# 创建用户
|
|
|
|
+ userID = CommonService.getUserID(μs=False, setOTAID=True)
|
|
create_data = {
|
|
create_data = {
|
|
"username": username,
|
|
"username": username,
|
|
"NickName": username,
|
|
"NickName": username,
|
|
"userEmail": userEmail,
|
|
"userEmail": userEmail,
|
|
"password": make_password(password),
|
|
"password": make_password(password),
|
|
- "userID": CommonService.getUserID(μs=False, setOTAID=True),
|
|
|
|
|
|
+ "userID": userID,
|
|
"is_active": True,
|
|
"is_active": True,
|
|
"user_isValid": True,
|
|
"user_isValid": True,
|
|
"region_status": region_status
|
|
"region_status": region_status
|
|
@@ -3651,6 +3678,18 @@ class Image_Code_RegisterView(TemplateView):
|
|
if number:
|
|
if number:
|
|
create_data["region_country"] = number
|
|
create_data["region_country"] = number
|
|
Device_User.objects.create(**create_data)
|
|
Device_User.objects.create(**create_data)
|
|
|
|
+ if push_scription:
|
|
|
|
+ UserEmailSubscriptions.objects.create(email=userEmail, user_id=userID, push_sub_status=1)
|
|
|
|
+ else:
|
|
|
|
+ UserEmailSubscriptions.objects.create(email=userEmail, user_id=userID, push_sub_status=0)
|
|
|
|
+ if email_scription:
|
|
|
|
+ subscribers = {
|
|
|
|
+ "userEmail": userEmail,
|
|
|
|
+ "region_country": number
|
|
|
|
+ }
|
|
|
|
+ subscription_thread = threading.Thread(target=UserSubscriptionControllerView.subscription,
|
|
|
|
+ args=(subscribers,))
|
|
|
|
+ subscription_thread.start()
|
|
return self.do_login(email_qs, response)
|
|
return self.do_login(email_qs, response)
|
|
|
|
|
|
@staticmethod
|
|
@staticmethod
|