feat: sflog filter
This commit is contained in:
parent
d285e09c5c
commit
a6167294f7
|
@ -0,0 +1,14 @@
|
||||||
|
from django_filters import rest_framework as filters
|
||||||
|
from apps.wpm.models import SfLog
|
||||||
|
['mgroup', 'shift', 'team', 'leader', 'team__belong_dept']
|
||||||
|
class SfLogFilter(filters.FilterSet):
|
||||||
|
class Meta:
|
||||||
|
model = SfLog
|
||||||
|
fields = {
|
||||||
|
"mgroup": ["exact"],
|
||||||
|
"shift": ["exact"],
|
||||||
|
"team": ["exact"],
|
||||||
|
"leader": ["exact"],
|
||||||
|
"team__belong_dept": ["exact"],
|
||||||
|
"end_time": ["day", "month", "year"]
|
||||||
|
}
|
|
@ -9,6 +9,7 @@ from rest_framework.mixins import DestroyModelMixin, UpdateModelMixin, ListModel
|
||||||
from apps.utils.viewsets import CustomGenericViewSet, CustomModelViewSet
|
from apps.utils.viewsets import CustomGenericViewSet, CustomModelViewSet
|
||||||
from apps.wpm.models import SfLog, StLog, StSfLog
|
from apps.wpm.models import SfLog, StLog, StSfLog
|
||||||
from apps.wpm.serializers import SfLogSerializer, StLogSerializer, StSfLogSerializer
|
from apps.wpm.serializers import SfLogSerializer, StLogSerializer, StSfLogSerializer
|
||||||
|
from apps.wpm.filters import SfLogFilter
|
||||||
|
|
||||||
# Create your views here.
|
# Create your views here.
|
||||||
class StLogViewSet(ListModelMixin, CustomGenericViewSet):
|
class StLogViewSet(ListModelMixin, CustomGenericViewSet):
|
||||||
|
@ -35,7 +36,7 @@ class SfLogViewSet(UpdateModelMixin, ListModelMixin, DestroyModelMixin, CustomGe
|
||||||
queryset = SfLog.objects.all()
|
queryset = SfLog.objects.all()
|
||||||
serializer_class = SfLogSerializer
|
serializer_class = SfLogSerializer
|
||||||
select_related_fields = ['mgroup', 'shift', 'team', 'leader']
|
select_related_fields = ['mgroup', 'shift', 'team', 'leader']
|
||||||
filterset_fields = ['mgroup', 'shift', 'team', 'leader', 'team__belong_dept']
|
filterset_class = SfLogFilter
|
||||||
search_fields = ['note']
|
search_fields = ['note']
|
||||||
ordering = ['-start_time']
|
ordering = ['-start_time']
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue