93 lines
3.2 KiB
Python
93 lines
3.2 KiB
Python
from .models import (PatentInfo, Papersecret, PatentRecord)
|
|
from apps.utils.serializers import CustomModelSerializer
|
|
from rest_framework import serializers
|
|
from django.db import transaction
|
|
from rest_framework.exceptions import ParseError
|
|
from apps.utils.constants import EXCLUDE_FIELDS
|
|
from apps.wf.serializers import TicketSimpleSerializer
|
|
|
|
class PatentInfoSerializer(CustomModelSerializer):
|
|
create_by_name = serializers.CharField(source='create_by.name', read_only=True)
|
|
belong_dept_name = serializers.CharField(source='belong_dept.name', read_only=True)
|
|
ticket_ = TicketSimpleSerializer(source='ticket', read_only=True)
|
|
class Meta:
|
|
model = PatentInfo
|
|
fields = '__all__'
|
|
read_only_fields = EXCLUDE_FIELDS
|
|
|
|
|
|
class PaperSeSerializer(CustomModelSerializer):
|
|
create_by_name = serializers.CharField(source='create_by.name', read_only=True)
|
|
belong_dept_name = serializers.CharField(source='belong_dept.name', read_only=True)
|
|
ticket_ = TicketSimpleSerializer(source='ticket', read_only=True)
|
|
class Meta:
|
|
model = Papersecret
|
|
fields = '__all__'
|
|
read_only_fields = EXCLUDE_FIELDS
|
|
|
|
|
|
class PatentRecordSerializer(CustomModelSerializer):
|
|
create_by_name = serializers.CharField(source='create_by.name', read_only=True)
|
|
belong_dept_name = serializers.CharField(source='belong_dept.name', read_only=True)
|
|
patent_name = serializers.CharField(source='patent.name', read_only=True, label="专利名称")
|
|
patent_type = serializers.CharField(source='patent.type', read_only=True, label="专利类型")
|
|
class Meta:
|
|
model = PatentRecord
|
|
fields = '__all__'
|
|
read_only_fields = EXCLUDE_FIELDS
|
|
|
|
|
|
# class PlatformSerializer(serializers.ModelSerializer):
|
|
# class Meta:
|
|
# model = Platform
|
|
# fields = ['id', 'name']
|
|
|
|
|
|
# class ProjectSerializer(serializers.ModelSerializer):
|
|
# class Meta:
|
|
# model = Project
|
|
# fields = ['id', 'name']
|
|
|
|
|
|
# class ProjectMemberSerializer(CustomModelSerializer):
|
|
# affiliated_platforms = serializers.PrimaryKeyRelatedField(
|
|
# many=True,
|
|
# queryset=Platform.objects.all(),
|
|
# write_only=True
|
|
# )
|
|
# affiliated_platforms_detail = PlatformSerializer(
|
|
# source='affiliated_platforms', many=True, read_only=True
|
|
# )
|
|
|
|
# affiliated_projects = serializers.PrimaryKeyRelatedField(
|
|
# many=True,
|
|
# queryset=Project.objects.all(),
|
|
# write_only=True
|
|
# )
|
|
# affiliated_projects_detail = ProjectSerializer(
|
|
# source='affiliated_projects', many=True, read_only=True
|
|
# )
|
|
# class Meta:
|
|
# model = PatentRecord
|
|
# fields = '__all__'
|
|
|
|
|
|
# class PaperRecordSerializer(CustomModelSerializer):
|
|
# class Meta:
|
|
# model = PaperRecord
|
|
# fields = '__all__'
|
|
# read_only_fields = EXCLUDE_FIELDS
|
|
|
|
|
|
# class ProjectApprovalSerializer(CustomModelSerializer):
|
|
# class Meta:
|
|
# model = ProjectApproval
|
|
# fields = '__all__'
|
|
# read_only_fields = EXCLUDE_FIELDS
|
|
|
|
|
|
# class ProjectInfoSerializer(CustomModelSerializer):
|
|
# class Meta:
|
|
# model = ProjectInfo
|
|
# fields = '__all__'
|
|
# read_only_fields = EXCLUDE_FIELDS |