Fix country conversion for unknown

This commit is contained in:
Ruben van de Ven 2021-10-20 10:17:37 +02:00
parent 752abb0cc6
commit 34b7a1c280

View file

@ -181,6 +181,9 @@ class Assignment(Base):
def toDict(self) -> dict: def toDict(self) -> dict:
values = {c.name: getattr(self, c.name) for c in self.__table__.columns} values = {c.name: getattr(self, c.name) for c in self.__table__.columns}
if self.turk_country: if self.turk_country:
if self.turk_country == 'Unknown':
values['turk_country_code'] = '--'
else:
values['turk_country_code'] = cc.convert([self.turk_country], to='ISO2') values['turk_country_code'] = cc.convert([self.turk_country], to='ISO2')
else: else:
values['turk_country_code'] = None values['turk_country_code'] = None
@ -192,6 +195,9 @@ class Assignment(Base):
'turk_country': self.turk_country 'turk_country': self.turk_country
} }
if self.turk_country: if self.turk_country:
if self.turk_country == 'Unknown':
values['turk_country_code'] = '--'
else:
values['turk_country_code'] = cc.convert([self.turk_country], to='ISO2') values['turk_country_code'] = cc.convert([self.turk_country], to='ISO2')
else: else:
values['turk_country_code'] = None values['turk_country_code'] = None