Esempio n. 1
0
class ContactSerializer(serializers.ModelSerializer):
    created_by = UserSerializer()
    company = CompanySerializer()
    teams = TeamsSerializer(read_only=True, many=True)
    assigned_to = UserSerializer(read_only=True, many=True)
    address = BillingAddressSerializer(read_only=True)
    get_team_users = UserSerializer(read_only=True, many=True)
    get_team_and_assigned_users = UserSerializer(read_only=True, many=True)
    get_assigned_users_not_in_teams = UserSerializer(read_only=True, many=True)

    class Meta:
        model = Contact
        fields = (
            'id',
            "first_name",
            "last_name",
            "email",
            "phone",
            "address",
            "description",
            "assigned_to",
            "created_by",
            "created_on",
            "is_active",
            "teams",
            "company",
            "created_on_arrow",
            "get_team_users",
            "get_team_and_assigned_users",
            "get_assigned_users_not_in_teams",
        )
class CaseSerializer(serializers.ModelSerializer):
    account = AccountSerializer(read_only=True, many=True)
    contacts = ContactSerializer(read_only=True, many=True)
    assigned_to = UserSerializer(read_only=True, many=True)
    created_by = UserSerializer(read_only=True)
    teams = TeamsSerializer(read_only=True, many=True)
    company = CompanySerializer()
    get_team_users = UserSerializer(read_only=True, many=True)
    get_team_and_assigned_users = UserSerializer(read_only=True, many=True)
    get_assigned_users_not_in_teams = UserSerializer(read_only=True, many=True)

    class Meta:
        model = Case
        fields = (
            "id",
            "name",
            "status",
            "priority",
            "case_type",
            "account",
            "contacts",
            "closed_on",
            "description",
            "assigned_to",
            "created_by",
            "created_on",
            "is_active",
            "teams",
            "company",
            "get_team_users",
            "get_team_and_assigned_users",
            "get_assigned_users_not_in_teams",
            "created_on_arrow",
        )
Esempio n. 3
0
class CaseSerializer(serializers.ModelSerializer):
    account = AccountSerializer(read_only=True, many=True)
    contacts = ContactSerializer(read_only=True, many=True)
    assigned_to = UserSerializer(read_only=True, many=True)
    created_by = UserSerializer(read_only=True)
    teams = TeamsSerializer(read_only=True, many=True)
    company = CompanySerializer()
    get_team_users = UserSerializer(read_only=True, many=True)
    get_team_and_assigned_users = UserSerializer(read_only=True, many=True)
    get_assigned_users_not_in_teams = UserSerializer(read_only=True, many=True)

    class Meta:
        model = Case
        fields = (
            'id',
            'name',
            'status',
            'priority',
            'case_type',
            'account',
            'contacts',
            'closed_on',
            'description',
            'assigned_to',
            'created_by',
            'created_on',
            'is_active',
            'teams',
            'company',
            'get_team_users',
            'get_team_and_assigned_users',
            "get_assigned_users_not_in_teams",
            "created_on_arrow",
        )
Esempio n. 4
0
class EventSerializer(serializers.ModelSerializer):
    created_by = UserSerializer()
    assigned_to = UserSerializer(read_only=True, many=True)
    contacts = ContactSerializer(read_only=True, many=True)
    teams = TeamsSerializer(read_only=True, many=True)
    company = CompanySerializer()
    event_attachment = AttachmentsSerializer(read_only=True, many=True)
    event_comments = CommentSerializer(read_only=True, many=True)

    class Meta:
        model = Event
        fields = (
            "id",
            "name",
            "event_type",
            "status",
            "is_active",
            "disabled",
            "start_date",
            "start_time",
            "end_date",
            "end_time",
            "description",
            "date_of_meeting",
            "created_by",
            "created_on",
            "contacts",
            "teams",
            "assigned_to",
            "event_attachment",
            "event_comments",
            "company",
        )
