예제 #1
0
class ProjDetailSerializer_user_withsecretinfo(serializers.ModelSerializer):
    tags = serializers.SerializerMethodField()
    service = serializers.SerializerMethodField()
    industries = serializers.SerializerMethodField()
    country = countrySerializer()
    transactionType = serializers.SerializerMethodField()
    finance = serializers.SerializerMethodField()
    attachment = serializers.SerializerMethodField()
    supportUser = UserCommenSerializer()
    takeUser = UserCommenSerializer()
    makeUser = UserCommenSerializer()
    linkpdfurl = serializers.SerializerMethodField()

    class Meta:
        model = project
        exclude = ('createuser', 'lastmodifyuser', 'deleteduser',
                   'deletedtime', 'datasource', 'isSendEmail')
        depth = 1

    def get_tags(self, obj):
        qs = obj.tags.filter(tag_projects__is_deleted=False)
        if qs.exists():
            return tagSerializer(qs, many=True).data
        return None

    def get_industries(self, obj):
        qs = obj.project_industries.filter(is_deleted=False)
        if qs.exists():
            return ProjIndustrySerializer(qs, many=True).data
        return None

    def get_transactionType(self, obj):
        qs = obj.transactionType.filter(
            transactionType_projects__is_deleted=False)
        if qs.exists():
            return transactionTypeSerializer(qs, many=True).data
        return None

    def get_finance(self, obj):
        usertrader = obj.proj_finances.filter(is_deleted=False)
        if usertrader.exists():
            return FinanceSerializer(usertrader, many=True).data
        return None

    def get_attachment(self, obj):
        usertrader = obj.proj_attachment.filter(is_deleted=False)
        if usertrader.exists():
            return ProjAttachmentSerializer(usertrader, many=True).data
        return None

    def get_service(self, obj):
        qs = obj.service.filter(service_projects__is_deleted=False)
        if qs.exists():
            return serviceSerializer(qs, many=True).data
        return None

    def get_linkpdfurl(self, obj):
        if obj.linkpdfkey and obj.ismarketplace:
            return getUrlWithBucketAndKey('file', obj.linkpdfkey)
        return None
예제 #2
0
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
예제 #3
0
class FavoriteSerializer(serializers.ModelSerializer):
    user = UserCommenSerializer()
    trader = UserCommenSerializer()
    proj = ProjCommonSerializer()

    class Meta:
        model = favoriteProject
        fields = '__all__'
예제 #4
0
 def get_manager(self, obj):
     qs = obj.ProjectBD_managers.filter(is_deleted=False)
     if qs.exists():
         return {
             'main': UserCommenSerializer(obj.manager).data,
             'normal': ProjectBDManagersSerializer(qs, many=True).data
         }
     return {'main': UserCommenSerializer(obj.manager).data, 'normal': None}
예제 #5
0
class ProjSerializer(serializers.ModelSerializer):
    supportUser = UserCommenSerializer()
    takeUser = UserCommenSerializer()
    makeUser = UserCommenSerializer()
    proj_finances = ProjFinanceSerializer(many=True)
    proj_attachment = ProjAttachmentSerializer(many=True)

    class Meta:
        model = project
        exclude = ('isSendEmail', 'datasource', 'realname')
        depth = 1
예제 #6
0
class ProjectBDSerializer(serializers.ModelSerializer):
    BDComments = serializers.SerializerMethodField()
    location = orgAreaSerializer()
    usertitle = titleTypeSerializer()
    bd_status = BDStatusSerializer()
    manager = serializers.SerializerMethodField()
    contractors = UserCommenSerializer()
    financeCurrency = currencyTypeSerializer()

    class Meta:
        model = ProjectBD
        exclude = ('deleteduser', 'deletedtime', 'datasource', 'is_deleted')

    def get_manager(self, obj):
        qs = obj.ProjectBD_managers.filter(is_deleted=False)
        if qs.exists():
            return {
                'main': UserCommenSerializer(obj.manager).data,
                'normal': ProjectBDManagersSerializer(qs, many=True).data
            }
        return {'main': UserCommenSerializer(obj.manager).data, 'normal': None}

    def get_BDComments(self, obj):
        user_id = self.context.get('user_id')
        manage = self.context.get('manage')
        indGroup_id = self.context.get('indGroup_id')
        if manage or is_projBDManager(
                user_id, obj) or (obj.indGroup
                                  and obj.indGroup.id == indGroup_id):
            qs = obj.ProjectBD_comments.filter(
                is_deleted=False).order_by('-createdtime')
            if qs.exists():
                return ProjectBDCommentsSerializer(qs, many=True).data
        return None
예제 #7
0
class OrgBDBlackSerializer(serializers.ModelSerializer):
    org = OrgCommonSerializer()
    proj = ProjSimpleSerializer()
    createuser = UserCommenSerializer()

    class Meta:
        model = OrgBDBlack
        exclude = ('deleteduser', 'deletedtime', 'datasource', 'is_deleted')
