优化代码,增加域名默认数据

dependabot/npm_and_yarn/fir_admin/dns-packet-1.3.4
youngS 4 years ago
parent 10e9f80067
commit e53e0843a3
  1. 17
      fir_ser/api/models.py
  2. 4
      fir_ser/api/utils/TokenManager.py
  3. 3
      fir_ser/api/views/domain.py
  4. 170
      fir_ser/dumpdata.json

@ -5,7 +5,7 @@ from django.db import models
from django.contrib.contenttypes.models import ContentType from django.contrib.contenttypes.models import ContentType
from api.utils.app.randomstrings import make_random_uuid from api.utils.app.randomstrings import make_random_uuid
from django.contrib.auth.models import AbstractUser from django.contrib.auth.models import AbstractUser
from api.utils.TokenManager import generateAlphanumericTokenOfLength from api.utils.TokenManager import generateAlphanumericTokenOfLength, generateNumericTokenOfLength
######################################## 用户表 ######################################## ######################################## 用户表 ########################################
@ -457,11 +457,16 @@ class DomainCnameInfo(models.Model):
created_time = models.DateTimeField(auto_now_add=True, verbose_name="创建时间") created_time = models.DateTimeField(auto_now_add=True, verbose_name="创建时间")
class Meta: class Meta:
verbose_name = '分发域名信息' verbose_name = '系统分发域名配置'
verbose_name_plural = "分发域名信息" verbose_name_plural = "系统分发域名配置"
def save(self, *args, **kwargs):
if not self.domain_record or (self.domain_record and len(self.domain_record) < 26): # 最多3个启用的价格表
self.domain_record = '%s.%s' % (generateNumericTokenOfLength(24, 'abcdef'), self.domain_record)
super(DomainCnameInfo, self).save(*args, **kwargs)
def __str__(self): def __str__(self):
return "%s-%s-%s" % (self.domain_record, self.ip_address, self.is_enable) return "%s-%s-is_enable:%s-is_system:%s" % (self.domain_record, self.ip_address, self.is_enable, self.is_system)
class UserDomainInfo(models.Model): class UserDomainInfo(models.Model):
@ -473,8 +478,8 @@ class UserDomainInfo(models.Model):
created_time = models.DateTimeField(auto_now_add=True, verbose_name="创建时间") created_time = models.DateTimeField(auto_now_add=True, verbose_name="创建时间")
class Meta: class Meta:
verbose_name = '分发域名绑定' verbose_name = '用户分发域名绑定'
verbose_name_plural = "分发域名绑定" verbose_name_plural = "用户分发域名绑定"
def __str__(self): def __str__(self):
return "%s-%s-%s" % (self.user_id, self.cname_id, self.domain_name) return "%s-%s-%s" % (self.user_id, self.cname_id, self.domain_name)

@ -60,8 +60,8 @@ def generateTokenForMedium(medium):
return generateNumericTokenOfLength(6) return generateNumericTokenOfLength(6)
def generateNumericTokenOfLength(length): def generateNumericTokenOfLength(length, random_str=''):
return "".join([random.choice(string.digits) for _ in range(length)]) return "".join([random.choice(string.digits + random_str) for _ in range(length)])
def generateAlphanumericTokenOfLength(length): def generateAlphanumericTokenOfLength(length):

@ -6,7 +6,8 @@
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, get_min_default_domain_cname_obj 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