Esempio n. 5
0
class TaskSerializer(serializers.ModelSerializer):
    created_by = UserSerializer()
    assigned_to = UserSerializer(read_only=True, many=True)
    contacts = ContactSerializer(read_only=True, many=True)
    teams = TeamsSerializer(read_only=True, many=True)
    company = CompanySerializer()
    task_attachment = AttachmentsSerializer(read_only=True, many=True)
    task_comments = CommentSerializer(read_only=True, many=True)

    class Meta:
        model = Task
        fields = (
            "id",
            "title",
            "status",
            "priority",
            "due_date",
            "account",
            "created_by",
            "created_on",
            "contacts",
            "teams",
            "assigned_to",
            "task_attachment",
            "task_comments",
            "company",
        )
Esempio n. 6
0
class BlockedEmailAddSerailizer(serializers.ModelSerializer):
    created_by = UserSerializer()
    company = CompanySerializer()
    email = serializers.EmailField

    def __init__(self, *args, **kwargs):
        request_obj = kwargs.pop("request_obj", None)
        super(BlockedEmailAddSerailizer, self).__init__(*args, **kwargs)
        self.fields["created_by"].required = False
        self.fields["company"].required = False
        self.company = request_obj.company

    def validate_email(self, email):
        if self.instance:
            if (
                BlockedEmail.objects.filter(email=email, company=self.company)
                .exclude(id=self.instance.id)
                .exists()
            ):
                raise serializers.ValidationError("Email already exists")
        else:
            if BlockedEmail.objects.filter(email=email, company=self.company).exists():
                raise serializers.ValidationError("email already exists")
        return email

    class Meta:
        model = BlockedEmail
        fields = ("id", "email", "created_on", "created_by", "company")
Esempio n. 7
0
class BlockedDomainSerailizer(serializers.ModelSerializer):
    created_by = UserSerializer()
    company = CompanySerializer()

    class Meta:
        model = BlockedDomain
        fields = ("id", "domain", "created_on", "created_by", "company")
Esempio n. 8
0
class BlockedDomainAddSerailizer(serializers.ModelSerializer):
    created_by = UserSerializer()
    company = CompanySerializer()

    def __init__(self, *args, **kwargs):
        request_obj = kwargs.pop("request_obj", None)
        super(BlockedDomainAddSerailizer, self).__init__(*args, **kwargs)
        self.fields["created_by"].required = False
        self.fields["company"].required = False
        self.company = request_obj.company

    def validate_domain(self, domain):
        domain_regex = "^([a-z0-9]+(-[a-z0-9]+)*\.)+[a-z]{2,}$"
        if re.match(domain_regex, domain) is None:
            raise serializers.ValidationError("Enter a valid domain.")
        if self.instance:
            if BlockedDomain.objects.filter(domain__iexact=domain,
                                            company=self.company).exclude(
                                                id=self.instance.id).exists():
                raise serializers.ValidationError(
                    "Domain already exists with this name")
        else:
            if BlockedDomain.objects.filter(domain__iexact=domain,
                                            company=self.company).exists():
                raise serializers.ValidationError(
                    "Domain already exists with this name")
        return domain

    class Meta:
        model = BlockedDomain
        fields = ("id", "domain", "created_on", "created_by", "company")
Esempio n. 9
0
class BlockedEmailSerailizer(serializers.ModelSerializer):
    created_by = UserSerializer()
    company = CompanySerializer()
    email = serializers.EmailField

    class Meta:
        model = BlockedEmail
        fields = ("id", "email", "created_on", "created_by", "company")
Esempio n. 10
0
class TeamsSerializer(serializers.ModelSerializer):
    users = UserSerializer(read_only=True, many=True)
    created_by = UserSerializer()
    company = CompanySerializer()

    class Meta:
        model = Teams
        fields = ("id", "name", "description", "users", "created_on",
                  "created_by", "company", "created_on_arrow")
Esempio n. 11
0
class ContactEmailCampaignSerailizer(serializers.ModelSerializer):
    created_by = UserSerializer()
    company = CompanySerializer()

    def __init__(self, *args, **kwargs):
        request_obj = kwargs.pop("request_obj", None)
        super(ContactEmailCampaignSerailizer, self).__init__(*args, **kwargs)
        self.fields["name"].required = False
        self.fields["created_by"].required = False
        self.fields["company"].required = False

    class Meta:
        model = ContactEmailCampaign
        fields = ("id", "name", "last_name", "email", "created_on",
                  "created_by", "company")
