diff --git a/CHANGELOG.rst b/CHANGELOG.rst index c8e7422..fd9f4dd 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -4,6 +4,9 @@ Change log Next version ------------ +* Limited the email field choices to email fields only when using the send + emails to authors option. + 0.26 ---- diff --git a/form_designer/models.py b/form_designer/models.py index ae6e7a9..202a7d8 100644 --- a/form_designer/models.py +++ b/form_designer/models.py @@ -1,7 +1,6 @@ -from typing import Optional - import warnings from functools import partial +from typing import Optional from django import forms from django.conf import settings @@ -53,14 +52,18 @@ def validate_comma_separated_emails(value): for v in value.split(","): validate_email(v.strip()) -def email_field_choices(form: Optional[forms.ModelForm], required: bool=True) -> list[tuple[str, str]]: + +def email_field_choices( + form: Optional[forms.ModelForm], required: bool = True +) -> list[tuple[str, str]]: if not form or not form.instance or not form.instance.pk: return [] - email_fields = form.instance.fields.filter(type='email') - choices = [] if required else [('', '--')] + email_fields = form.instance.fields.filter(type="email") + choices = [] if required else [("", "--")] choices.extend([(_.name, _.title) for _ in email_fields]) return choices + class Form(models.Model): CONFIG_OPTIONS = [ (