From 7a4e73fc2ba9caf74c28dc76ddbb918445eee7dd Mon Sep 17 00:00:00 2001 From: nineven Date: Sun, 23 May 2021 18:17:46 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- fir_ser/api/utils/app/supersignutils.py | 2 +- fir_ser/api/utils/baseutils.py | 4 ++-- fir_ser/api/views/domain.py | 7 ++----- fir_ser/api/views/login.py | 2 +- fir_ser/dumpdata.json | 2 +- 5 files changed, 7 insertions(+), 10 deletions(-) diff --git a/fir_ser/api/utils/app/supersignutils.py b/fir_ser/api/utils/app/supersignutils.py index 39b8725..4b54453 100644 --- a/fir_ser/api/utils/app/supersignutils.py +++ b/fir_ser/api/utils/app/supersignutils.py @@ -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: domain_name = app_domain_name 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' if is_https: protocol = 'https' diff --git a/fir_ser/api/utils/baseutils.py b/fir_ser/api/utils/baseutils.py index 812f1c8..ef75bd0 100644 --- a/fir_ser/api/utils/baseutils.py +++ b/fir_ser/api/utils/baseutils.py @@ -149,6 +149,6 @@ def get_user_default_domain_name(domain_cname_obj): return None, None -def get_min_default_domain_cname_obj(): - return min(DomainCnameInfo.objects.annotate(Count('userdomaininfo')).filter(is_enable=True, is_system=True), +def get_min_default_domain_cname_obj(is_system=True): + return min(DomainCnameInfo.objects.annotate(Count('userdomaininfo')).filter(is_enable=True, is_system=is_system), key=lambda x: x.userdomaininfo__count) diff --git a/fir_ser/api/views/domain.py b/fir_ser/api/views/domain.py index 5e84a89..8b9b9b5 100644 --- a/fir_ser/api/views/domain.py +++ b/fir_ser/api/views/domain.py @@ -6,7 +6,7 @@ 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.auth import ExpiringTokenAuthentication from rest_framework.response import Response @@ -57,10 +57,7 @@ class DomainCnameView(APIView): res.data = {'cname_domain': user_domian_obj.cname_id.domain_record} else: UserDomainInfo.objects.filter(**get_domain_filter(request), is_enable=False).delete() - min_domain_cname_info_obj = min( - DomainCnameInfo.objects.annotate(Count('userdomaininfo')).filter(is_enable=True, - is_system=False), - key=lambda x: x.userdomaininfo__count) + min_domain_cname_info_obj = get_min_default_domain_cname_obj(False) if min_domain_cname_info_obj: res.data = {'cname_domain': min_domain_cname_info_obj.domain_record} data_dict = { diff --git a/fir_ser/api/views/login.py b/fir_ser/api/views/login.py index 78e66bb..a77a905 100644 --- a/fir_ser/api/views/login.py +++ b/fir_ser/api/views/login.py @@ -341,7 +341,7 @@ class RegistView(APIView): "username": random_username, "password": password, "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): diff --git a/fir_ser/dumpdata.json b/fir_ser/dumpdata.json index 2f955fb..998f6fe 100644 --- a/fir_ser/dumpdata.json +++ b/fir_ser/dumpdata.json @@ -36,7 +36,7 @@ "description": "100k_times", "price": 200000, "package_size": 100000, - "download_count_gift": 3000, + "download_count_gift": 8000, "is_enable": true, "updated_time": "2021-03-29T18:28:31.942" }