class TimeLineListSerializer_admin(serializers.ModelSerializer): investor = UserCommenSerializer() trader = UserCommenSerializer() proj = ProjSimpleSerializer() transationStatu = serializers.SerializerMethodField() supportor = serializers.SerializerMethodField() class Meta: model = timeline # fields = '__all__' exclude = ('is_deleted', 'deleteduser', 'deletedtime', 'lastmodifyuser', 'lastmodifytime', 'createuser', 'createdtime') def get_supportor(self, obj): user = obj.proj.supportUser if user.is_deleted: return None return UserCommenSerializer(user).data def get_transationStatu(self, obj): qs = obj.timeline_transationStatus.all().filter(is_deleted=False, isActive=True) if qs.exists(): return TimeLineStatuSerializer(qs.first()).data return None
class WorkReportProjInfoSerializer(serializers.ModelSerializer): proj = ProjSimpleSerializer() class Meta: model = WorkReportProjInfo exclude = ('deleteduser', 'deletedtime', 'datasource', 'is_deleted', 'createuser')
class OrgBDBlackSerializer(serializers.ModelSerializer): org = OrgCommonSerializer() proj = ProjSimpleSerializer() createuser = UserCommenSerializer() class Meta: model = OrgBDBlack exclude = ('deleteduser', 'deletedtime', 'datasource', 'is_deleted')
class MeetingBDSerializer(serializers.ModelSerializer): org = OrgCommonSerializer() proj = ProjSimpleSerializer() usertitle = titleTypeSerializer() manager = UserCommenSerializer() attachmenturl = serializers.SerializerMethodField() class Meta: model = MeetingBD exclude = ('deleteduser', 'deletedtime', 'datasource', 'is_deleted', 'createuser') def get_attachmenturl(self, obj): if obj.attachmentbucket and obj.attachment: return getUrlWithBucketAndKey(obj.attachmentbucket, obj.attachment) else: return None
class OrgBDSerializer(serializers.ModelSerializer): org = OrgCommonSerializer() proj = ProjSimpleSerializer() BDComments = serializers.SerializerMethodField() usertitle = titleTypeSerializer() bd_status = BDStatusSerializer() manager = UserCommenSerializer() wechat = serializers.SerializerMethodField() email = serializers.SerializerMethodField() useinfo = serializers.SerializerMethodField() createuser = UserCommenSerializer() makeUser = serializers.SerializerMethodField() class Meta: model = OrgBD exclude = ('deleteduser', 'deletedtime', 'datasource', 'is_deleted') def get_BDComments(self, obj): qs = obj.OrgBD_comments.filter(is_deleted=False) if qs.exists(): return OrgBDCommentsSerializer(qs, many=True).data return None def get_wechat(self, obj): if obj.bduser: return obj.bduser.wechat return None def get_email(self, obj): if obj.bduser: return obj.bduser.email return None def get_useinfo(self, obj): if obj.bduser: return UserCommenSerializer(obj.bduser).data return None def get_makeUser(self, obj): if obj.proj: if obj.proj.makeUser: return obj.proj.makeUser_id return None
class OrgBDSerializer(serializers.ModelSerializer): org = OrgCommonSerializer() proj = ProjSimpleSerializer() BDComments = serializers.SerializerMethodField() usertitle = titleTypeSerializer() cardurl = serializers.SerializerMethodField() userreamrk = serializers.SerializerMethodField() userattachment = serializers.SerializerMethodField() manager = UserSimpleSerializer() userinfo = serializers.SerializerMethodField() createuser = UserSimpleSerializer() class Meta: model = OrgBD exclude = ('deleteduser', 'deletedtime', 'datasource', 'is_deleted', 'usermobile') def get_BDComments(self, obj): qs = obj.OrgBD_comments.filter(is_deleted=False) if qs.exists(): return OrgBDCommentsSerializer(qs, many=True).data return None def get_cardurl(self, obj): if obj.bduser: if obj.bduser.cardKey: return getUrlWithBucketAndKey('image', obj.bduser.cardKey) return None def get_userreamrk(self, obj): if obj.bduser: return UserRemarkSimpleSerializer( obj.bduser.user_remarks.all().filter(is_deleted=False), many=True).data return None def get_userattachment(self, obj): if obj.bduser: return UserAttachmentSerializer( obj.bduser.user_userAttachments.all().filter(is_deleted=False), many=True).data return None def get_userinfo(self, obj): user_id = self.context.get("user_id") info = { 'email': None, 'mobile': None, 'wechat': None, 'tags': None, 'photourl': None, 'cardurl': None } if obj.bduser: tags = obj.bduser.tags.filter(tag_usertags__is_deleted=False) if tags.exists(): info['tags'] = tagSerializer(tags, many=True).data if obj.bduser.photoKey: info['photourl'] = getUrlWithBucketAndKey( 'image', obj.bduser.photoKey) if obj.bduser.photoKey: info['cardurl'] = getUrlWithBucketAndKey( 'image', obj.bduser.cardKey) if user_id: if obj.manager.id == user_id or is_userInvestor( obj.bduser, user_id): info['email'] = obj.bduser.email info['mobile'] = obj.bduser.mobile info['wechat'] = obj.bduser.wechat return info