From 17af3412c63e354843ee6e64f8fd58de368cb755 Mon Sep 17 00:00:00 2001 From: Matthias Kestenholz Date: Tue, 10 Sep 2024 15:38:59 +0200 Subject: [PATCH] Amend the CHANGELOG --- CHANGELOG.rst | 3 +++ form_designer/models.py | 13 ++++++++----- 2 files changed, 11 insertions(+), 5 deletions(-) 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 = [ (