예제 #8
0
class ProjSerializer(serializers.ModelSerializer):
    supportUser = UserCommenSerializer()
    PM = UserCommenSerializer()
    projTraders = serializers.SerializerMethodField()
    proj_finances = ProjFinanceSerializer(many=True)
    proj_attachment = ProjAttachmentSerializer(many=True)
    lastProject = ProjSimpleSerializer()

    class Meta:
        model = project
        exclude = ('isSendEmail', 'datasource', 'realname')
        depth = 1

    def get_projTraders(self, obj):
        qs = obj.proj_traders.filter(is_deleted=False, user__isnull=False)
        if qs.exists():
            return ProjTradersSerializer(qs, many=True).data
        return None
예제 #9
0
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
예제 #10
0
class ScheduleSerializer(serializers.ModelSerializer):
    user = UserInfoSerializer()
    createuser = UserCommenSerializer()
    country = countrySerializer()
    proj = ProjCommonSerializer()
    location = orgAreaSerializer()
    meeting = WebEXMeetingSerializer()

    class Meta:
        model = schedule
        exclude = ('deleteduser', 'datasource', 'is_deleted', 'deletedtime')
예제 #11
0
class ScheduleSerializer(serializers.ModelSerializer):
    user = UserInfoSerializer()
    createuser = UserCommenSerializer()
    country = countrySerializer()
    proj = ProjCommonSerializer()
    location = orgAreaSerializer()

    class Meta:
        model = schedule
        fields = ('id', 'comments', 'scheduledtime', 'user', 'address',
                  'projtitle', 'proj', 'createuser', 'createdtime', 'country',
                  'location')
예제 #12
0
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
예제 #13
0
class ProjectBDSerializer(serializers.ModelSerializer):
    BDComments = serializers.SerializerMethodField()
    location = orgAreaSerializer()
    usertitle = titleTypeSerializer()
    bd_status = BDStatusSerializer()
    manager = UserCommenSerializer()

    class Meta:
        model = ProjectBD
        exclude = ('deleteduser', 'deletedtime', 'datasource', 'is_deleted',
                   'createuser')

    def get_BDComments(self, obj):
        qs = obj.ProjectBD_comments.filter(is_deleted=False)
        if qs.exists():
            return ProjectBDCommentsSerializer(qs, many=True).data
        return None
예제 #14
0
 def get_useinfo(self, obj):
     if obj.bduser:
         return UserCommenSerializer(obj.bduser).data
     return None
예제 #15
0
class ProjDetailSerializer_all(serializers.ModelSerializer):
    tags = serializers.SerializerMethodField()
    service = serializers.SerializerMethodField()
    industries = serializers.SerializerMethodField()
    transactionType = serializers.SerializerMethodField()
    finance = serializers.SerializerMethodField()
    attachment = serializers.SerializerMethodField()
    country = countryWithContinentSerializer()
    supportUser = UserCommenSerializer()
    PM = UserCommenSerializer()
    createuser = UserCommenSerializer()
    projTraders = serializers.SerializerMethodField()
    linkpdfurl = serializers.SerializerMethodField()
    lastProject = ProjSimpleSerializer()
    currency = currencyTypeSerializer()
    projstatus = ProjectStatusSerializer()

    class Meta:
        model = project
        exclude = (
            'lastmodifyuser',
            'deleteduser',
            'deletedtime',
            'datasource',
            'isSendEmail',
        )

    def get_service(self, obj):
        qs = obj.service.filter(service_projects__is_deleted=False)
        if qs.exists():
            return serviceSerializer(qs, many=True).data
        return None

    def get_projTraders(self, obj):
        qs = obj.proj_traders.filter(is_deleted=False, user__isnull=False)
        if qs.exists():
            return ProjTradersSerializer(qs, many=True).data
        return None

    def get_tags(self, obj):
        qs = obj.tags.filter(tag_projects__is_deleted=False)
        if qs.exists():
            return tagSerializer(qs, many=True).data
        return None

    def get_industries(self, obj):
        qs = obj.project_industries.filter(is_deleted=False)
        if qs.exists():
            return ProjIndustrySerializer(qs, many=True).data
        return None

    def get_transactionType(self, obj):
        qs = obj.transactionType.filter(
            transactionType_projects__is_deleted=False)
        if qs.exists():
            return transactionTypeSerializer(qs, many=True).data
        return None

    def get_finance(self, obj):
        usertrader = obj.proj_finances.filter(is_deleted=False)
        if usertrader.exists():
            return FinanceSerializer(usertrader, many=True).data
        return None

    def get_attachment(self, obj):
        usertrader = obj.proj_attachment.filter(is_deleted=False)
        if usertrader.exists():
            return ProjAttachmentSerializer(usertrader, many=True).data
        return None

    def get_linkpdfurl(self, obj):
        return None
예제 #16
0
class ProjTradersSerializer(serializers.ModelSerializer):
    user = UserCommenSerializer()

    class Meta:
        model = projTraders
        fields = '__all__'
예제 #17
0
class ProjectBDManagersSerializer(serializers.ModelSerializer):
    manager = UserCommenSerializer()

    class Meta:
        model = ProjectBDManagers
        fields = ('manager', 'id', 'createdtime', 'projectBD', 'createuser')
예제 #18
0
 def get_supportor(self, obj):
     user = obj.proj.supportUser
     if user.is_deleted:
         return None
     return UserCommenSerializer(user).data