fix: 修复工单申请人过滤问题 (#12957)

Co-authored-by: feng <1304903146@qq.com>
pull/12958/head
fit2bot 2024-04-08 18:56:59 +08:00 committed by GitHub
parent 5ea4bba676
commit cd19a276c9
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 5 additions and 5 deletions

View File

@ -1,9 +1,8 @@
from django.db.models import Subquery, OuterRef, Value, F, Q
from django_filters import rest_framework as filters
from django.db.models.functions import Concat
from django_filters import rest_framework as filters
from common.drf.filters import BaseFilterSet
from tickets.models import (
Ticket, TicketStep, ApplyAssetTicket,
ApplyLoginTicket, ApplyLoginAssetTicket, ApplyCommandTicket
@ -11,10 +10,10 @@ from tickets.models import (
class TicketFilter(BaseFilterSet):
applicant = filters.CharFilter(method='filter_applicant')
assignees__id = filters.UUIDFilter(method='filter_assignees_id')
relevant_asset = filters.CharFilter(method='filter_relevant_asset')
relevant_command = filters.CharFilter(method='filter_relevant_command')
applicant_username_name = filters.CharFilter(method='filter_applicant_username_name')
class Meta:
model = Ticket
@ -63,9 +62,10 @@ class TicketFilter(BaseFilterSet):
).values_list('id', flat=True)
return queryset.filter(id__in=list(command_ids))
def filter_applicant(self, queryset, name, value):
def filter_applicant_username_name(self, queryset, name, value):
return queryset.filter(
Q(applicant__username__icontains=value) | Q(applicant__name__icontains=value)
Q(applicant__name__icontains=value) |
Q(applicant__username__icontains=value)
)