mex.extractors.consent_mailer package¶
Submodules¶
mex.extractors.consent_mailer.extract module¶
- mex.extractors.consent_mailer.extract.extract_consents_for_persons(person_items: list[MergedPerson]) list[MergedConsent] ¶
Get consents for ldap persons.
- mex.extractors.consent_mailer.extract.extract_ldap_persons(extracted_primary_source_ldap_identifier: MergedPrimarySourceIdentifier) list[MergedPerson] ¶
Get all persons from primary source LDAP.
mex.extractors.consent_mailer.filter module¶
- mex.extractors.consent_mailer.filter.filter_persons_without_consent(person_items: list[MergedPerson], consent_items: list[MergedConsent]) list[MergedPerson] ¶
Filter person items for having no consent.
- Parameters:
person_items – list of persons
consent_items – list of consents
- Returns:
list of filtered persons without consent.
mex.extractors.consent_mailer.main module¶
mex.extractors.consent_mailer.settings module¶
- class mex.extractors.consent_mailer.settings.ConsentMailerSettings(*, mailpit_api_url: str = 'localhost:8025', mailpit_api_user: SecretStr = SecretStr('**********'), mailpit_api_password: SecretStr = SecretStr('**********'), schedule: str | None = None, smtp_server: str = 'localhost:1025', template_path: AssetsPath = AssetsPath('mailings'))¶
Bases:
BaseModel
Settings definition class for the consent mailer.
- mailpit_api_password: SecretStr¶
- mailpit_api_url: str¶
- mailpit_api_user: SecretStr¶
- model_computed_fields: ClassVar[Dict[str, ComputedFieldInfo]] = {}¶
A dictionary of computed field names and their corresponding ComputedFieldInfo objects.
- model_config: ClassVar[ConfigDict] = {'extra': 'ignore', 'populate_by_name': True, 'str_max_length': 100000, 'str_min_length': 1, 'str_strip_whitespace': True, 'use_enum_values': True, 'validate_assignment': True, 'validate_default': True}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- model_fields: ClassVar[Dict[str, FieldInfo]] = {'mailpit_api_password': FieldInfo(annotation=SecretStr, required=False, default=SecretStr('**********'), description='The password used for Basic HTTP auth against the mailpit api. USED FOR TESTS ONLY!'), 'mailpit_api_url': FieldInfo(annotation=str, required=False, default='localhost:8025', description='The url to the api endpoint for mailpit. USED FOR TESTS ONLY!'), 'mailpit_api_user': FieldInfo(annotation=SecretStr, required=False, default=SecretStr('**********'), description='The username used for Basic HTTP auth against the mailpit api. USED FOR TESTS ONLY!'), 'schedule': FieldInfo(annotation=Union[str, NoneType], required=False, default=None, description='A valid cron string defining when to run the consent mailer'), 'smtp_server': FieldInfo(annotation=str, required=False, default='localhost:1025', description='Address and port (<address>:<port>) of the SMTP server to use for the consent mailer.'), 'template_path': FieldInfo(annotation=AssetsPath, required=False, default=AssetsPath("mailings"), description='Path to the directory with the jinja template file containing the email body template, absolute path or relative to `assets_dir`.')}¶
Metadata about the fields defined on the model, mapping of field names to [FieldInfo][pydantic.fields.FieldInfo] objects.
This replaces Model.__fields__ from Pydantic V1.
- schedule: str | None¶
- smtp_server: str¶
- template_path: AssetsPath¶
mex.extractors.consent_mailer.transform module¶
- mex.extractors.consent_mailer.transform._generate_email_body(person: MergedPerson, template: Template, template_args: dict[str, Any]) str ¶
Generates the consent email body.
- Parameters:
person – person to send email to
template – email template
template_args – dict with args inserted into template
- Returns:
email body string
- mex.extractors.consent_mailer.transform.transform_person_to_sendable_email(person: MergedPerson) EmailMessage | None ¶
Transforms a person to an email requesting consent.
Following properties are used: - the subject defined in ‘settings.consent_mailer.template_path / “config.json”’ - the person email addresses (ending on @rki.de) as target addresses (if none is present, this function will return none) - the template defined in ‘settings.consent_mailer.template_path / “consent.html”’ to generate the email body (text) for each person
- Parameters:
person (MergedPerson) – The person that needs to be transformed into a sendable
email. (consent)
- Returns:
The email message for the defined person or None if the person doesn’t have a @rki.de email address.
- Return type:
EmailMessage | None