HEX
Server: Apache/2.4.52 (Ubuntu)
System: Linux spn-python 5.15.0-89-generic #99-Ubuntu SMP Mon Oct 30 20:42:41 UTC 2023 x86_64
User: arjun (1000)
PHP: 8.1.2-1ubuntu2.20
Disabled: NONE
Upload Files
File: //proc/thread-self/root/home/arjun/projects/buyercall/buyercall/blueprints/contacts/serializers.py
from marshmallow import fields

from buyercall.blueprints.partnership.models import PartnershipAccount
from buyercall.extensions import ma
from buyercall.blueprints.contacts.models import ContactTags, Contact


class ContactTagSchema(ma.SQLAlchemyAutoSchema):
    class Meta:
        model = ContactTags
        exclude = ['id', 'is_active', 'tag_type']


class ContactSchema(ma.SQLAlchemyAutoSchema):
    primaryTag = fields.String(attribute='bdc_status')
    partnership_account_id = ma.Method('get_partnership_account_id')
    intentScore = fields.String(attribute='get_intent_state')
    manualStatus = fields.String(attribute='status')
    secondaryTags = ma.Method('get_secondary_tags')
    updatedOn = fields.String(attribute='updated_on')
    name = fields.String(attribute='name')

    class Meta:
        exclude = ['id', 'agent_assigned', 'agent_id', 'api_token_id', 'bdc_status', 'api_source', 'caller_id',
                   'form_count', 'phone_source', 'status', 'updated_on', "created_on"]
        model = Contact

    def get_partnership_account_id(self, obj):
        return str(PartnershipAccount.get_sid_from_id(obj.partnership_account_id))

    def get_secondary_tags(self, obj):
        return obj.get_secondary_tags()