feat: mtm goal 接口
This commit is contained in:
parent
14539b89ba
commit
e709b28d25
|
@ -1,5 +1,5 @@
|
||||||
from apps.utils.serializers import CustomModelSerializer
|
from apps.utils.serializers import CustomModelSerializer
|
||||||
from apps.mtm.models import Shift, Material, Mgroup, Team
|
from apps.mtm.models import Shift, Material, Mgroup, Team, Goal
|
||||||
from apps.utils.constants import EXCLUDE_FIELDS
|
from apps.utils.constants import EXCLUDE_FIELDS
|
||||||
from rest_framework import serializers
|
from rest_framework import serializers
|
||||||
from apps.system.models import Dept
|
from apps.system.models import Dept
|
||||||
|
@ -31,4 +31,11 @@ class TeamSerializer(CustomModelSerializer):
|
||||||
class Meta:
|
class Meta:
|
||||||
model = Team
|
model = Team
|
||||||
fields = '__all__'
|
fields = '__all__'
|
||||||
|
read_only_fields = EXCLUDE_FIELDS
|
||||||
|
|
||||||
|
|
||||||
|
class GoalSerializer(CustomModelSerializer):
|
||||||
|
class Meta:
|
||||||
|
model = Goal
|
||||||
|
fields = '__all__'
|
||||||
read_only_fields = EXCLUDE_FIELDS
|
read_only_fields = EXCLUDE_FIELDS
|
|
@ -1,7 +1,7 @@
|
||||||
from django.urls import path, include
|
from django.urls import path, include
|
||||||
from rest_framework.routers import DefaultRouter
|
from rest_framework.routers import DefaultRouter
|
||||||
|
|
||||||
from apps.mtm.views import MgroupViewSet, ShiftViewSet, TeamViewSet, MaterialViewSet
|
from apps.mtm.views import MgroupViewSet, ShiftViewSet, TeamViewSet, MaterialViewSet, GoalViewSet
|
||||||
|
|
||||||
API_BASE_URL = 'api/mtm/'
|
API_BASE_URL = 'api/mtm/'
|
||||||
HTML_BASE_URL = 'mtm/'
|
HTML_BASE_URL = 'mtm/'
|
||||||
|
@ -11,6 +11,7 @@ router.register('mgroup', MgroupViewSet, basename='mgroup')
|
||||||
router.register('team', TeamViewSet, basename='team')
|
router.register('team', TeamViewSet, basename='team')
|
||||||
router.register('material', MaterialViewSet, basename='material')
|
router.register('material', MaterialViewSet, basename='material')
|
||||||
router.register('shift', ShiftViewSet, basename='shift')
|
router.register('shift', ShiftViewSet, basename='shift')
|
||||||
|
router.register('goal', GoalViewSet, basename='goal')
|
||||||
|
|
||||||
urlpatterns = [
|
urlpatterns = [
|
||||||
path(API_BASE_URL, include(router.urls)),
|
path(API_BASE_URL, include(router.urls)),
|
||||||
|
|
|
@ -2,8 +2,8 @@ from django.shortcuts import render
|
||||||
from rest_framework.mixins import ListModelMixin
|
from rest_framework.mixins import ListModelMixin
|
||||||
|
|
||||||
from apps.utils.viewsets import CustomGenericViewSet, CustomModelViewSet
|
from apps.utils.viewsets import CustomGenericViewSet, CustomModelViewSet
|
||||||
from apps.mtm.models import Material, Mgroup, Shift, Team
|
from apps.mtm.models import Material, Mgroup, Shift, Team, Goal
|
||||||
from apps.mtm.serializers import MaterialSerializer, MgroupSerializer, ShiftSerializer, TeamSerializer
|
from apps.mtm.serializers import MaterialSerializer, MgroupSerializer, ShiftSerializer, TeamSerializer, GoalSerializer
|
||||||
|
|
||||||
# Create your views here.
|
# Create your views here.
|
||||||
class MaterialViewSet(CustomModelViewSet):
|
class MaterialViewSet(CustomModelViewSet):
|
||||||
|
@ -55,4 +55,17 @@ class TeamViewSet(CustomModelViewSet):
|
||||||
serializer_class = TeamSerializer
|
serializer_class = TeamSerializer
|
||||||
select_related_fields = ['belong_dept', 'leader']
|
select_related_fields = ['belong_dept', 'leader']
|
||||||
filterset_fields = ['belong_dept']
|
filterset_fields = ['belong_dept']
|
||||||
|
search_fields = ['name']
|
||||||
|
|
||||||
|
|
||||||
|
class GoalViewSet(CustomModelViewSet):
|
||||||
|
"""
|
||||||
|
list: 目标
|
||||||
|
|
||||||
|
目标
|
||||||
|
"""
|
||||||
|
queryset = Goal.objects.all()
|
||||||
|
serializer_class = GoalSerializer
|
||||||
|
select_related_fields = ['mgroup', 'product', 'team', 'goal_cate']
|
||||||
|
filterset_fields = ['mgroup', 'product', 'team', 'goal_cate', 'year']
|
||||||
search_fields = ['name']
|
search_fields = ['name']
|
Loading…
Reference in New Issue