@ -6,11 +6,11 @@
"name": "1k_times", "name": "1k_times",
"title": "1k_times", "title": "1k_times",
"description": "1k_times", "description": "1k_times",
"price": 2000, "price": 2500,
"package_size": 1000, "package_size": 1000,
"download_count_gift": 100, "download_count_gift": 100,
"is_enable": true, "is_enable": true,
"updated_time": "2021-04-14T17:37:05.512" "updated_time": "2021-05-25T16:22:23.744"
} }
}, },
{ {
@ -20,11 +20,11 @@
"name": "10k_times", "name": "10k_times",
"title": "10k_times", "title": "10k_times",
"description": "10k_times", "description": "10k_times",
"price": 20000, "price": 22000,
"package_size": 10000, "package_size": 10000,
"download_count_gift": 800, "download_count_gift": 800,
"is_enable": true, "is_enable": true,
"updated_time": "2021-03-30T12:21:17.789" "updated_time": "2021-05-25T16:22:35.404"
} }
}, },
{ {
@ -38,7 +38,7 @@
"package_size": 100000, "package_size": 100000,
"download_count_gift": 8000, "download_count_gift": 8000,
"is_enable": true, "is_enable": true,
"updated_time": "2021-03-29T18:28:31.942" "updated_time": "2021-05-25T16:22:43.995"
} }
}, },
{ {
@ -49,6 +49,7 @@
"ip_address": "d.ashort.top.w.kunlunsl.com", "ip_address": "d.ashort.top.w.kunlunsl.com",
"is_enable": true, "is_enable": true,
"is_system": true, "is_system": true,
"is_https": false,
"description": "d.ashort.top \u7cfb\u7edf\u81ea\u5e26\u57df\u540d\uff0c\u672a\u5907\u6848\uff0c\u56fd\u5916\u52a0\u901f\uff0c\u7528\u4e0e\u4e0b\u8f7d\u9875\u8df3\u8f6c\u57df\u540d", "description": "d.ashort.top \u7cfb\u7edf\u81ea\u5e26\u57df\u540d\uff0c\u672a\u5907\u6848\uff0c\u56fd\u5916\u52a0\u901f\uff0c\u7528\u4e0e\u4e0b\u8f7d\u9875\u8df3\u8f6c\u57df\u540d",
"created_time": "2021-05-21T21:25:33" "created_time": "2021-05-21T21:25:33"
} }
@ -61,6 +62,7 @@
"ip_address": "d.bshort.top.w.kunlunsl.com", "ip_address": "d.bshort.top.w.kunlunsl.com",
"is_enable": true, "is_enable": true,
"is_system": true, "is_system": true,
"is_https": false,
"description": "d.bshort.top \u7cfb\u7edf\u81ea\u5e26\u57df\u540d\uff0c\u672a\u5907\u6848\uff0c\u56fd\u5916\u52a0\u901f\uff0c\u7528\u4e0e\u4e0b\u8f7d\u9875\u8df3\u8f6c\u57df\u540d", "description": "d.bshort.top \u7cfb\u7edf\u81ea\u5e26\u57df\u540d\uff0c\u672a\u5907\u6848\uff0c\u56fd\u5916\u52a0\u901f\uff0c\u7528\u4e0e\u4e0b\u8f7d\u9875\u8df3\u8f6c\u57df\u540d",
"created_time": "2021-05-21T21:25:33" "created_time": "2021-05-21T21:25:33"
} }
@ -73,6 +75,7 @@
"ip_address": "d.cshort.top.w.kunlunsl.com", "ip_address": "d.cshort.top.w.kunlunsl.com",
"is_enable": true, "is_enable": true,
"is_system": true, "is_system": true,
"is_https": false,
"description": "d.cshort.top \u7cfb\u7edf\u81ea\u5e26\u57df\u540d\uff0c\u672a\u5907\u6848\uff0c\u56fd\u5916\u52a0\u901f\uff0c\u7528\u4e0e\u4e0b\u8f7d\u9875\u8df3\u8f6c\u57df\u540d", "description": "d.cshort.top \u7cfb\u7edf\u81ea\u5e26\u57df\u540d\uff0c\u672a\u5907\u6848\uff0c\u56fd\u5916\u52a0\u901f\uff0c\u7528\u4e0e\u4e0b\u8f7d\u9875\u8df3\u8f6c\u57df\u540d",
"created_time": "2021-05-21T21:25:33" "created_time": "2021-05-21T21:25:33"
} }
@ -85,8 +88,165 @@
"ip_address": "d.eshort.top.w.kunlunsl.com", "ip_address": "d.eshort.top.w.kunlunsl.com",
"is_enable": true, "is_enable": true,
"is_system": true, "is_system": true,
"is_https": false,
"description": "d.eshort.top \u7cfb\u7edf\u81ea\u5e26\u57df\u540d\uff0c\u672a\u5907\u6848\uff0c\u56fd\u5916\u52a0\u901f\uff0c\u7528\u4e0e\u4e0b\u8f7d\u9875\u8df3\u8f6c\u57df\u540d", "description": "d.eshort.top \u7cfb\u7edf\u81ea\u5e26\u57df\u540d\uff0c\u672a\u5907\u6848\uff0c\u56fd\u5916\u52a0\u901f\uff0c\u7528\u4e0e\u4e0b\u8f7d\u9875\u8df3\u8f6c\u57df\u540d",
"created_time": "2021-05-21T21:25:33" "created_time": "2021-05-21T21:25:33"
} }
},
{
"model": "api.domaincnameinfo",
"pk": 5,
"fields": {
"domain_record": "234bfdd02542cf838cff76b9.dshort.top",
"ip_address": "47.241.30.190",
"is_enable": true,
"is_system": false,
"is_https": false,
"description": "",
"created_time": "2021-05-25T16:10:37.180"
}
},
{
"model": "api.domaincnameinfo",
"pk": 6,
"fields": {
"domain_record": "03d9108cf7caf79ba2667a94.dshort.top",
"ip_address": "47.241.30.190",
"is_enable": true,
"is_system": false,
"is_https": false,
"description": "",
"created_time": "2021-05-25T16:14:17.624"
}
},
{
"model": "api.domaincnameinfo",
"pk": 7,
"fields": {
"domain_record": "e61cc922e0227d4febfdd681.fshort.top",
"ip_address": "47.241.30.190",
"is_enable": true,
"is_system": false,
"is_https": false,
"description": "",
"created_time": "2021-05-25T16:16:17.067"
}
},
{
"model": "api.domaincnameinfo",
"pk": 8,
"fields": {
"domain_record": "93bab80713ed87897d30e4db.fshort.top",
"ip_address": "47.241.30.190",
"is_enable": true,
"is_system": false,
"is_https": false,
"description": "",
"created_time": "2021-05-25T16:16:25.248"
}
},
{
"model": "api.domaincnameinfo",
"pk": 9,
"fields": {
"domain_record": "b1cf45592f107520a29475dc.eshort.top",
"ip_address": "47.241.30.190",
"is_enable": true,
"is_system": false,
"is_https": false,
"description": "",
"created_time": "2021-05-25T16:36:38.244"
}
},
{
"model": "api.domaincnameinfo",
"pk": 10,
"fields": {
"domain_record": "a897858c4775a288f99dd55e.eshort.top",
"ip_address": "47.241.30.190",
"is_enable": true,
"is_system": false,
"is_https": false,
"description": "",
"created_time": "2021-05-25T16:36:44.967"
}
},
{
"model": "api.domaincnameinfo",
"pk": 11,
"fields": {
"domain_record": "2f717ce5b6d2ad8bc8216808.ashort.top",
"ip_address": "47.241.30.190",
"is_enable": true,
"is_system": false,
"is_https": false,
"description": "",
"created_time": "2021-05-25T16:37:38.661"
}
},
{
"model": "api.domaincnameinfo",
"pk": 12,
"fields": {
"domain_record": "051466b64caf72a2de466400.ashort.top",
"ip_address": "47.241.30.190",
"is_enable": true,
"is_system": false,
"is_https": false,
"description": "",
"created_time": "2021-05-25T16:37:43.715"
}
},
{
"model": "api.domaincnameinfo",
"pk": 13,
"fields": {
"domain_record": "eb7a92ce0b9c613f2dead7d4.bshort.top",
"ip_address": "47.241.30.190",
"is_enable": true,
"is_system": false,
"is_https": false,
"description": "",
"created_time": "2021-05-25T16:38:32.069"
}
},
{
"model": "api.domaincnameinfo",
"pk": 14,
"fields": {
"domain_record": "798c2576b649ce38bdc16eb3.bshort.top",
"ip_address": "47.241.30.190",
"is_enable": true,
"is_system": false,
"is_https": false,
"description": "",
"created_time": "2021-05-25T16:38:36.919"
}
},
{
"model": "api.domaincnameinfo",
"pk": 15,
"fields": {
"domain_record": "42ff0f107683baf335162f78.cshort.top",
"ip_address": "47.241.30.190",
"is_enable": true,
"is_system": false,
"is_https": false,
"description": "",
"created_time": "2021-05-25T16:39:18.063"
}
},
{
"model": "api.domaincnameinfo",
"pk": 16,
"fields": {
"domain_record": "8fc3c8b4cc987c235a68b347.cshort.top",
"ip_address": "47.241.30.190",
"is_enable": true,
"is_system": false,
"is_https": false,
"description": "",
"created_time": "2021-05-25T16:39:23.235"
}
} }
] ]
Loading…
Cancel
Save