diff --git a/src/controller/asset/views.py b/src/controller/asset/views.py index ed08365..0f32894 100644 --- a/src/controller/asset/views.py +++ b/src/controller/asset/views.py @@ -11,6 +11,7 @@ from controller.asset import parsers class HostViews(parsers.HostParse, ListCreateViewSet): model = assetModel.Host fields = assetField.HostFields + filter_fields = (("public_ip", "contains"), ("private_ip", "contains"), ("tags", "")) def __init__(self): self.init_parse() @@ -32,6 +33,7 @@ class HostDetailViews(parsers.HostParse, DetailViewSet): class MySQLInstanceViews(parsers.DatabaseServerParse, ListCreateViewSet): model = assetModel.MySQLInstance fields = assetField.MySQLInstanceFields + filter_fields = (("name", "icontains"), ("host", "icontains"), ("manage", ""), ("tags", "")) def __init__(self): self.init_parse() @@ -71,6 +73,7 @@ class MySQLInstanceDetail(parsers.DatabaseServerParse, DetailViewSet): class RedisInstanceViews(parsers.DatabaseServerParse, ListCreateViewSet): model = assetModel.RedisInstance fields = assetField.RedisInstanceFields + filter_fields = (("name", "icontains"), ("host", "icontains"), ("manage", ""), ("tags", "")) def __init__(self): self.init_parse() @@ -105,6 +108,7 @@ class RedisInstanceDetail(parsers.DatabaseServerParse, DetailViewSet): class NginxInstanceViews(parsers.MiddlewareParse, ListCreateViewSet): model = assetModel.NginxInstance fields = assetField.NginxInstanceFields + filter_fields = (("host", "icontains"), ("manage", ""), ("url", "icontains"), ("tags", "")) def __init__(self): self.init_parse() @@ -134,6 +138,7 @@ class CDNViews(ListCreateViewSet): model = assetModel.CDN fields = assetField.CDNFields uniq_fields = ("domain",) + filter_fields = (("domain", "icontains"), ("tags", ""),) def __init__(self): self.request_parse = reqparse.RequestParser() diff --git a/src/controller/project/views.py b/src/controller/project/views.py index 3ac13e0..b3b19de 100644 --- a/src/controller/project/views.py +++ b/src/controller/project/views.py @@ -13,6 +13,7 @@ class ProjectViews(ListMixin, CreateMixin): model = Project paging = False fields = fields.ProjectFields + filter_fields = (("name", ""), ("fork", ""), ("ops_ip", ""), ("domain", "icontains"), ("tags", "")) class ProjectDetailViews(DetailViewSet): @@ -24,6 +25,7 @@ class ChannelViews(parsers.ChannelParse, ListCreateViewSet): model = Channel fields = fields.ChannelFields uniq_fields = (("spid", "project_id"),) + filter_fields = (("name", ""), ("spid", ""), ("tags", "")) def __init__(self): self.init_parse() @@ -49,6 +51,7 @@ class ServerViews(parsers.ServerParse, ListCreateViewSet): fields = fields.ServerFields uniq_fields = (("num", "channel_id"),) relation_fields = (("host_id", assetModel.Host, ""), ("channel_id", Channel, True)) + filter_fields = (("num", ""), ("spid", ""), ("tags", "")) def __init__(self): self.init_parse() diff --git a/src/models/asset/models.py b/src/models/asset/models.py index 5a19a19..dc53731 100644 --- a/src/models/asset/models.py +++ b/src/models/asset/models.py @@ -97,6 +97,7 @@ class NginxInstance(Middleware): class CDN(DocumentBase): """cdn域名""" + meta = {'collection': 'cdn'} domain = mongo.StringField(max_length=256, required=True) # cdn域名 manage = mongo.StringField(max_length=128, default="") data = mongo.DictField(default=dict)