Skip to content

Commit

Permalink
fix(backend): 修复单据过滤问题 #6941
Browse files Browse the repository at this point in the history
  • Loading branch information
iSecloud committed Sep 13, 2024
1 parent 5c40cd0 commit ab6dc0f
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 13 deletions.
9 changes: 8 additions & 1 deletion dbm-ui/backend/ticket/filters.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,14 @@ class TicketListFilter(filters.FilterSet):

class Meta:
model = Ticket
fields = ["remark", "cluster"]
fields = {
"id": ["exact", "in"],
"bk_biz_id": ["exact"],
"ticket_type": ["exact", "in"],
"status": ["exact", "in"],
"create_at": ["gte", "lte"],
"creator": ["exact"],
}

def filter_cluster(self, queryset, name, value):
clusters = Cluster.objects.filter(immute_domain__icontains=value).values_list("id", flat=True)
Expand Down
17 changes: 5 additions & 12 deletions dbm-ui/backend/ticket/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
)
from backend.ticket.contexts import TicketContext
from backend.ticket.exceptions import TicketDuplicationException
from backend.ticket.filters import TicketListFilter
from backend.ticket.flow_manager.manager import TicketFlowManager
from backend.ticket.handler import TicketHandler
from backend.ticket.models import ClusterOperateRecord, InstanceOperateRecord, Ticket, TicketFlowsConfig, Todo
Expand Down Expand Up @@ -89,15 +90,7 @@ class TicketViewSet(viewsets.AuditedModelViewSet):

queryset = Ticket.objects.all()
serializer_class = TicketSerializer
# filter_class = TicketListFilter
filter_fields = {
"id": ["exact", "in"],
"bk_biz_id": ["exact"],
"ticket_type": ["exact", "in"],
"status": ["exact", "in"],
"create_at": ["gte", "lte"],
"creator": ["exact"],
}
filter_class = TicketListFilter

def _get_custom_permissions(self):
# 创建单据,关联单据类型的动作
Expand Down Expand Up @@ -275,7 +268,7 @@ def list(self, request, *args, **kwargs):
auto_schema=PaginatedResponseSwaggerAutoSchema,
tags=[TICKET_TAG],
)
@action(methods=["GET"], detail=False, serializer_class=ListTicketStatusSerializer, filter_fields=None)
@action(methods=["GET"], detail=False, serializer_class=ListTicketStatusSerializer, filter_class=None)
def list_ticket_status(self, request, *args, **kwargs):
ticket_ids = self.params_validate(self.get_serializer_class())["ticket_ids"].split(",")
ticket_status_map = {ticket.id: ticket.status for ticket in Ticket.objects.filter(id__in=ticket_ids)}
Expand Down Expand Up @@ -352,7 +345,7 @@ def revoke_flow(self, request, pk):
responses={status.HTTP_200_OK: TicketTypeResponseSLZ(many=True)},
tags=[TICKET_TAG],
)
@action(methods=["GET"], detail=False, filter_fields=None, pagination_class=None, serializer_class=TicketTypeSLZ)
@action(methods=["GET"], detail=False, filter_class=None, pagination_class=None, serializer_class=TicketTypeSLZ)
def flow_types(self, request, *args, **kwargs):
is_apply = self.params_validate(self.get_serializer_class())["is_apply"]
ticket_type_list = []
Expand Down Expand Up @@ -556,7 +549,7 @@ def get_instance_operate_records(self, request, *args, **kwargs):
methods=["GET"],
detail=False,
serializer_class=QueryTicketFlowDescribeSerializer,
filter_fields=None,
filter_class=None,
pagination_class=None,
)
@Permission.decorator_external_permission_field(
Expand Down

0 comments on commit ab6dc0f

Please sign in to comment.