From 46c0f86f721595e7c5bb74fa365aa758104a2f82 Mon Sep 17 00:00:00 2001 From: Oliver Roick Date: Fri, 2 Dec 2016 18:28:54 +0100 Subject: [PATCH] Fix migrations --- .../migrations/0016_populate_question_index_field.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/cadasta/questionnaires/migrations/0016_populate_question_index_field.py b/cadasta/questionnaires/migrations/0016_populate_question_index_field.py index c9e19199e..9f9e0f7c3 100644 --- a/cadasta/questionnaires/migrations/0016_populate_question_index_field.py +++ b/cadasta/questionnaires/migrations/0016_populate_question_index_field.py @@ -5,6 +5,7 @@ import itertools from django.db import migrations from pyxform.xls2json import parse_file_to_json +from botocore.exceptions import ClientError def populate_index_fields(apps, schema_editor): @@ -19,7 +20,6 @@ def update_question(idx, **kwargs): question.save() def update_group(idx, **kwargs): - print(kwargs) group = QuestionGroup.objects.get(**kwargs) group.index = idx group.save() @@ -47,8 +47,13 @@ def update_children(children, questionnaire_id, question_group_id=None): id=project.current_questionnaire) if questionnaire.xls_form: - q_json = parse_file_to_json(questionnaire.xls_form.file.name) - update_children(q_json.get('children', []), questionnaire.id) + try: + q_json = parse_file_to_json( + questionnaire.xls_form.file.name) + update_children( + q_json.get('children', []), questionnaire.id) + except ClientError: + pass class Migration(migrations.Migration):