api.v1.serializers.account_serializers package

api.v1.serializers.account_serializers package containing serializers for the core.models.Account data.

class api.v1.serializers.account_serializers.AccountSerializer(*args, **kwargs)[source]

Bases: BaseAccountSerializer

The standard serializer for a core.models.Account.

Includes a nested serializer for the related field mailboxes.

_declared_fields = {'mailboxes': BaseMailboxSerializer(many=True, read_only=True):     id = BigIntegerField(label='ID', read_only=True)     is_favorite = BooleanField(label='Favorite status', required=False)     is_healthy = BooleanField(allow_null=True, label='Health status', read_only=True)     last_error = CharField(read_only=True, style={'base_template': 'textarea.html'})     last_error_occurred_at = DateTimeField(allow_null=True, label='Time of last error occurrence', read_only=True)     created = DateTimeField(label='Time of creation', read_only=True)     updated = DateTimeField(label='Time of last update', read_only=True)     name = CharField(read_only=True)     type = ChoiceField(choices=[('INBOX', 'Inbox'), ('OUTBOX', 'Outbox'), ('SENT', 'Sent'), ('JUNK', 'Junk'), ('DRAFTS', 'Drafts'), ('TRASH', 'Trash'), ('', '')], read_only=True)     save_attachments = BooleanField(help_text='Whether the attachments from the emails in this mailbox will be saved.', required=False)     save_to_eml = BooleanField(help_text='Whether the emails in this mailbox will be stored in .eml files.', label='Save as .eml', required=False)     account = PrimaryKeyRelatedField(read_only=True), 'user': HiddenField(default=CurrentUserDefault())}
mailboxes

The mailboxes of the account are serialized by core.models.MailboxSerializers.BaseMailboxSerializer.BaseMailboxSerializer.

class api.v1.serializers.account_serializers.BaseAccountSerializer(*args, **kwargs)[source]

Bases: ModelSerializer

The base serializer for core.models.Account.

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

user

The core.models.Account.Account.user field is included but hidden.

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 Account

fields = '__all__'

Include all fields.

read_only_fields: Final[list[str]] = ['is_healthy', 'last_error', 'last_error_occurred_at', 'created', 'updated']

The core.models.Account.Account.is_healthy, core.models.Account.Account.created and core.models.Account.Account.updated fields are read-only.

extra_kwargs = {'password': {'write_only': True}}

The core.models.Account.Account.password field is set to write-only for security reasons.

_declared_fields = {'user': HiddenField(default=CurrentUserDefault())}
validate(attrs)[source]

Include full model-side validation to allow testing of account on submission.

Parameters:

attrs (dict[str, Any]) – The attributes on the serializer.

Return type:

dict[str, Any]

Returns:

The same attributes.

Raises:

serializers.ValidationError – If the validation fails.

Submodules