core.models.EmailCorrespondent module

Module with the EmailCorrespondent model class.

class core.models.EmailCorrespondent.EmailCorrespondent(*args, **kwargs)[source]

Bases: ExportModelOperationsMixin('email_correspondent'), URLMixin, TimestampModelMixin, Model

Database model for connecting emails and their correspondents.

BASENAME = 'email'

Direct user to email endpoints.

DELETE_NOTICE = 'This will delete the records of this email and all its attachments but not its correspondents.'
DELETE_NOTICE_PLURAL = 'This will delete the records of these emails and all their attachments but not their correspondents.'
email

The email correspondent was mentioned in. Unique together with correspondent and mention.

correspondent

The correspondent mentioned in email. Unique together with email and mention.

mention

The mention of correspondent in email. Unique together with email and correspondent.

exception DoesNotExist

Bases: ObjectDoesNotExist

exception MultipleObjectsReturned

Bases: MultipleObjectsReturned

_meta = <Options for EmailCorrespondent>
correspondent_id
created

The datetime the model instance was created. Is set automatically.

email_id
get_mention_display(*, field=<django.db.models.fields.CharField: mention>)
get_next_by_created(*, field=<django.db.models.fields.DateTimeField: created>, is_next=True, **kwargs)
get_next_by_updated(*, field=<django.db.models.fields.DateTimeField: updated>, is_next=True, **kwargs)
get_previous_by_created(*, field=<django.db.models.fields.DateTimeField: created>, is_next=False, **kwargs)
get_previous_by_updated(*, field=<django.db.models.fields.DateTimeField: updated>, is_next=False, **kwargs)
id

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

objects = <django.db.models.manager.Manager object>
updated

The datetime the model instance entry was last updated. Is set automatically.

__str__()[source]

Returns a string representation of the model data.

Return type:

str

Returns:

The string representation of the emailcorrespondent, using email, correspondent and mention.

classmethod create_from_header(header, header_name, email)[source]

Prepares a list core.models.EmailCorrespondent from an email header.

Parameters:
  • header (str) – The header to parse the malinglistdata from.

  • header_name (str) – The name of the header, the mention type of the correspondent.

  • email (Email) – The email for the new emailcorrespondent.

Return type:

set[EmailCorrespondent] | None

Returns:

The list of core.models.EmailCorrespondent instances with data from the header. If the correspondent already exists in the db. None if the correspondent could not be parsed.

Raises:

ValueError – If the email argument is not in the db.