Skip to content

Commit

Permalink
Amend the CHANGELOG
Browse files Browse the repository at this point in the history
  • Loading branch information
matthiask committed Sep 10, 2024
1 parent 3d9e560 commit 17af341
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
----

Expand Down
13 changes: 8 additions & 5 deletions form_designer/models.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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 = [
(
Expand Down

0 comments on commit 17af341

Please sign in to comment.