From 2becc0b25793855b2c6db2f1ba526d0760361889 Mon Sep 17 00:00:00 2001 From: michigg Date: Mon, 4 Dec 2017 11:51:27 +0100 Subject: [PATCH] Fix the fuck --- ofu_app/apps/food/utils/migrate_data.py | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/ofu_app/apps/food/utils/migrate_data.py b/ofu_app/apps/food/utils/migrate_data.py index 15e71af..a4d7395 100644 --- a/ofu_app/apps/food/utils/migrate_data.py +++ b/ofu_app/apps/food/utils/migrate_data.py @@ -35,10 +35,22 @@ def writeStudentenwerkDataInDB(data): allergens.append(Allergene.objects.get(name=allergen)) try: if 'prices' in single_food: + if 'price_student' in single_food['prices']: + price_student = single_food['prices']['price_student'] + else: + price_student = "None" + if 'price_employee' in single_food['prices']: + price_employee = single_food['prices']['price_employee'] + else: + price_employee = "None" + if 'price_guest' in single_food['prices']: + price_guest = single_food['prices']['price_guest'] + else: + price_guest = "None" db_single_food = SingleFood.objects.create(name=single_food['title'], - price_student=single_food['prices']['price_student'], - price_employee=single_food['prices']['price_employee'], - price_guest=single_food['prices']['price_guest']) + price_student=price_student, + price_employee=price_employee, + price_guest=price_guest) else: db_single_food = SingleFood.objects.create(name=single_food['title']) if 'allergens' in locals():