FIx #28. When user don't exist, it will create one with that external_id.

This commit is contained in:
João Nuno 2015-01-11 22:01:59 +01:00
Родитель 8af805eae9
Коммит 1c6aca6add
1 изменённых файлов: 5 добавлений и 1 удалений

Просмотреть файл

@ -198,7 +198,11 @@ class IController(object):
:param n:
:return: Item external id list
"""
user = User.get_user_by_external_id(user)
try:
user = User.get_user_by_external_id(user)
except IndexError:
logging.info("User %s not exist. Is going to be created")
user = User.objects.create(external_id=user)
result = self.get_recommendation(user=user, n=n)
return [Item.get_item_external_id_by_id(r) for r in result]