Esempio n. 12
0
class AccountSerializer(serializers.ModelSerializer):
    created_by = UserSerializer()
    lead = LeadSerializer()
    company = CompanySerializer()
    tags = TagsSerailizer(read_only=True, many=True)
    assigned_to = UserSerializer(read_only=True, many=True)
    contacts = ContactSerializer(read_only=True, many=True)
    teams = TeamsSerializer(read_only=True, many=True)

    class Meta:
        model = Account
        # fields = ‘__all__’
        fields = ('id', "name", "email", "phone", "industry",
                  "billing_address_line", "billing_street", "billing_city",
                  "billing_state", "billing_postcode", "billing_country",
                  "website", "description", "created_by", "created_on",
                  "is_active", "tags", "status", "lead", "contact_name",
                  "contacts", "assigned_to", "teams", "company")
Esempio n. 13
0
class LeadSerializer(serializers.ModelSerializer):
    assigned_to = UserSerializer(read_only=True, many=True)
    created_by = UserSerializer()
    tags = TagsSerializer(read_only=True, many=True)
    lead_attachment = AttachmentsSerializer(read_only=True, many=True)
    teams = TeamsSerializer(read_only=True, many=True)
    company = CompanySerializer()
    lead_comments = LeadCommentSerializer(read_only=True, many=True)

    class Meta:
        model = Lead
        # fields = ‘__all__’
        fields = (
            "id",
            "title",
            "first_name",
            "last_name",
            "phone",
            "email",
            "status",
            "source",
            "address_line",
            "street",
            "city",
            "state",
            "postcode",
            "country",
            "website",
            "description",
            "lead_attachment",
            "lead_comments",
            "assigned_to",
            "account_name",
            "opportunity_amount",
            "created_by",
            "created_on",
            "is_active",
            "enquery_type",
            "tags",
            "created_from_site",
            "teams",
            "company",
        )
Esempio n. 14
0
class OpportunitySerializer(serializers.ModelSerializer):
    account = AccountSerializer()
    closed_by = UserSerializer()
    created_by = UserSerializer()
    company = CompanySerializer()
    tags = TagsSerializer(read_only=True, many=True)
    assigned_to = UserSerializer(read_only=True, many=True)
    contacts = ContactSerializer(read_only=True, many=True)
    teams = TeamsSerializer(read_only=True, many=True)
    opportunity_attachment = AttachmentsSerializer(read_only=True, many=True)

    class Meta:
        model = Opportunity
        # fields = ‘__all__’
        fields = (
            "id",
            "name",
            "stage",
            "currency",
            "amount",
            "lead_source",
            "probability",
            "contacts",
            "closed_by",
            "closed_on",
            "description",
            "assigned_to",
            "created_by",
            "created_on",
            "is_active",
            "tags",
            "opportunity_attachment",
            "teams",
            "company",
            "created_on_arrow",
            "account",
            # "get_team_users",
            # "get_team_and_assigned_users",
            # "get_assigned_users_not_in_teams",
        )
Esempio n. 15
0
class InvoiceSerailizer(serializers.ModelSerializer):
    from_address = BillingAddressSerializer()
    to_address = BillingAddressSerializer()
    created_by = UserSerializer()
    company = CompanySerializer()
    teams = TeamsSerializer(read_only=True, many=True)
    assigned_to = UserSerializer(read_only=True, many=True)

    class Meta:
        model = Invoice
        fields = (
            "id",
            "invoice_title",
            "invoice_number",
            "status",
            "due_date",
            "name",
            "email",
            "phone",
            "from_address",
            "to_address",
            "created_on",
            "created_by",
            "currency",
            "quantity",
            "rate",
            "tax",
            "total_amount",
            "amount_due",
            "amount_paid",
            "is_email_sent",
            "details",
            "teams",
            "assigned_to",
            "company",
        )