api.v1.serializers.email_serializers package

api.v1.serializers.email_serializers package containing serializers for the core.models.Email data.

class api.v1.serializers.email_serializers.BaseEmailSerializer(*args, **kwargs)[source]

Bases: ModelSerializer

The base serializer for core.models.Email.

Includes all viable fields from the model. Sets all constraints that must be implemented in all serializers. Other serializers for core.models.Email should inherit from this.

class Meta[source]

Bases: object

Metadata class for the base serializer.

Contains constraints that must be implemented by all serializers. Other serializer metaclasses should inherit from this. read_only_fields and exclude must not be shortened in subclasses.

model

alias of Email

exclude: ClassVar[list[str]] = ['file_path']

Exclude the core.models.Email.Email.file_path field.

read_only_fields: Final[list[str]] = ['message_id', 'datetime', 'subject', 'plain_bodytext', 'html_bodytext', 'in_reply_to', 'references', 'datasize', 'correspondents', 'mailbox', 'headers', 'x_spam_flag', 'created', 'updated']

All fields except for core.models.Email.Email.is_favorite are read-only.

_declared_fields = {}
class api.v1.serializers.email_serializers.EmailSerializer(*args, **kwargs)[source]

Bases: BaseEmailSerializer

The standard serializer for a core.models.Email.

Includes only the most relevant model fields. Includes nested serializers for the core.models.Email.Email.replies, core.models.Email.Email.attachments`and :attr:`core.models.Email.Email.correspondents foreign key and related fields.

replies: PrimaryKeyRelatedField

The replies mails are included by id only to prevent recursion.

referenced_by: PrimaryKeyRelatedField

The referencing mails are included by id only to prevent recursion.

attachments

The attachments are serialized by eonvelope.AttachmentSerializers.BaseAttachmentSerializer.BaseAttachmentSerializer.

_declared_fields = {'attachments': BaseAttachmentSerializer(many=True, read_only=True):     id = BigIntegerField(label='ID', read_only=True)     is_favorite = BooleanField(label='Favorite status', required=False)     created = DateTimeField(label='Time of creation', read_only=True)     updated = DateTimeField(label='Time of last update', read_only=True)     file_name = CharField(label='Filename', read_only=True)     content_disposition = CharField(read_only=True)     content_id = CharField(label='Content ID', read_only=True)     content_maintype = CharField(read_only=True)     content_subtype = CharField(read_only=True)     datasize = IntegerField(read_only=True)     email = PrimaryKeyRelatedField(read_only=True), 'correspondents': SerializerMethodField(read_only=True), 'referenced_by': ManyRelatedField(child_relation=PrimaryKeyRelatedField(read_only=True), read_only=True), 'replies': ManyRelatedField(child_relation=PrimaryKeyRelatedField(read_only=True), read_only=True)}
correspondents

The emails are set from the core.models.EmailCorrespondent via get_correspondents().

class Meta[source]

Bases: Meta

Metadata class for the serializer.

exclude: ClassVar[list[str]] = ['file_path', 'headers']

Omit the other header fields.

get_correspondents(instance)[source]

Serializes the correspondents connected to the instance to be serialized.

Parameters:

instance (Email) – The instance being serialized.

Return type:

ReturnDict[str, Any]

Returns:

The serialized correspondents connected to the instance to be serialized.

class api.v1.serializers.email_serializers.FullEmailSerializer(*args, **kwargs)[source]

Bases: BaseEmailSerializer

A complete serializer for a core.models.Email.

Includes nested serializers for the core.models.Email.Email.replies, core.models.Email.Email.attachments and core.models.Email.Email.correspondents foreign key and related fields.

replies: PrimaryKeyRelatedField

The replies mails are included by id only to prevent recursion.

referenced_by: PrimaryKeyRelatedField

The referencing mails are included by id only to prevent recursion.

_declared_fields = {'attachments': BaseAttachmentSerializer(many=True, read_only=True):     id = BigIntegerField(label='ID', read_only=True)     is_favorite = BooleanField(label='Favorite status', required=False)     created = DateTimeField(label='Time of creation', read_only=True)     updated = DateTimeField(label='Time of last update', read_only=True)     file_name = CharField(label='Filename', read_only=True)     content_disposition = CharField(read_only=True)     content_id = CharField(label='Content ID', read_only=True)     content_maintype = CharField(read_only=True)     content_subtype = CharField(read_only=True)     datasize = IntegerField(read_only=True)     email = PrimaryKeyRelatedField(read_only=True), 'correspondents': SerializerMethodField(read_only=True), 'referenced_by': ManyRelatedField(child_relation=PrimaryKeyRelatedField(read_only=True), read_only=True), 'replies': ManyRelatedField(child_relation=PrimaryKeyRelatedField(read_only=True), read_only=True)}
attachments

The attachments are serialized by eonvelope.AttachmentSerializers.BaseAttachmentSerializer.BaseAttachmentSerializer.

correspondents

The emails are set from the core.models.EmailCorrespondent via get_correspondents().

get_correspondents(instance)[source]

Serializes the correspondents connected to the instance to be serialized.

Parameters:

instance (Email) – The instance being serialized.

Return type:

ReturnDict[str, Any]

Returns:

The serialized correspondents connected to the instance to be serialized.

Submodules