优化代码

dependabot/npm_and_yarn/fir_admin/dns-packet-1.3.4
nineven 4 years ago
parent af21dd2129
commit 7a4e73fc2b
  1. 2
      fir_ser/api/utils/app/supersignutils.py
  2. 4
      fir_ser/api/utils/baseutils.py
  3. 7
      fir_ser/api/views/domain.py
  4. 2
      fir_ser/api/views/login.py
  5. 2
      fir_ser/dumpdata.json

@ -221,7 +221,7 @@ def get_redirect_server_domain(request, user_obj=None, app_domain_name=None):
elif app_domain_name and len(app_domain_name) > 3: elif app_domain_name and len(app_domain_name) > 3:
domain_name = app_domain_name domain_name = app_domain_name
else: else:
is_https, domain_name = get_user_default_domain_name(get_min_default_domain_cname_obj()) is_https, domain_name = get_user_default_domain_name(get_min_default_domain_cname_obj(True))
protocol = 'http' protocol = 'http'
if is_https: if is_https:
protocol = 'https' protocol = 'https'

@ -149,6 +149,6 @@ def get_user_default_domain_name(domain_cname_obj):
return None, None return None, None
def get_min_default_domain_cname_obj(): def get_min_default_domain_cname_obj(is_system=True):
return min(DomainCnameInfo.objects.annotate(Count('userdomaininfo')).filter(is_enable=True, is_system=True), return min(DomainCnameInfo.objects.annotate(Count('userdomaininfo')).filter(is_enable=True, is_system=is_system),
key=lambda x: x.userdomaininfo__count) key=lambda x: x.userdomaininfo__count)

@ -6,7 +6,7 @@
from rest_framework.views import APIView from rest_framework.views import APIView
from api.utils.baseutils import is_valid_domain, get_cname_from_domain, get_user_domain_name from api.utils.baseutils import is_valid_domain, get_cname_from_domain, get_user_domain_name, get_min_default_domain_cname_obj
from api.utils.response import BaseResponse from api.utils.response import BaseResponse
from api.utils.auth import ExpiringTokenAuthentication from api.utils.auth import ExpiringTokenAuthentication
from rest_framework.response import Response from rest_framework.response import Response
@ -57,10 +57,7 @@ class DomainCnameView(APIView):
res.data = {'cname_domain': user_domian_obj.cname_id.domain_record} res.data = {'cname_domain': user_domian_obj.cname_id.domain_record}
else: else:
UserDomainInfo.objects.filter(**get_domain_filter(request), is_enable=False).delete() UserDomainInfo.objects.filter(**get_domain_filter(request), is_enable=False).delete()
min_domain_cname_info_obj = min( min_domain_cname_info_obj = get_min_default_domain_cname_obj(False)
DomainCnameInfo.objects.annotate(Count('userdomaininfo')).filter(is_enable=True,
is_system=False),
key=lambda x: x.userdomaininfo__count)
if min_domain_cname_info_obj: if min_domain_cname_info_obj:
res.data = {'cname_domain': min_domain_cname_info_obj.domain_record} res.data = {'cname_domain': min_domain_cname_info_obj.domain_record}
data_dict = { data_dict = {

@ -341,7 +341,7 @@ class RegistView(APIView):
"username": random_username, "username": random_username,
"password": password, "password": password,
"first_name": random_username[:8], "first_name": random_username[:8],
"default_domain_name": get_min_default_domain_cname_obj() "default_domain_name": get_min_default_domain_cname_obj(True)
} }
if is_valid_email(username): if is_valid_email(username):

@ -36,7 +36,7 @@
"description": "100k_times", "description": "100k_times",
"price": 200000, "price": 200000,
"package_size": 100000, "package_size": 100000,
"download_count_gift": 3000, "download_count_gift": 8000,
"is_enable": true, "is_enable": true,
"updated_time": "2021-03-29T18:28:31.942" "updated_time": "2021-03-29T18:28:31.942"
} }

Loading…
Cancel
Save