Fix behavior of default email/phone field with empty value

This commit is contained in:
Lance Edgar 2017-03-17 18:15:54 -05:00
parent 15eae8b2c7
commit 9808bb3a91

View file

@ -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:
if address:
email = contact.emails[0] email = contact.emails[0]
email.address = address email.address = address
else: 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:
if number:
phone = contact.phones[0] phone = contact.phones[0]
phone.number = number phone.number = number
else: else:
contact.phones.pop(0)
elif number:
phone = contact.add_phone_number(number) phone = contact.add_phone_number(number)