Fix behavior of default email/phone field with empty value
This commit is contained in:
parent
15eae8b2c7
commit
9808bb3a91
|
@ -72,9 +72,12 @@ class DefaultEmailField(fa.Field):
|
|||
address = self._deserialize()
|
||||
contact = self.parent.model
|
||||
if contact.emails:
|
||||
if address:
|
||||
email = contact.emails[0]
|
||||
email.address = address
|
||||
else:
|
||||
contact.emails.pop(0)
|
||||
elif address:
|
||||
email = contact.add_email_address(address)
|
||||
|
||||
|
||||
|
@ -96,7 +99,10 @@ class DefaultPhoneField(fa.Field):
|
|||
number = self._deserialize()
|
||||
contact = self.parent.model
|
||||
if contact.phones:
|
||||
if number:
|
||||
phone = contact.phones[0]
|
||||
phone.number = number
|
||||
else:
|
||||
contact.phones.pop(0)
|
||||
elif number:
|
||||
phone = contact.add_phone_number(number)
|
||||
|
|
Loading…
Reference in a new issue