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()
|
address = self._deserialize()
|
||||||
contact = self.parent.model
|
contact = self.parent.model
|
||||||
if contact.emails:
|
if contact.emails:
|
||||||
email = contact.emails[0]
|
if address:
|
||||||
email.address = address
|
email = contact.emails[0]
|
||||||
else:
|
email.address = address
|
||||||
|
else:
|
||||||
|
contact.emails.pop(0)
|
||||||
|
elif address:
|
||||||
email = contact.add_email_address(address)
|
email = contact.add_email_address(address)
|
||||||
|
|
||||||
|
|
||||||
|
@ -96,7 +99,10 @@ class DefaultPhoneField(fa.Field):
|
||||||
number = self._deserialize()
|
number = self._deserialize()
|
||||||
contact = self.parent.model
|
contact = self.parent.model
|
||||||
if contact.phones:
|
if contact.phones:
|
||||||
phone = contact.phones[0]
|
if number:
|
||||||
phone.number = number
|
phone = contact.phones[0]
|
||||||
else:
|
phone.number = number
|
||||||
|
else:
|
||||||
|
contact.phones.pop(0)
|
||||||
|
elif number:
|
||||||
phone = contact.add_phone_number(number)
|
phone = contact.add_phone_number(number)
|
||||||
|
|
Loading…
Reference in a new issue