From 34b7a1c280eaea2797aafa31db98c919a2431ece Mon Sep 17 00:00:00 2001 From: Ruben van de Ven Date: Wed, 20 Oct 2021 10:17:37 +0200 Subject: [PATCH] Fix country conversion for unknown --- sorteerhoed/HITStore.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/sorteerhoed/HITStore.py b/sorteerhoed/HITStore.py index 4ea1556..e4175ce 100644 --- a/sorteerhoed/HITStore.py +++ b/sorteerhoed/HITStore.py @@ -181,7 +181,10 @@ class Assignment(Base): def toDict(self) -> dict: values = {c.name: getattr(self, c.name) for c in self.__table__.columns} if self.turk_country: - values['turk_country_code'] = cc.convert([self.turk_country], to='ISO2') + if self.turk_country == 'Unknown': + values['turk_country_code'] = '--' + else: + values['turk_country_code'] = cc.convert([self.turk_country], to='ISO2') else: values['turk_country_code'] = None return values @@ -192,7 +195,10 @@ class Assignment(Base): 'turk_country': self.turk_country } if self.turk_country: - values['turk_country_code'] = cc.convert([self.turk_country], to='ISO2') + if self.turk_country == 'Unknown': + values['turk_country_code'] = '--' + else: + values['turk_country_code'] = cc.convert([self.turk_country], to='ISO2') else: values['turk_country_code'] = None return values